small medium large xlarge

Back to: All Forums  PragPub
2d57728_pragsmall
06 Jul 2011, 16:48
Jean-François "Jeff" Héon (7 posts)

A small note on the capitalize-n-stretch function.

Since comp will apply the right-most function first and continues right-to-left, I should have defined it like this:

(def capitalize-n-stretch (comp stretch capitalize))

In that case, our functions are commutative so the result is the same, but, for example, a reverse-n-capitalize function would return different results depending on ‘comp’ function argument order.

((comp capitalize reverse) “abcd”) >”Dcba”

((comp reverse capitalize) “abcd”) >”dcbA”

You must be logged in to comment