I want to write a function f that converts a binary list to an integer, like:
f :: [Integer] -> Integer
f [] = 0
f list = (last list) * 2^(length list -1) + f (init list)
For example, in f [1,1,1,1,0,0,1,0] = 79, the first list element represents 2^0 and the last list element represents 2^7.
Can I write this function with higher-order functions instead of with explicit recursion?
foldl.length. Thinkabcd = 1*d + 2*c + 2*2*b + 2*2*2*a = 1*d + 2*(c + 2*(b + 2*a))).2^n.