; Iter 15h — demo for the new std_list combinators `take` and `drop`. ; Uses a top-level `(const xs)` for the canonical [1, 2, 3, 4, 5] — ; pure ctor expression, so a const is fine (same idiom as ; std_list_demo). Six checks pin both n=0, 0length ; boundaries on each combinator. (module std_list_more_demo (import std_list) (const xs (doc "The canonical [1, 2, 3, 4, 5] used across all checks.") (type (con List (con Int))) (body (term-ctor List Cons 1 (term-ctor List Cons 2 (term-ctor List Cons 3 (term-ctor List Cons 4 (term-ctor List Cons 5 (term-ctor List Nil)))))))) (fn main (doc "Expected output (one per line): 0, 3, 5, 5, 3, 0.") (type (fn-type (params) (ret (own (con Unit))) (effects IO))) (params) (body (seq (seq (app print (app List.length (app List.take 0 xs))) (do io/print_str "\n")) (seq (seq (app print (app List.length (app List.take 3 xs))) (do io/print_str "\n")) (seq (seq (app print (app List.length (app List.take 100 xs))) (do io/print_str "\n")) (seq (seq (app print (app List.length (app List.drop 0 xs))) (do io/print_str "\n")) (seq (seq (app print (app List.length (app List.drop 2 xs))) (do io/print_str "\n")) (seq (app print (app List.length (app List.drop 100 xs))) (do io/print_str "\n"))))))))))