Re: matching, assigning and branching in one form

2013-06-24 Thread Gary Johnson
The condp form is very nice and concise if you have multiple match clauses. If you are more generally just looking to perform a single match/assign/branch task, I'd recommend this little nugget of clojure wisdom: Forget ye not the hidden might of if-let. (if-let [[_ from to message] (re-find

Re: matching, assigning and branching in one form

2013-06-23 Thread dmirylenka
or even without let: (condp re-find msg #^:(.*?)!.*PRIVMSG (.*) :(.*) : (fn [[_ from to message]] (true-form ...)) (false-form...)) On Saturday, June 22, 2013 11:26:35 PM UTC+12, Vincent wrote: What about using condp? (condp re-find msg #^:(.*?)!.*PRIVMSG (.*) :(.*) : #(let [[_ from to

Re: matching, assigning and branching in one form

2013-06-22 Thread Vincent
What about using condp? (condp re-find msg #^:(.*?)!.*PRIVMSG (.*) :(.*) : #(let [[_ from to message] %] (logic...))) Vincent On Friday, 21 June 2013 17:43:50 UTC+2, Steven Arnold wrote: Hi, I am writing a simple IRC bot, pretty much just for fun, starting with a simple implementation

matching, assigning and branching in one form

2013-06-21 Thread Steven D. Arnold
Hi, I am writing a simple IRC bot, pretty much just for fun, starting with a simple implementation originally posted by Nurullah Akkaya on his blog. It already does what it's supposed to, which is message a fortune from mod-fortune (shelling out) when someone asks it to. However, there's a

Re: matching, assigning and branching in one form

2013-06-21 Thread David Nolen
Not a specific answer to your question, but it would be cool to see someone make the core.match regex facilities handle this. (match [msg] [(#^:(.*?)!.*PRIVMSG (.*) :(.*) : [from to message])] ... true form ... :else ... false form ..) David On Fri, Jun 21, 2013 at 11:43 AM, Steven D.