B. Pym
2024-08-31 07:09:04 UTC
Which reminds me, where's the obligatory Haskell response?
No problem :-)(let (res)
(dotimes (i 11 (nreverse res))
(dotimes (j 11)
(push (+ i j) res))))
[x + y | x <- [0..10], y <- [0..10]]
(use srfi-42) ; list-ec
(list-ec (: x 11) (: y 11) (+ x y))
Can it be done with a single "do*"?
(do* ((r '())
(j 0 (mod (+ j 1) 11))
(i 0 (if (zero? j) (+ 1 i) i)))
((= 11 i) (reverse r))
(push! r (+ i j)))
(0 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9
10 11 12 3 4 5 6 7 8 9 10 11 12 13 4 5 6 7 8 9 10 11 12 13 14
5 6 7 8 9 10 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 16 7 8 9
10 11 12 13 14 15 16 17 8 9 10 11 12 13 14 15 16 17 18 9 10 11
12 13 14 15 16 17 18 19 10 11 12 13 14 15 16 17 18 19 20)