summaryrefslogtreecommitdiff
path: root/tests/dlist.ur
blob: 0733a0dbfe2ba03ff685b5e975eb2887763d8cef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
datatype dlist = Nil | Cons of string * source dlist

fun delist dl =
    case dl of
        Nil => <xml>[]</xml>
      | Cons (x, s) => <xml>{[x]} :: ({delistSource s})</xml>

and delistSource s = <xml><dyn signal={dl <- signal s; return (delist dl)}/></xml>

fun main () : transaction page =
    ns <- source Nil;
    s <- source ns;
    tb <- source "";
    return <xml><body>
      <dyn signal={s <- signal s; return (delistSource s)}/><br/>
      <br/>
      <ctextbox source={tb}/>
      <button value="Add" onclick={hd <- get tb;
                                   tl <- get s;
                                   s' <- source (Cons (hd, tl));
                                   set s s'}/>
      <button value="Reset" onclick={set s ns}/>
    </body></xml>