(* VSTTE'10 competition Problem 3: searching a linked list *){ use export list.List use export list.Length use export option.Option(* logic nth (n : int) (l : list 'a) = match l with | Nil -> None | Cons x r -> if n = 0 then Some x else nth (n - 1) r end*)}let rec search i l = match l with | Nil -> i | Cons x r -> if x = 0 then i else search (i+1) r endlet search_list l = { } search 0 l { (0 <= result < length l (* nth result l = 0*)) or (result = length l) }(*Local Variables: compile-command: "unset LANG; make -C ../.. examples/programs/vstte10_search_list.gui"End: *)