Here is my solution...
(defnu succ [n n+1]
([0 1])
([1 2])
([2 3])
([3 4])
([4 5])
([5 6])
([6 7])
([7 8])
([8 9])
([9 10]))
(defn pred [n n-1]
(succ n-1 n))
(defnu lengtho [l n]
([[] 0])
([[_ . ?rst] _] (fresh [n1]
(lengtho ?rst n1)
(succ n1 n)))))
Obviously the above code is not right or efficient and is very limited in
range. I am sure there should be a better solution..
Thanks,
Sunil.
On Sat, Oct 8, 2011 at 1:20 PM, Sunil S Nandihalli <
[email protected]> 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 [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