Clearly "board" is a chunked seq in this case. Use doseq when you want side effects for-each of some seqable, but don't care about the return values. The arguments for doseq are identical to those for for, but a) doseq will return nil and b) if the output of for was discarded (rather than the repl realizing the sequence to print the nils) the side effects would never take place, whereas doseq forces them to take place whether or not the nil *it* returns is used or discarded.
On Mon, Nov 25, 2013 at 8:25 AM, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > Hi Edward, > > I believe the return value of your expression is (nil nil nil nil ...), > but the printlns are forced just after the ( is printed. > > Thanks, > Ambrose > > > On Mon, Nov 25, 2013 at 9:14 PM, <edw...@kenworthy.info> wrote: > >> Some (println) weirdness (board is a vector to vectors): >> >> (println (board 0)) >> (println (board 1)) >> (println (board 2)) >> (println (board 3)) >> (println (board 4)) >> (println (board 5)) >> (println (board 6)) >> (println (board 7)) >> >> Works as I would expect, printing to the console. >> >> However: >> >> (for [row board] >> (println row)) >> >> Doesn't: the output from println is part of the result of evaluating the >> for (along with a slew of nils). >> >> ([:empty :empty :empty :empty :empty :empty :empty :empty] >> [:empty :empty :empty :empty :empty :empty :empty :empty] >> [:empty :empty :empty :empty :empty :empty :empty :empty] >> [:empty :empty :empty :white :black :empty :empty :empty] >> [:empty :empty :empty :black :white :empty :empty :empty] >> [:empty :empty :empty :empty :empty :empty :empty :empty] >> [:empty :empty :empty :empty :empty :empty :empty :empty] >> [:empty :empty :empty :empty :empty :empty :empty :empty] >> nil nil nil nil nil nil nil nil) >> >> Any idea why there is any difference at all between the two? The only >> thing I can think of is for's lazy evaluation but I don't see how. >> >> -- >> -- >> 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 >> Note that posts from new members are moderated - please be patient with >> your first post. >> 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 >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > -- > 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 > Note that posts from new members are moderated - please be patient with > your first post. > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- 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 Note that posts from new members are moderated - please be patient with your first post. 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.