
25 May
2007
25 May
'07
6:55 p.m.
Donald Bruce Stewart wrote:
instance Num String anyone? Mwhaha
addString xs ys = add 0 xs ys where m = fromEnum (maxBound :: Char) + 1 alu c x y = let s = c + fromEnum x + fromEnum y in if s >= m then (1, s-m) else (0, s) add c (x:xs) (y:ys) = case alu c x y of (c', s') -> toEnum s' : add c' xs ys add c [] (y:ys) = case alu c 0 y of (0, s') -> toEnum s' : ys (1, s') -> toEnum s' : add 1 [] ys add c xs@(_:_) [] = add c [] xs add c [] [] = if c==0 then [] else [toEnum c]