diff options
Diffstat (limited to 'stdlib/source/lux/data/collection/list.lux')
-rw-r--r-- | stdlib/source/lux/data/collection/list.lux | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/stdlib/source/lux/data/collection/list.lux b/stdlib/source/lux/data/collection/list.lux index 1e00ee529..cec488e95 100644 --- a/stdlib/source/lux/data/collection/list.lux +++ b/stdlib/source/lux/data/collection/list.lux @@ -25,7 +25,7 @@ #.Nil init - (#.Cons [x xs']) + (#.Cons x xs') (fold f (f x init) xs')))) (def: #export (reverse xs) @@ -42,7 +42,7 @@ #.Nil #.Nil - (#.Cons [x xs']) + (#.Cons x xs') (if (keep? x) (#.Cons x (filter keep? xs')) (filter keep? xs')))) @@ -57,16 +57,16 @@ (#.Cons head tail) (let [[in out] (partition satisfies? tail)] (if (satisfies? head) - [(list& head in) out] - [in (list& head out)])))) + [(#.Cons head in) out] + [in (#.Cons head out)])))) (def: #export (as-pairs xs) {#.doc (doc "Cut the list into pairs of 2." "Caveat emptor: If the list has an uneven number of elements, the last one will be skipped.")} (All [a] (-> (List a) (List [a a]))) (case xs - (^ (#.Cons [x1 (#.Cons [x2 xs'])])) - (#.Cons [[x1 x2] (as-pairs xs')]) + (^ (list& x1 x2 xs')) + (#.Cons [x1 x2] (as-pairs xs')) _ #.Nil)) @@ -80,11 +80,11 @@ #.Nil #.Nil - (#.Cons [x xs']) + (#.Cons x xs') <then>) <else>))] - [take (#.Cons [x (take (dec n) xs')]) #.Nil] + [take (#.Cons x (take (dec n) xs')) #.Nil] [drop (drop (dec n) xs') xs] ) @@ -96,12 +96,12 @@ #.Nil #.Nil - (#.Cons [x xs']) + (#.Cons x xs') (if (predicate x) <then> <else>)))] - [take-while (#.Cons [x (take-while predicate xs')]) #.Nil] + [take-while (#.Cons x (take-while predicate xs')) #.Nil] [drop-while (drop-while predicate xs') xs] ) @@ -113,9 +113,9 @@ #.Nil [#.Nil #.Nil] - (#.Cons [x xs']) + (#.Cons x xs') (let [[tail rest] (split (dec n) xs')] - [(#.Cons [x tail]) rest])) + [(#.Cons x tail) rest])) [#.Nil xs])) (def: (split-with' predicate ys xs) @@ -125,9 +125,9 @@ #.Nil [ys xs] - (#.Cons [x xs']) + (#.Cons x xs') (if (predicate x) - (split-with' predicate (#.Cons [x ys]) xs') + (split-with' predicate (#.Cons x ys) xs') [ys xs]))) (def: #export (split-with predicate xs) @@ -153,7 +153,7 @@ (All [a] (-> Nat a (List a))) (if (n.> 0 n) - (#.Cons [x (repeat (dec n) x)]) + (#.Cons x (repeat (dec n) x)) #.Nil)) (def: (iterate' f x) @@ -161,7 +161,7 @@ (-> (-> a (Maybe a)) a (List a))) (case (f x) (#.Some x') - (list& x (iterate' f x')) + (#.Cons x (iterate' f x')) #.None (list))) @@ -172,7 +172,7 @@ (-> (-> a (Maybe a)) a (List a))) (case (f x) (#.Some x') - (list& x (iterate' f x')) + (#.Cons x (iterate' f x')) #.None (list x))) @@ -185,7 +185,7 @@ #.Nil #.None - (#.Cons [x xs']) + (#.Cons x xs') (if (predicate x) (#.Some x) (find predicate xs')))) @@ -197,7 +197,7 @@ #.Nil #.None - (#.Cons [x xs']) + (#.Cons x xs') (case (check x) (#.Some output) (#.Some output) @@ -212,7 +212,7 @@ #.Nil #.None - (#.Cons [x xs']) + (#.Cons x xs') (case (check x) (#.Some output) (#.Cons output (search-all check xs')) @@ -228,11 +228,11 @@ #.Nil xs - (#.Cons [x #.Nil]) + (#.Cons x #.Nil) xs - (#.Cons [x xs']) - (#.Cons [x (#.Cons [sep (interpose sep xs')])]))) + (#.Cons x xs') + (list& x sep (interpose sep xs')))) (def: #export (size list) (All [a] (-> (List a) Nat)) @@ -267,7 +267,7 @@ #.Nil #.None - (#.Cons [x xs']) + (#.Cons x xs') (if (n.= 0 i) (#.Some x) (nth (dec i) xs')))) @@ -343,11 +343,11 @@ {#.doc "Generates an inclusive interval of values [from, to]."} (-> <type> <type> (List <type>)) (cond (<lt> to from) - (list& from (<name> (inc from) to)) + (#.Cons from (<name> (inc from) to)) ## > GT (<lt> from to) - (list& from (<name> (dec from) to)) + (#.Cons from (<name> (dec from) to)) ## (= to from) (list from)))] |