From 56b0ca377a30e30bf832d6dfdb789676f67e7ade Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 30 May 2017 19:44:46 -0400 Subject: - Re-implemented "every?" and "any?" for better performance. --- stdlib/source/lux/data/coll/list.lux | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'stdlib/source') 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 ( p xs) (All [a] (-> (-> a Bool) (List a) Bool)) - (fold (function [_2 _1] ( _1 (p _2))) xs))] + (loop [xs xs] + (case xs + #;Nil + + + (#;Cons x xs') + (case (p x) + + (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."} -- cgit v1.2.3