Hi Dave,

Another option is to use the 
for<http://clojuredocs.org/clojure_core/clojure.core/for>macro's while clause 
to stop processing as soon as you hit an error.

Here's a basic example with a simple my-func that returns a string-based 
error to give you an idea of how it could look:

(defn my-func [n]
  (cond
   (< n 4) (str n)
   :else "error"))

(for [n [1 2 3 4 5]
      :let [result (my-func n)]
      :while (not= result "error")]
  result)

Cheers,
James

On Sunday, November 24, 2013 5:19:49 PM UTC+1, David Simmons wrote:
>
> Hi All.
>
> Still struggling to get my head around Clojure - this is attempt number 4.
>
> I wish to process each item in a vector. I know I can use map to do this 
> e.g. (map my-func my-vector). My problem is that I need to be able to break 
> out of the map if my-func returns an error when processing any of the 
> items. I know map isn't what I'm looking for but is there a function or 
> some idiomatic piece of clojure to achieve my aim.
>
> cheers
>
> Dave
>
>

-- 
-- 
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.

Reply via email to