mk: enumerate-i / enumerate-from-i — 501/501 milestone
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s

(enumerate-i l result): result is l with each element paired with its
0-based index. (enumerate-from-i n l result): same but starts at n.

  (enumerate-i (list :a :b :c) q) -> (((0 :a) (1 :b) (2 :c)))

5 new tests, 501/501 cumulative.
This commit is contained in:
2026-05-08 12:20:03 +00:00
parent 221c7fef35
commit 08f4a7babd
3 changed files with 42 additions and 0 deletions

View File

@@ -117,3 +117,13 @@
(conde
((nullo l) (== n 0))
((fresh (a d n-1) (conso a d l) (lengtho-i d n-1) (pluso-i 1 n-1 n))))))
(define
enumerate-from-i
(fn
(start l result)
(conde
((nullo l) (nullo result))
((fresh (a d r-rest start-prime) (conso a d l) (conso (list start a) r-rest result) (pluso-i 1 start start-prime) (enumerate-from-i start-prime d r-rest))))))
(define enumerate-i (fn (l result) (enumerate-from-i 0 l result)))