summaryrefslogtreecommitdiff
path: root/demo/more/dlist.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-09-17 16:35:11 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-09-17 16:35:11 -0400
commit13e3b7139dcee90106332ff4fb5b3c63fcf4a892 (patch)
tree9d7a2e3bc1dff89e7399d555415ffae5c45c8b52 /demo/more/dlist.ur
parent7c045f4dd298b8cc1cbe5895b4fc30280e23abbf (diff)
Basic tail recursion introduction seems to be working
Diffstat (limited to 'demo/more/dlist.ur')
-rw-r--r--demo/more/dlist.ur18
1 files changed, 18 insertions, 0 deletions
diff --git a/demo/more/dlist.ur b/demo/more/dlist.ur
index a8c464a6..6e660ab8 100644
--- a/demo/more/dlist.ur
+++ b/demo/more/dlist.ur
@@ -48,6 +48,24 @@ fun append [t] dl v =
set tl new;
return (tailPos cur new tl)
+fun replace [t] dl ls =
+ case ls of
+ [] => set dl Empty
+ | x :: ls =>
+ tl <- source Nil;
+ let
+ fun build ls acc =
+ case ls of
+ [] => return acc
+ | x :: ls =>
+ this <- source (Cons (x, tl));
+ build ls this
+ in
+ hd <- build (List.rev ls) tl;
+ tlS <- source tl;
+ set dl (Nonempty {Head = Cons (x, hd), Tail = tlS})
+ end
+
fun renderDyn [ctx] [ctx ~ body] [t] (f : t -> position -> xml (ctx ++ body) [] []) filter dl = <xml>
<dyn signal={dl' <- signal dl;
return (case dl' of