On Feb 1, 12:16 am, Meikel Brandmeyer <[email protected]> wrote: > Hi, > > Am 01.02.2009 um 03:26 schrieb Onorio Catenacci: > > > (defn init-sheet > > #^{:doc "Initialize a worksheet with a particular month"} > > ([current-month] > > (if debugging (println "In init-sheet")) > > ) > > ) > > You don't need #^ to attach the docstring. In fact your version > attaches the docstring to the following list, not to the Var. > Another note: for functions with only one argument vector you > don't need the enclosing (). > > (defn init-sheet > "Initialise a worksheet with a particular month" > [current-month] > ...) > > > ;For my own reference--this is an example of a Clojure sequence > > comprehension > > (for [current-month [months]] > > (let [current-sheet (init-sheet current-month)]) > > ) > > Yes. for is a list comprehension and not a looping construct. > And as others pointed out: for is lazy. When you really need > looping for side-effects look for doseq. If you also need the > results look for dorun or doall. >
Thanks everyone. I figured I was missing something fairly obvious but I'm just learning the language (and FP concepts) so I was somewhat confused. Doseq and doall (for . . . are indeed the answers I was looking for. I should have stripped out some of those comments--they are in there for my own benefit. As I build more code and I can't remember how something is done, I can search the comments for "sequence comprehension" and find an example from my own code. Helps me to get more familiar with the language and not have pester others. :-) Thanks again for the help everyone. -- Onorio Catenacci III --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
