Write a Haskell program to produce the infinite Thue sequence, t, defined by the limit
lim i->infinity: ti
where
t0 = 0
ti+1 =
ti [0->01,
1->10]
The last expression means replace (simultaenously) each 0 in ti by 01 and each 1 by 10. Thus
t = 01101001100101101001011001101001...
Some properties that may be verified:
infixl 6 # -- 6 is the same precedence as +
(#) :: [a] -> [a] -> [a]
[] # [] = []
(x:xs) # (y:ys) = x : y : xs#ys
nand :: Bool -> Bool -> Bool
nand True True = False
nand _ _ = True
Write a Haskell program that finds a minimal nand-only expression for each of the 16 binary operations with signature Bool×Bool->Bool. For example, the binary operation f(x,y) whose truth table is
| x | y | f(x,y) |
| False | False | True |
| False | True | True |
| True | False | False |
| True | True | False |
Problems designed by Doug McIlroy
Last modified:
Tue May 20 12:03:50 EDT 2003