From f2882c39c1acb5abc16f49524acb08d6c0b7b1d5 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 7 Feb 2020 13:53:50 -0500 Subject: List.foldli --- lib/ur/list.ur | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/ur/list.ur') diff --git a/lib/ur/list.ur b/lib/ur/list.ur index 848bbd5f..1eb7626a 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -31,6 +31,16 @@ fun foldl [a] [b] (f : a -> b -> b) = foldl' end +fun foldli [a] [b] (f : int -> a -> b -> b) = + let + fun foldli' i acc ls = + case ls of + [] => acc + | x :: ls => foldli' (i + 1) (f i x acc) ls + in + foldli' 0 + end + val rev = fn [a] => let fun rev' acc (ls : list a) = -- cgit v1.2.3