Thanks Chouser, Happy new year!
sun On Jan 1, 12:37 am, Chouser <chou...@gmail.com> wrote: > On Wed, Dec 31, 2008 at 11:41 PM, wubbie <sunj...@gmail.com> wrote: > > > Hi all, > > > what's the new syntax for this? > > It is part of the code below which was translation by Stu. > > That's a nifty little function. This just fixes the syntax: > > (defn plot [f min max step] > (doseq [i (range min max step)] > (dotimes [_ (apply f [i])] (print "*")) > (println))) > > But we can add features and tightens up the implementation a bit: > > (defn plot [f & range-args] > (doseq [i (apply range range-args)] > (println (apply str (replicate (f i) "*"))))) > > This gets rid of the distracting _ and the extra 'println', and also > allows us to use the optional args for 'range': > > (plot #(* % %) 8) > > --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---