On Wed, 21 May 2014 12:49:49 -0700, Shayne Fletcher wrote:
> 
> In site/learn/tutorials/99problems.md:
> 
> > +    let e_i k i acc = 
> > +     Printf.sprintf "'%c':%d, %s" k i acc in
> > +    let e_c k v acc =
> > +     Printf.sprintf "'%c':%c, %s" k (Char_map.find k pred) acc in
> > +    "  d = {" ^ Char_map.fold e_i d "" ^ "}\n"^
> > +    "  f = {" ^ Char_map.fold e_i f "" ^ "}\n"^
> > +    "  pred ={" ^ Char_map.fold e_c pred "" ^ "}\n"
> > +
> I see that function can be 'inlined'. I argue that the result of doing so makes the resulting program segment quite a lot harder to read and, quoting the 'Zen of Python', "readability counts" :)

It is not a matter of inlining.  Say you want to concatenate s₁,..., sₙ where (for simplicity) all these strings have length k.  If you do as above (((s₁ ^ s₂) ^ s₃) ^ ⋯ ^ sₙ), then you construct a string of length 2k, then 3k,... so in total you allocate 2k + 3k + ⋯ + nk = k · O(n²).  If you use String.concat, then only the final string of length k · n will be allocated.