Skip to content

Instantly share code, notes, and snippets.

@hudon
Created October 1, 2016 17:16
Show Gist options
  • Select an option

  • Save hudon/424d483a91b54f69f9e0c6f74735e945 to your computer and use it in GitHub Desktop.

Select an option

Save hudon/424d483a91b54f69f9e0c6f74735e945 to your computer and use it in GitHub Desktop.

Revisions

  1. hudon created this gist Oct 1, 2016.
    8 changes: 8 additions & 0 deletions bytesum.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    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