~jojo/Carth

ref: ee5251b9b8bf725c1d5499fedf9c9671308fa476 Carth/examples/sieve.carth -rw-r--r-- 376 bytes
ee5251b9JoJo Glob exports in AST modules -- minor refactor / cleanup 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
(import std)

(define (main Unit)
  (let ((primes (sieve (range-from 2))))
    (for primes (<o display show-int))))

(define (sieve xs)
  (Iter (fun (_)
          (match (next! xs)
            (case (Pair x xs')
                  (Some (Pair x
                              (sieve (filter (<o not (flip divisible? x))
                                             xs')))))))))