summaryrefslogtreecommitdiff
path: root/lib/ur/list.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2019-02-12 11:05:48 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2019-02-12 11:05:48 -0500
commit62dfceb86ba7dfbabb0fabaf89c9cbc8d08afc32 (patch)
tree74a0bdb21e89ee2a09ac71ee80d377939b63f191 /lib/ur/list.ur
parentb9ddbe0ce5c700fef313788fda5c7ecb82c84638 (diff)
List.mapConcat and mapConcatM
Diffstat (limited to 'lib/ur/list.ur')
-rw-r--r--lib/ur/list.ur20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index b38097b7..848bbd5f 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -101,6 +101,16 @@ fun mp [a] [b] f =
mp' []
end
+fun mapConcat [a] [b] f =
+ let
+ fun mapConcat' acc ls =
+ case ls of
+ [] => rev acc
+ | x :: ls => mapConcat' (revAppend (f x) acc) ls
+ in
+ mapConcat' []
+ end
+
fun mapi [a] [b] f =
let
fun mp' n acc ls =
@@ -153,6 +163,16 @@ fun mapM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f =
mapM' []
end
+fun mapConcatM [m] (_ : monad m) [a] [b] f =
+ let
+ fun mapConcatM' acc ls =
+ case ls of
+ [] => return (rev acc)
+ | x :: ls' => ls <- f x; mapConcatM' (revAppend ls acc) ls'
+ in
+ mapConcatM' []
+ end
+
fun mapMi [m ::: (Type -> Type)] (_ : monad m) [a] [b] f =
let
fun mapM' i acc ls =