It's like the title says. I've implemented this, but maybe this function already has a common name and exists in a standard library.
Other suggestions about this function are welcome. Maybe there is a cleaner implementation.
let transform x funcList = transform' x [x] funcList
where transform' startVal accum funcList
| null funcList = reverse accum
| otherwise = let result = (head funcList) startVal
in transform' result (result:accum) $ tail funcList
When executed, it does this:
> transform 2 [(2 + ),((-1) +),(3 *)]
[2,4,3,9]
You can define it with scanl:
let transform = scanl (\v f -> f v)
or
let transform = scanl (flip ($))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With