background
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| background [2022/04/23 14:34] – [Understanding Haskell] f2b216 | background [2025/10/08 00:44] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 32: | Line 32: | ||
| ===== Understanding Haskell ===== | ===== Understanding Haskell ===== | ||
| - | Just to imagine how rich Haskell is in terms of abstraction - enyoy the example below. | + | Just to imagine how rich Haskell is in terms of abstraction |
| The following shows how 10 primes are evaluated and displayed starting with the one millionth prime number. | The following shows how 10 primes are evaluated and displayed starting with the one millionth prime number. | ||
| Line 93: | 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.1650717266.txt.gz · Last modified: (external edit)
