Just answering myself found i should bind with choice as it is done in
reifyg
(defn export [out vs gs]
(fn [a]
(let [a' (bind a gs)
as (take* (bind a' (fn [s]
*(choice (walk* s vs)*
* empty-f)*)))]
(bind a (== out as)))))
On Tuesday, January 3, 2017 at 4:14:20 PM UTC-3, Paulo César Cuneo wrote:
>
> I was hacking around with core.logic, trying to implement a "bind var in
> sub process".
>
> So that this this succeeds:
> (run [q]
> (fresh[a]
> (runsub [q] ;; will "export 'q" or "bind 'q in
> caller context"
> [(== a 1) (== q 1)]) ;; 'a will be bound only inside this
> context
> (lvaro a))) ;; 'a is not bind in caller context
> (1)
>
> I didn't want to do term replacement, so i figure i could run goals an
> return the original substitution.
> (fn[a]
> (let[ a' (take* (reduce bind a goals))]
> (magic-happens q a' a) ;; generate an mplus binding lvar q with a'
> values inside a.
> )
>
> Anyway :D haha.
>
> I found that, take* throws an exception because
>
> > (let [x (lvar)
> as (tramp (-> empty-s
> ((conde [(== x 1)]
> [(== x 2)]))))
> ls (take* as)]
> ls)
> (#object[clojure.core.logic.Substitutions 0x7c509c4b "{<lvar:28932>
> 1}"]*AbstractMethodError
> clojure.lang.RT.seqFrom (RT.java:533)*
> >
>
> It happens because :
> (deftype Substitutions
> ....
> ITake
> (take* [ this ] this) ;; why not seqable?
>
> Seems easy to fix, but i bet there be code depending on return not being a
> seqable.
> (take* [ this ] [this])
>
> Bye.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.