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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user