diff options
author | Eduardo Julian | 2017-05-30 19:44:46 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-05-30 19:44:46 -0400 |
commit | 56b0ca377a30e30bf832d6dfdb789676f67e7ade (patch) | |
tree | cb44d9a1a3302a9563b62a9e1e7710b57e4771d5 /stdlib/source | |
parent | bbf78668e9ae2fb3deb78217ae97791df89ada56 (diff) |
- Re-implemented "every?" and "any?" for better performance.
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux/data/coll/list.lux | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux index 958ef16df..568aded11 100644 --- a/stdlib/source/lux/data/coll/list.lux +++ b/stdlib/source/lux/data/coll/list.lux @@ -204,10 +204,22 @@ [(def: #export (<name> p xs) (All [a] (-> (-> a Bool) (List a) Bool)) - (fold (function [_2 _1] (<op> _1 (p _2))) <init> xs))] + (loop [xs xs] + (case xs + #;Nil + <init> + + (#;Cons x xs') + (case (p x) + <init> + (recur xs') + + output + output))))] [every? true and] - [any? false or]) + [any? false or] + ) (def: #export (nth i xs) {#;doc "Fetches the element at the specified index."} |