Kelker Ryan's solution isn't quite what you asked for (you asked for a function that takes a vector and returns an iterator, whereas his version stores the vector in a global var), but it can easily be adapted to what you wanted:
(defn make-blah [v] (let [a (atom v)] (fn [] (let [x (first @a)] (swap! a rest) x)))) That's the general approach to creating a function that needs its own internal state. However, in this case, since what you want is an iterator, why not just use Java interop? (defn make-blah [^Iterable v] (let [i (.iterator v)] (fn [] (when (.hasNext i) (.next i))))) => (def blah (make-blah [1 2 3])) #'mark.scratch/blah => (blah) 1 => (blah) 2 => (blah) 3 => (blah) nil -- -- 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.