On May 28, 2009, at 1:13 PM, Sean Devlin wrote: > 1. collect is the ruby version of map, not reduce. An interesting > use of reduce, though.
For anyone keeping score, inject is Ruby's reduce. And Ruby has map, it's an alias to collect. > This is exactly why I think creating defblockfn is a bad idea. We > already have a perfectly good macro facility in clojure. Let's use > what we've got. I think between the #() reader macro and (fn) we're mostly covered. My 0.02¢. :) On May 28, 2009, at 1:23 PM, CuppoJava wrote: > It's useful in all the cases where a blocks are useful in Ruby. It > simply saves typing out "(fn [])" and IMO makes the code look a little > cleaner. > > eg. > (with_file "myfile.txt" > (write "asdf") > (close)) We've also got with-open already... http://clojure.org/api#toc612 (with-open [file (java.io.FileWriter. "write-test.txt")] (.write file "Hello")) And doto: http://clojure.org/api#toc228 (doto (java.io.FileWriter. "write-test.txt") (.write "Hello") (.close)) And spit, if we're using Contrib: (clojure.contrib.duck-streams/spit "write-test.txt" "Hello") I think if there were a way to combine doto and with-open it would probably do what you want without needing another macro. — Daniel Lyons http://www.storytotell.org -- Tell It! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---