给出两个二进制字符串a和b,返回它们的和为二进制字符串.写为哈斯克尔函数
这里是哈斯克尔的解决方案: ````````` addBinary :: 字符串 -> 字符串 -> 字符串 addBinary a b = 逆向 $ addBinaryHelper (逆向 a) (逆向 b) '0' addBinaryHelper :: 字符串 -> 字符串 -> Char -> 字符串 addBinaryHelper [] [] '0' = [] addBinaryHelper [] [] carry = [carry] addBinaryHelper [] (y:digys) carry = addBinaryHelper [] (数字数字数字 '0' y) addBinaryHelper (x:xs) [] carryBinaryHelper [x] (逆向 b) '0' addBinaryHelper (逆向 x) :: 字符串 -> 字符串 addBinaryHelper [] [] [] [] [0' = [0' B1' 取两个字符串的总和值,其中 '0' = '0' ('0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0 '0 '0 '0' '0 '0' '0' '0