Your projecting last-val which is unbound. Once projected you have a value not a logic var.
David On Saturday, October 8, 2011, Sunil S Nandihalli <sunil.nandiha...@gmail.com> wrote: > Thanks Ambrose. that fixed it .. I tried the following along the same lines but didn't work.. can you suggest as to how I can do it? > (defn nlasto [l last-val] > (project [l last-val] > (== last-val (last l)))) > (run* [q] (nlasto [1 2 3 4 5] q)) > I do know how to do it in pure relational thing.. I just wanted to try the non-relational version > Sunil. > On Sat, Oct 8, 2011 at 6:38 PM, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: >> >> Hi Sunil, >> Use the non-relational goal "project" to get the value of a lvar. >> The "is" operator in Prolog does similar things AFAIK. >> Untested: >> (defnu lengtho [l n] >> ([[] 0]) >> ([[_ . rst] _] (fresh [n1] >> (lengtho rst n1) >> (project [n n1] >> (== n (+ n1 1))))) >> Thanks, >> Ambrose >> On Sat, Oct 8, 2011 at 3:50 PM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: >>> >>> Hi everybody, >>> I was just trying to implement a simple length of a list in core.logic (basically solving the 99-problems-in-prolog). I am not able to find a way to increment values.. Can somebody help me with this... I would like some thing like the following to work.. >>> (defnu lengtho [l n] >>> ([[] 0]) >>> ([[_ . rst] _] (fresh [n1] >>> (lengtho rst n1) >>> (== n (+ n1 1)))) >>> but I can't do "(== n (+ n1 1))" can somebody help me? Even if you tell me as to how I can covert the regular count function so that I can use it as a goal.. that would work too. >>> Thanks, >>> Sunil. >>> >>> -- >>> 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 < clojure%2bunsubscr...@googlegroups.com> >>> For more options, visit this group at >>> http://groups.google.com/group/clojure?hl=en < http://groups.google.com/group/clojure?hl=en> >> >> -- >> 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 < clojure%2bunsubscr...@googlegroups.com> >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en < http://groups.google.com/group/clojure?hl=en> > > -- > 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 < clojure%2bunsubscr...@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 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