So I'm trying to write a function which performs a input function f on input list ls [l1, l2, ..., ln] and output a string "[" ++ (f l1) ++ "," ++ (f l2) ++ "," ++ ... ++ (f ln) ++ "]"
flist :: (a -> String) -> [a] -> String
flist f ls =
for example:
>flist show [1, 2, 3]
would output "[1, 2, 3]"
>flist (fun x -> x) ["dog"]
would output "[dog]"
I tried to use foldl'
flist f ls = "[" ++ (foldl' (++) f "," ls) ++ "]"
which doesn't seems to be working