Hi Edmund,

Thanks for your interest.  There's actually no way to fill in ??? in your 
example, because it's a requirement of Graph that node names must be 
unique, and distinct from top-level input keys.  This ensures that the 
Graph has a unique topological order, and it's always clear where the input 
to a node comes from.  So we can't both treat :a as an input and an output. 
 (Of course, we could always wrap the graph function to merge the inputs 
in, but it still won't quite fit your example)

Here are three ways to do something similar:

;; As a single fnk that returns an explicit map
user> ((eager-compile {:a2 (fnk [[:a1 b]] {:b b :c (inc b)})}) 
       {:a1 {:b 1}})
{:a2 {:b 1, :c 2}}

;; As a single fnk that modifies the input map
user> ((eager-compile {:a2 (fnk [[:a1 b :as a1]] (assoc a1 :c (inc b)))}) 
       {:a1 {:b 1}})
{:a2 {:c 2, :b 1}}

;; As a hierarchical graph
user> ((eager-compile {:a2 {:b (fnk [[:a1 b]] b) 
                            :c (fnk [[:a1 b]] (inc b))}}) 
       {:a1 {:b 1}})
{:a2 {:b 1, :c 2}}

Note that these all take input key :a1 and output :a2, to avoid a key 
clash, and explicitly copy :b to the output.  If you give me some more 
details about your use case I may be able to provide better advice.

Hope this helps -- let me know if you have any questions.

Cheers,
Jason

On Thursday, February 7, 2013 1:55:13 AM UTC-8, Edmund wrote:
>
> Hey Aria / Jason,
>
>   Thanks for OSing this library, its really useful.  One question: how do 
> you deal with nesting on the output side of graph declaration ?  I 
> understand it for fnk, but but how would I achieve:
>
> {:a {:b 1}} -> {:a {:b 1, :c 2}}
>
> with a single declaration:
>
> (graph/eager-compile
>  {??? (fnk [[:a b]] (inc b))}
>
> where ??? is the binding form I'm after to describe the nesting ?  
>
> I'm currently doing this by breaking up my map and using update-in, but it 
> seems you must have a sneaky trick to do this declaratively ?
>
> I figure [:a :c] would be an possible syntax ?
>
> Thanks again,
>
>  Edmund
> On Tuesday, 29 January 2013 18:46:54 UTC, Aria Haghighi wrote:
>>
>> Hey all,
>>
>>  Prismatic has open-sourced our Plumbing and Graph library on 
>> github<https://github.com/prismatic/plumbing>. 
>> Jason Wolfe gave a 
>> talk<http://blog.getprismatic.com/blog/2012/10/1/prismatics-graph-at-strange-loop.html>about
>>  how we use graph for systems composition at Strange loop last year. 
>> Please give the library
>> a whirl and let us know if you're using it and if you find any issues or 
>> feature requests. We use this library very heavily throughout our code and 
>> hope others find it useful as well.
>>
>>  Best, Aria
>>
>

-- 
-- 
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/groups/opt_out.


Reply via email to