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 22:01] – [Difficulties to understand Haskell? You are not alone.] f2b216 | background [2025/10/08 00:44] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 32: | 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 55: | 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 91: | 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.1650571277.txt.gz · Last modified: (external edit)
