summaryrefslogtreecommitdiffstats
path: root/tests/19-list.sml
blob: 52404dc7c27f49ef02281d7d3b11da9b33f175c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
infix 6 +
infixr 5 ::

datatype 'a list = Nil | :: of 'a * 'a list

fun x + y = __builtin "add" (x, y)

fun foldl _ acc Nil = acc
  | foldl f acc (x :: xs) = foldl f (f (x, acc)) xs

val _ = __builtin "exit" (foldl op + 0 (1 :: 2 :: 3 :: 6 :: 8 :: 10 :: 12 :: Nil))