I'm trying to write a function, pipe
that takes a list of mathematical functions where pipe [f1,...,fn] x
should return f1(f2(...(fn x)))
I've set it up such that:
pipe :: [(a -> a)] -> (a -> a)
pipe fs = foldLeft f base fs
where
f a x =
base =
-- >>> pipe [] 3
-- 3
--
-- >>> pipe [(\x -> x+x), (\x -> x + 3)] 3
-- 12
--
-- >>> pipe [(\x -> x * 4), (\x -> x + x)] 3
-- 24
whats the best way to go about this using foldl? Thanks!