On Mon, Aug 12, 2013 at 4:03 PM, Mark <markaddle...@gmail.com> wrote:

>
> At run level 6, I get all the permutations of [1 2 3], just as expected.
> However, at 7, the program does not terminate and I'd like to understand
> why.  I feel like I need to constrain the relation between o-h and o better
> but I'm not sure what else to say about it.
>

Looking at this, it's clear that this will never terminate.  Your recursion
is unbounded on the rembero.  When you get to rembero, your l and o-h are
both always fresh.  (rembero :anyting (lvar) (lvar)) will produce an
infinite set of results.

After you've generated all your 6 results, remberallo will of course fail
on everything rembero produces, but you've got nothing that stops rembero.

Now, consider putting the remberallo BEFORE the rembero:

(defne remberallo [s l o]
  ([() l l])
  ([[h . r] _ _]
     (fresh [o-h]
            (remberallo r o-h o)
            (rembero h l o-h))))

Now, imagine you are on a final remberallo call where h is some number and
r is the empty list.  The recursive remberallo will will only produce one
answer, unifying o-h and o.  Now o-h is no longer fresh and your rembero
will have enough information to terminate.

-- 
-- 
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/groups/opt_out.


Reply via email to