This still seems very verbose to me.  I think it is because the definition 
of "open," "opposite," and "closed" are implicit in the great big blocks of 
arithmetic you are doing.  I think a useful exercise would be to define 
edges in terms of points, and maybe faces in terms of edges and an `face?` 
function.  Then define different properties like `open?` in terms of 
functions on edges.

E.g. if you define a point as a keyword, and an edge as a set of 2 points:

(def o :O)
(def a :A)
(def oa #{o a})
;; ...etc...
(defn connected? [edge-1 edge-2]
  (= 1 (count (set/intersection edge-1 edge-1))))
(defn open? [edge-1 edge-2 edge-3] ...)

Then I think the below function will eventually become something like

(->> edges
     open-triads
     ;; could give inner fn a name, too
     (map (fn [triad] (product (map edge-length triad))))
     sum)

The code as a whole will be more verbose, but it will be a verbosity that 
has evident meaning.

Happy Clojuring,
Leif

On Thursday, July 30, 2015 at 7:59:27 PM UTC-4, kirby urner wrote:
>
>
> Thanks to excellent feedback, I now realize my code was overly verbose, a 
> common phenomenon among beginners in many a computer language.
>
> As an example, the newer version replaces this:
>
>
> ===
>>
>> (ns test-project.synmods)
>>
>> (defn add-open
>>   [edges]
>>   (let [[a b c d e f] edges
>>         [a2 b2 c2 d2 e2 f2] (map (fn [x] (* x x)) edges )]
>>     (do
>>       (reduce + [
>>          (reduce * [f2 a2 b2])
>>          (reduce * [d2 a2 c2])
>>          (reduce * [a2 b2 e2])
>>          (reduce * [c2 b2 d2])
>>          (reduce * [e2 c2 a2])
>>          (reduce * [f2 c2 b2])
>>          (reduce * [e2 d2 a2])
>>          (reduce * [b2 d2 f2])
>>          (reduce * [b2 e2 f2])
>>          (reduce * [d2 e2 c2])
>>          (reduce * [a2 f2 e2])
>>          (reduce * [d2 f2 c2])])
>>       )))
>>
>>
>
>
> ... with this:
>
>
>
>
> (defn add-open
>   [edges]
>   (let [[a b c d e f] edges
>         [a2 b2 c2 d2 e2 f2] (map (fn [x] (* x x)) edges )]
>     (+ (* f2 a2 b2)
>        (* d2 a2 c2)
>        (* a2 b2 e2)
>        (* c2 b2 d2)
>        (* e2 c2 a2)
>        (* f2 c2 b2)
>        (* e2 d2 a2)
>        (* b2 d2 f2)
>        (* b2 e2 f2)
>        (* d2 e2 c2)
>        (* a2 f2 e2)
>        (* d2 f2 c2))
>       ))
>
> Much simpler!  Thank you.  I'll look into testing features.  
>
> In my Python version of the above, I do in fact, invoke the unittest 
> framework.
>
> Kirby
>
>
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to