Tuesday 15 April 2014

lisp - Iterate over 2 lists in parallel in CLISP -


I am trying to reinvent the two new lists in two ways, such as:

 < Code> (temp2) (var2 (car temp2)) (temp2 l2 (cdr l2)) (factor 2 temp1) (factor temp2))) ((endp-temp2) 'end-l-1))) < / Code>  

The problem is that I have found an infinite loop in my code and I do not know why your help would be appreciated.

I'm not sure what you are trying to do, but in your code This modification fixes the endless loop:

  (defun test-do * (l1 l2) (* * ((temp1 l1 (cdr temp1)) (var1 (car temp1) (car temp1   

On a one-to-one basis) (temp2 l2 (cd temp2)) (var2 (car temp2)) (car temp2) Consider the details given in your do * loop:

  (temp1 l1 (cdr l1))   

In English Translated (in the context of a do * loop), It means: "This is not what you want, because the value of l1 never changes, and therefore temp1 is identical to every transaction after the first time. Consider this amendment:

  (temp1 l1 (cdr temp1))   

This means: "On the first trip, Set the code> temp1 to the value of l1 . On each subsequent journey, set the temp1 to the value of (cdr temp1) . "In this way, the value of temp1 on each visit depends on the value of temp1 on the last recurrence, and the list of your loop as you want.

No comments:

Post a Comment