spec: sequence protocol tests — 45 tests, all passing on JS and OCaml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 10:18:37 +00:00
parent 06a3eee114
commit 0fe00bf7ac
5 changed files with 233 additions and 18 deletions

View File

@@ -3649,7 +3649,8 @@
(fn
(s)
(cond
((or (= s nil) (list? s)) (len s))
((= s nil) 0)
((list? s) (len s))
((vector? s) (vector-length s))
((string? s) (len s))
(else (len (seq-to-list s))))))
@@ -3674,6 +3675,15 @@
((and (string? s1) (string? s2)) (str s1 s2))
(else (concat (seq-to-list s1) (seq-to-list s2))))))
(define
build-range
(fn
(i end step acc)
(if
(if (> step 0) (>= i end) (<= i end))
(reverse acc)
(build-range (+ i step) end step (cons i acc)))))
(define
in-range
(fn
@@ -3686,16 +3696,7 @@
(if
(= step 0)
(error "in-range: step cannot be zero")
(do
(define
build
(fn
(i acc)
(if
(if (> step 0) (>= i end) (<= i end))
(reverse acc)
(build (+ i step) (cons i acc)))))
(build real-start (list)))))))
(build-range real-start end step (list))))))
(define
step-ho-map