comparison demo/more/dlist.ur @ 954:2a50da66ffd8

Basic tail recursion introduction seems to be working
author Adam Chlipala <adamc@hcoop.net>
date Thu, 17 Sep 2009 16:35:11 -0400
parents 301530da2062
children 2831be2daf2e
comparison
equal deleted inserted replaced
953:301530da2062 954:2a50da66ffd8
45 cur <- get tl; 45 cur <- get tl;
46 new <- source Nil; 46 new <- source Nil;
47 set cur (Cons (v, new)); 47 set cur (Cons (v, new));
48 set tl new; 48 set tl new;
49 return (tailPos cur new tl) 49 return (tailPos cur new tl)
50
51 fun replace [t] dl ls =
52 case ls of
53 [] => set dl Empty
54 | x :: ls =>
55 tl <- source Nil;
56 let
57 fun build ls acc =
58 case ls of
59 [] => return acc
60 | x :: ls =>
61 this <- source (Cons (x, tl));
62 build ls this
63 in
64 hd <- build (List.rev ls) tl;
65 tlS <- source tl;
66 set dl (Nonempty {Head = Cons (x, hd), Tail = tlS})
67 end
50 68
51 fun renderDyn [ctx] [ctx ~ body] [t] (f : t -> position -> xml (ctx ++ body) [] []) filter dl = <xml> 69 fun renderDyn [ctx] [ctx ~ body] [t] (f : t -> position -> xml (ctx ++ body) [] []) filter dl = <xml>
52 <dyn signal={dl' <- signal dl; 70 <dyn signal={dl' <- signal dl;
53 return (case dl' of 71 return (case dl' of
54 Empty => <xml/> 72 Empty => <xml/>