test/syntax/source/code/sml
raw| 1 | structure List : LIST = |
| 2 | struct |
| 3 | |
| 4 | val op + = InlineT.DfltInt.+ |
| 5 | |
| 6 | datatype list = datatype list |
| 7 | |
| 8 | exception Empty = Empty |
| 9 | |
| 10 | fun last [] = raise Empty |
| 11 | | last [x] = x |
| 12 | | last (_::r) = last r |
| 13 | |
| 14 | fun loop ([], []) = EQUAL |
| 15 | | loop ([], _) = LESS |
| 16 | | loop (_, []) = GREATER |
| 17 | | loop (x :: xs, y :: ys) = |
| 18 | (case compare (x, y) of |
| 19 | EQUAL => loop (xs, ys) |
| 20 | | unequal => unequal) |
| 21 | in |
| 22 | loop |
| 23 | end |
| 24 | |
| 25 | end (* structure List *) |
| 26 |