adamc@315: datatype list a = Nil | Cons of a * list a adamc@315: adamc@315: fun isNil (t ::: Type) (ls : list t) : bool = adamc@315: case ls of adamc@315: Nil => True adamc@315: | Cons _ => False adamc@315: adamc@316: fun append (t ::: Type) (ls1 : list t) (ls2 : list t) : list t = adamc@315: case ls1 of adamc@315: Nil => ls2 adamc@315: | Cons (x, ls1') => Cons (x, append ls1' ls2) adamc@315: adamc@317: fun pairAppend (t1 ::: Type) (t2 ::: Type) (ls1 : list (t1 * t2)) (ls2 : list (t1 * t2)) : list (t1 * t2) = adamc@317: case ls1 of adamc@317: Nil => ls2 adamc@317: | Cons (x, ls1') => Cons (x, pairAppend ls1' ls2) adamc@317: adamc@315: fun delist (ls : list string) : xml body [] [] = adamc@315: case ls of adamc@315: Nil =>
Nil adamc@316: | Cons (h, t) => {cdata h} :: {delist t} adamc@315: adamc@317: fun pairDelist (ls : list (string * int)) : xml body [] [] = adamc@317: case ls of adamc@317: Nil => Nil adamc@317: | Cons ((s, n), t) => ({cdata s}, {cdata (show _ n)}) :: {pairDelist t} adamc@317: adamc@315: val ls = Cons ("X", Cons ("Y", Cons ("Z", Nil))) adamc@316: val ls' = Cons ("A", Cons ("B", Nil)) adamc@315: adamc@317: val pls = Cons (("X", 1), Cons (("Y", 2), Cons (("Z", 3), Nil))) adamc@317: val pls' = Cons (("A", 1), Cons (("B", 2), Nil)) adamc@317: adamc@315: fun main () : transaction page = return adamc@315: {if isNil ls then It's Nil. else It's not Nil.} adamc@316: adamc@316:{delist (append ls' ls)}
adamc@317: adamc@317:{pairDelist (pairAppend pls' pls)}
adamc@315: