Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add x y = strSum '0' (fst (sameLength x y)) (snd (sameLength x y))
  2.  
  3. sameLength x y
  4.  | length x < length y = ((resize (length y) x), y)
  5.  | length x > length y = (x, (resize (length x) y))
  6.  | otherwise = (x, y)
  7.  
  8. strSum _ "" "" = ""
  9. strSum c x y = strSum (snd (bitSum c (last x) (last y))) (init x) (init y) ++ [fst (bitSum c (last x) (last y))]
  10.  
  11. bitSum '0' '0' '0' = ('0', '0')
  12. bitSum '0' '1' '0' = ('1', '0')
  13. bitSum '0' '0' '1' = ('1', '0')
  14. bitSum '0' '1' '1' = ('0', '1')
  15. bitSum '1' '0' '0' = ('1', '0')
  16. bitSum '1' '1' '0' = ('0', '1')
  17. bitSum '1' '0' '1' = ('0', '1')
  18. bitSum '1' '1' '1' = ('1', '1')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement