Re: How can I remove this "nil?" check from my code?

2015-05-25 Thread Chris Freeman
It seems like, if you don't mind doing the assoc all the time, you could replace the whole if with something like: (assoc nu (:winner c) (or ((:winner c) nu) {:history [{}]})) You might want to wrap that in a let so you don't repeat (:winner c). Also, it looks like add-placeholder-to-history cou

Re: Is this the right way to prevent repetitive code

2015-02-28 Thread Chris Freeman
You can pass your functions around directly; you don't need to wrap them in #(). That will get rid of most of the rest of the duplication you've got. (def search-fields [ ["Search Quotes (Case Independent)" show-search-quotes] ["Search Quotes Not (Case Independ

Re: channels operations

2015-01-10 Thread Chris Freeman
You might want to put it into a loop, keeping the 'played' values as the loop bindings. (I imagine [false false] in my head, but whatever is meaningful to you.) If the timer dings, you evaluate the winner. If you get a value on a player channel and the other player HAS played, you might recur wit

Re: core.async go-loop questions

2014-12-21 Thread Chris Freeman
On Dec 21, 2014 7:17 AM, "Jonathon McKitrick" wrote: > Well, my goal is to start a go-loop (if possible) at the root level of the > code that simply parks and waits for a group of emails to be sent. When > that happens, it would wake up and broadcast the result of the send > operation via web so

Re: core.async go-loop questions

2014-12-20 Thread Chris Freeman
I'm a little uncertain exactly what your code is trying to do, but I believe you're trying to notify a bunch of connections after your speaker notification emails are sent. In which case, I'd do something like this: (defn send-notifications [] (try (mailer/send-speaker-confirmation-notifica

Re: more colloquial "do x n times"

2014-12-04 Thread Chris Freeman
Sam, I'm not an expert, but I think making `co-occurrences` recursive is slightly simpler. Something like: (defn co-occurrences [db ht depth tags] (if (zero? depth) > tags > (recur db ht (dec depth) (co-ocs db ht tags You'll note that I'm not reducing into tags on the last line.