Created
October 1, 2016 17:16
-
-
Save hudon/424d483a91b54f69f9e0c6f74735e945 to your computer and use it in GitHub Desktop.
add two lists of arbitrary bytes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byteSum :: [Word8] -> [Word8] -> [Word8] | |
byteSum = byteSum' 0 | |
where | |
byteSum' 0 [] [] = [] | |
byteSum' 1 [] [] = [1] | |
byteSum' carry (x:xs) (y:ys) = | |
let v = x + y + carry | |
in v : byteSum' (if v < x || v < y then 1 else 0) xs ys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment