I'd just use a cond to flatten a nested if. That's usually all you need,
imo.
On Thu, Sep 5, 2013 at 1:07 PM, Bruno Kim Medeiros Cesar
brunokim...@gmail.com wrote:
Thanks for your suggestion, didn't know about that! One of the things that
made someone say that Clojure looks like a language
;; Better yet...
(if (or (and (multi? graph) (not= 2 (count edge)))
(and (looped? graph) (not (distinct? edge
graph
(let [e (if (directed? edge) (vec edge) (set edge))]
(update-in graph [:edges] conj e
On Thu, Sep 5, 2013 at 2:22 PM, Alex Baranosky
Thanks for your suggestion, didn't know about that! One of the things that
made someone say that Clojure looks like a language from the near future.
However, I'm having a hard time using it with its full power. Could you
recommend any other resource, besides the overview page on github, to
Thanks, Alex, I was going down an over-engineering rabbit hole. Your
solution just lacks a not before multi? and looped?.
On Thursday, September 5, 2013 6:24:13 PM UTC-3, Alex Baranosky wrote:
;; Better yet...
(if (or (and (multi? graph) (not= 2 (count edge)))
(and (looped? graph)
I'm writing (another) basic graph library, and would like to treat inputs
depending on the type of the graph. A graph can be
- Directed, in which case edges are vectors. Otherwise, edges are sets;
- Looped, allowing edges from a node to itself;
- Pseudo (or multi), allowing multiples
You could use pattern matching with core.match
On 05/09/2013 6:57 AM, Bruno Kim Medeiros Cesar brunokim...@gmail.com
wrote:
I'm writing (another) basic graph library, and would like to treat inputs
depending on the type of the graph. A graph can be
- Directed, in which case edges are