> Granted, this wouldn't work for anything that gets passed to Java, but
> the following gist would be a start.
> http://gist.github.com/176032

You already have a getPattern method for those cases. Which suggests
another solution:

(defn re-fn
  "Uses ss to construct a java.util.Pattern.
  Returns a function which returns the Pattern if called with no
arguments,
  and calls re-seq if called with a string argument."
  [ss]
  (let [pp (re-pattern ss)]
    (fn re
      ([] pp)
      ([s] (re-seq pp s)))))

user=> ((re-fn "2.") "12324251")
("23" "24" "25")
user=> ((re-fn "2."))
#"2."

 If #"X" created a (re-fn "X") then all the re functions could accept
a function and call it in order to avoid having to do (re-find (pp)
s). The previous signature could be retained so that they would work
with either type of arguments if that were desirable. The downside is
trying to explain that in the docs might be confusing - so a wrapper
seems more obvious for that.

Oh - it seems like re-seq does the most work so perhaps that is the
best candidate?


Regards,
Tim.

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

Reply via email to