summaryrefslogtreecommitdiff
path: root/tests/list.ur
blob: 815c0075164378a81073f29b3f428c20edff86a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fun isNil (t ::: Type) (ls : list t) =
    case ls of
        Nil => True
      | _ => False

fun delist (ls : list string) : xbody =
        case ls of
            Nil => <xml>Nil</xml>
          | Cons (h, t) => <xml>{[h]} :: {delist t}</xml>

fun main () = return <xml><body>
  {[isNil (Nil : list bool)]},
  {[isNil (Cons (1, Nil))]},
  {[isNil (Cons ("A", Cons ("B", Nil)))]}

  <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p>
</body></xml>