1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
$$ integers (n, nmax, qo) =
(n > nmax ?
(-1) >> qo
:
n >> qo;
become integers(n+1, nmax, qo)
)
# Version alternative :
$$ integers (n, nmax, qo) =
]->[ (
(n > nmax ? ->[]);
n >> qo;
n = n + 1
);
-1 >> qo
$$ filter (n, qi, qo) =
val << qi;
(val != -1 ?
(val % n != 0 ?
val >> qo
);
become filter(n, qi, qo)
:
-1 >> qo
)
# Version alternative :
$$ filter (n, qi, qo) =
]->[ (
val << qi;
(val == -1 ? ->[]);
(val % n != 0 ? val >> qo)
);
-1 >> qo
$$ primes (qi) =
val << qi;
(val != -1 ?
val >> stdout;
c = <>;
| become filter(val, qi, c.out) |;
become primes(c.in)
)
# Version alternative :
$$ primes (qi) =
]->[ (
val << qi;
(val == -1 ? ->[]);
val >> stdout;
c = <>;
| filter(val, qi, c.out) |;
qi = c.in
)
$$ main () =
c = <>;
| integers (2, 5000, c.out) |;
primes (c.in)
|