Awesome. +1
On Aug 27, 9:57 pm, Timothy Pratley <timothyprat...@gmail.com> wrote: > > > The only feature I want is the ability to use a regex as a predicate. > > Would automatically forcing the first step to get a nice 'nil' be > >unacceptable? > > Sounds good to me! > This can be quite easily accommodated: > > (defn re-fn > "Construct a regular expression from string. > Calling a regular expression with no arguments returns a Pattern. > Calling a regular expression with a string argument > returns nil if no matches, otherwise the equivalent of (re-seq re > string)." > [string] > (let [pp (re-pattern string)] > (fn re > ([] pp) > ([s] (let [groups (re-seq pp s)] > (if (first groups) > groups > nil)))))) > > user=> ((re-fn "7.") "12324251") > nil > user=> ((re-fn "2.") "12324251") > ("23" "24" "25") > user=> (if ((re-fn "1") "12") :great :bad) > :great > > (And of course a wrapper implementation version could do something > similar). > > 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 -~----------~----~----~----~------~----~------~--~---