On Thu, Oct 9, 2008 at 10:57 AM, CuppoJava <[EMAIL PROTECTED]> wrote: > > Hi, I'm trying to wrap my head around functional programming, and I'm > having some trouble doing the following: > > Here's a small iterator function that I wrote, which calls a function > on each element of a vector-of-vectors. > > (defn v2d-each > ([v2d stRow endRow stCol endCol func] > (doseq r (range (max 0 stRow) (min (v2d :rows) endRow)) > (doseq c (range (max 0 stCol) (min (v2d :cols) endCol)) > (func r c (v2d-get v2d r c)))))
This function doesn't return anything useful, which mean you must be relying on side-effects of "func". If you're sure you need to be using side effects, there are ways to exit early using loop/recur, take-while, and for, to name some options. But it may be worth taking a step back, first, to see if you can think of what new value you're trying to compute rather than thinking about iterating and changing data. --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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---