The real (and always perplexing) problem is that OCaml doesn't have a built-in function composition operator. So it's not so good out of the box for pointfree coding. If you really want to get fancy with it, you also need flip
, which inverts the order of the arguments of a two-argument function.
let flip f a b = f b a
At any rate, I don't see any problem with your solution once you've defined function composition as $
. You can leave out some of the parentheses:
# let lts = String.concat "" $ List.map (String.make 1);;
val lts : char list -> string = <fun>
As to efficiency, I assume this is more of a puzzle than a practical bit of code. Otherwise you should use the functions that Edwin suggests.