|
From: | Stefan Israelsson Tampe |
Subject: | Re: Potluck time! |
Date: | Sat, 13 Feb 2016 21:32:21 +0100 |
Hey GuilersMy potluk contibution is tp implement attributed variables for minikanren ontop af the source written by William E. Byrd.You can find the source at https://gitlab.com/tampe/attributed-minikanrenThe source containes examples using attributed variables to implement =/= symbolo numbero absento freezeo and whenoAPI(define AttributeId (make-attribute unify-fkn portray-fkn)(unify-fkn var data val lam)var is the varibale that is unified (not yet unified at the execution of this fkn) data is the data associated with AttributedId for variable varand val is the value that var will be unified to and lam is a variable that can be bound to a predicate to be executed after the unification havebeen taken.(portray-fkn var data s)Return a list of representations of attribuete AttributedId with data data for variable var. s is the variable binding stack.(get-attr var id data)Get data associated with attributed id if no attribute exists fail(put-attr var id data)Put attributed data data of kind id to variable var.New Examples(wheno (cons test1 lam1) (cons test2 lam2) u1 u2 ...)If u1 u2 ... is bound then before bounding test1 will by tried with no unification as a result and if success lam2 will be executed else the binding will failthen the variable will be bound and test2 lam2 combo will be tried similarly, the conses can be repaced with #f to indicate a void semantics.(freezeo u lam1 lam2)before the binding of u lam1 will be tried and after the binding of u lam2 will be tried.The rest of the constraints was implemented by other means before and is known please read the documentation by William E. Byrd.RegardsStefan
[Prev in Thread] | Current Thread | [Next in Thread] |