baskell-0.1: examples/NameSupply.bs
# Generates an infinite list of strings, following this
# sequence:
#
# ["a", "b" ..."z",
# "aa", "ab" ... "az",
# "ba", "bb" ... "bz",
# ...
# "za", "zb" ... "zz",
# "aaa", "aab" ... "aaz",
# "aba", "abb" ... "abz",
# ...
# "zza", "zzb" ... "zzz",
# ...
#
# In Haskell you would define it this way:
#
# ns = [x ++ [y] | x <- []:ns, y <- ['a'..'z']]
#
# Author: Bernie Pope
# Date: 10 October 2004
forallWorker
= !f -> !list1 -> !list2 -> !list3 ->
ite (null list1)
(ite (null list3)
[]
(forallWorker f list2 list2 (tail list3)))
(ite (null list3)
[]
(Cons (f (head list1) (head list3))
(forallWorker f (tail list1) list2 list3)));
forall
= !f -> !list1 -> !list2 ->
forallWorker f list1 list1 list2;
ns
= forall (\x -> \y -> append y (single x))
aToZ
(Cons [] ns);
single = \x -> Cons x [];
aToZ
= ['a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z'];