Well, FYI I've figured out you just need to project the variables you
want. Sorry for double-posting.

However I've got no idea about how optimum this is. So please don't
hesitate if you think about any more clever way to use functions in
core.logic :-)

胡軒

```clojure
(let [depart-state  {:a {:a 1      :c 4} ;; b2 missing
                     :b {:a 2 :b 3 :c 6}
                     :c 3}
      arrival-state {:a {:a 1 :b 2 :c 4}
                     :b {:a 2 :b 3 :c 6}
                     :c 3}
      modifier (fn [basic x y value]
                 (assoc-in basic [x y] value))]
  (run* [_1 _2 _3]
    (membero _1 [:a :b])
    (membero _2 [:a :b])
    (membero _3 (range 4))
    (project [_1 _2 _3]
             (clojure.core.logic/== arrival-state
                                    (modifier depart-state _1 _2 _3)))))
```

On 27/01/2016, 良ϖ <p.de.bois...@gmail.com> wrote:
> Hi everybody,
>
> I have defined a plain Clojure function which has a specific logic
> inside. It outputs a mutated state given an initial state and some
> other arguments. Basically, we could say it is like: (defn modifier
> [basic x y value] (assoc-in basic [x y] value))
>
> I want core.logic to deal with it in order to find the correct
> parameters for this function to output the result I want. Do I have to
> rewrite it as defne or defnc? methinks it would be a burden (just try
> to express assoc-in in pure logic) >< so I'd like to find another way.
> Maybe I could use the (for ) list comprehension but I feel like
> core.logic has a more clever approach.
>
> I have a gist with minimal working code sample here:
> https://gist.github.com/piotr-yuxuan/fa0cfdc63a26b667c3f3
>
> Will appreciate any help I would be given! :-) Thanks a lot in advance!
>
> 胡雨軒
>

-- 
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