|
|
1.1 ! root 1: (* Copyright 1989 by AT&T Bell Laboratories *) ! 2: (* list2.sml *) ! 3: (* functionals over pairs of lists *) ! 4: ! 5: structure List2 = struct ! 6: ! 7: fun app2 f ([],_) = () ! 8: | app2 f (_,[]) = () ! 9: | app2 f (a::l,b::m) = (f(a,b); app2 f (l,m)) ! 10: ! 11: fun map2 f ([],_) = [] ! 12: | map2 f (_,[]) = [] ! 13: | map2 f (a::l,b::m) = f(a,b)::(map2 f (l,m)) ! 14: ! 15: fun all2 pred ([],[]) = true ! 16: | all2 pred (a::l,b::m) = pred(a,b) andalso all2 pred (m,l) ! 17: | all2 pred _ = false; ! 18: ! 19: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.