aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/ur/list.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@csail.mit.edu>2016-02-26 10:32:08 -0500
committerGravatar Adam Chlipala <adamc@csail.mit.edu>2016-02-26 10:32:08 -0500
commitb0368093645dcb7f65e131862d8ae9c81f2844f2 (patch)
tree1489b634f26d305ef082a44af62b3f7742b4aa6e /lib/ur/list.ur
parent69e9c6064e7728458a9ba365726706612d10e3f8 (diff)
More consistent formatting for new List functions
Diffstat (limited to 'lib/ur/list.ur')
-rw-r--r--lib/ur/list.ur26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index eac5ab0c..50764e46 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -435,29 +435,29 @@ fun drop [a] (n : int) (xs : list a) : list a =
fun splitAt [a] (n : int) (xs : list a) : list a * list a =
(take n xs, drop n xs)
-fun span [a] (f:(a -> bool)) (ls:list a) : list a * list a =
+fun span [a] (f : a -> bool) (ls : list a) : list a * list a =
let
- fun span' f acc ls =
+ fun span' ls acc =
case ls of
[] => (rev acc, [])
- | x :: xs => if (f x) then span' f (x :: acc) xs else (rev acc, ls)
+ | x :: xs => if f x then span' xs (x :: acc) else (rev acc, ls)
in
- span' f [] ls
+ span' ls []
end
-fun groupBy [a] (f:(a -> a -> bool)) (ls:list a) : list (list a) =
+fun groupBy [a] (f : a -> a -> bool) (ls : list a) : list (list a) =
let
- fun groupBy' f ls =
+ fun groupBy' ls acc =
case ls of
- [] => [] :: []
+ [] => rev ([] :: acc)
| x :: xs =>
- let
- val (ys, zs) = span (f x) xs
- in
- (x :: ys) :: (groupBy' f zs)
- end
+ let
+ val (ys, zs) = span (f x) xs
+ in
+ groupBy' zs ((x :: ys) :: acc)
+ end
in
- groupBy' f ls
+ groupBy' ls []
end
fun mapXiM [m ::: Type -> Type] (_ : monad m) [a] [ctx ::: {Unit}] (f : int -> a -> m (xml ctx [] [])) : t a -> m (xml ctx [] []) =