background
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| background [2022/04/21 21:58] – [Difficulties to understand Haskell? You are not alone.] f2b216 | background [2025/10/08 00:44] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| * Often, the code examples are not appropriate. | * Often, the code examples are not appropriate. | ||
| * ..or I am to stupid? | * ..or I am to stupid? | ||
| - | * A lot of the available examples are outdated. | + | * A lot of the available examples are outdated, and incompatible with current packages, libraries and compiler versions. |
| * Often just incomplete. | * Often just incomplete. | ||
| - | * Often incompatible with the current packages. | ||
| * Often they contain confusing useless, warning generating statements. | * Often they contain confusing useless, warning generating statements. | ||
| * Example here: [[confusing: | * Example here: [[confusing: | ||
| Line 33: | Line 32: | ||
| ===== Understanding Haskell ===== | ===== Understanding Haskell ===== | ||
| - | Let's understand | + | Just to imagine |
| + | |||
| + | The following shows how 10 primes are evaluated and displayed starting with the one millionth prime number. | ||
| * Example )< | * Example )< | ||
| Line 56: | Line 57: | ||
| </ | </ | ||
| - | To understand this code (7 lines of code) completely I have to understand the following: | + | To understand this code (8 lines of code) completely I have to understand the following: |
| - Packets | - Packets | ||
| - Import | - Import | ||
| Line 92: | Line 93: | ||
| )< | )< | ||
| + | |||
| + | The following code (sieve of Erastothenes) will also work but by far not as fast for large numbers (approximately 100 times slower for the first 20 thousand prime numbers): | ||
| + | <code Haskell> | ||
| + | primes = let sieve (n0:lrn) = n0 : sieve [ n | n <- lrn, n `mod` n0 /= 0 ] in sieve [2..] | ||
| + | </ | ||
| )< | )< | ||
background.1650571138.txt.gz · Last modified: (external edit)
