« Beyond 'Conway's Law' | Main | The Urge to REPL, the Urge to Test »

April 10, 2011



I can't help but reply with Ruby's puts ',' + @method_names*',' where the map and reduce are replaced by Ruby's join (*',')?

Simon Harris

FWIW, something such as @method_names.map(&:name).join(",") would be slightly more idiomatic Ruby.

Stefan Tilkov

'intersperse' sounds exactly like Clojure's 'interpose'

Peter Harkins

Simon: name is not a method, this code is as simple as ",#{@method_names.join(',')}\n".

I guess I'm trying to solve the combination of printing, iterating, and formatting by just using the appropriate String code to do all of it.

(Side node, the two examples in the blogs do different things; the second lacks the trailing newline.)

Michael Feathers

Sheesh.. try to use a simple example of a general idea :) Simon: example made the switch from print to puts so the newline is covered.


Michael: Map/reduce, and FP in general, works well in the micro. But in the macro, I still prefer objects. Here's my Haskell translation: (map (\x -> x++",") xs) |> foldr (++) ""


Didn't know that reduce and inject were synonyms. But of course they are. I think Bil's example is interesting and didn't know that join and * were the same thing for strings. Not sure it's a good idea that they are, because it's really obscure. I'd rather use join anyway, because it does what it says on the tin, * implies some kind of array product.

Thanks for introducing me to reduce, it's much easier to understand as 'reduce' even though it's the same method.

Karen millen

Ferragamo outlet online store has wonderful accessories. Salvatore ferragamo handbags and ferragamo sunglasses are hot sale over the world.

iPhone contacts backup

will this method a good way to solve this.

The comments to this entry are closed.