summaryrefslogtreecommitdiff
path: root/demo/more/dlist.ur
diff options
context:
space:
mode:
Diffstat (limited to 'demo/more/dlist.ur')
-rw-r--r--demo/more/dlist.ur14
1 files changed, 14 insertions, 0 deletions
diff --git a/demo/more/dlist.ur b/demo/more/dlist.ur
index 1a5be7e3..fe0cdd07 100644
--- a/demo/more/dlist.ur
+++ b/demo/more/dlist.ur
@@ -246,6 +246,20 @@ fun elements [t] (dl : dlist t) =
Empty => return []
| Nonempty {Head = hd, ...} => elements' hd
+fun size' [t] (dl'' : dlist'' t) =
+ case dl'' of
+ Nil => return 0
+ | Cons (x, dl'') =>
+ dl'' <- signal dl'';
+ n <- size' dl'';
+ return (n + 1)
+
+fun size [t] (dl : dlist t) =
+ dl' <- signal dl;
+ case dl' of
+ Empty => return 0
+ | Nonempty {Head = hd, ...} => size' hd
+
fun foldl [t] [acc] (f : t -> acc -> signal acc) =
let
fun foldl'' (i : acc) (dl : dlist'' t) : signal acc =