collectWhileLet

This commit is contained in:
2023-05-02 16:46:08 -06:00
parent ca019159f6
commit a6c0cf88c6
2 changed files with 24 additions and 1 deletions

View File

@@ -679,7 +679,14 @@ From:[(assert false (+ \"false \" \"should \" \"have \" \"been \" \"true\"))]" m
stream (Stream.fromString "a\nb\nc")]
(whileLet [(Some line) (stream.takeLine)]
(Assert.equals (nth lines idx) line)
(+= idx 1))))
(+= idx 1)))
(let [lines ["a" "b" "c"]
options [(Some "a") (Some "b") (Some "c") None]
collected
(collectWhileLet [(Some line) (options.shift)]
line)]
(doFor i (range collected.length)
(Assert.equals (nth lines i) (nth collected i)))))
(function _testTrace []
(Assert.equals 5 (trace 5 "num"))