Lisp HUG Maillist Archive

error by correct function definitions

Hi,

I am new in LW. Former I used GCM. I don’t understand: some function definitions I can’t evaluate in the Editor – I get a error message: “The variable L1 is unbound.” though the definition is correct. In the Listener Window the same function definition has been evaluated. What is the matter?

Example:

 

(DEFUN MY-MERGE (L1 L2)

(COND ((NULL L1) L2)

      ((NULL L2) L1)

      ((< (CAR L1) (CAR L2)) (CONS (CAR L1) (MY-MERGE (CDR L1) L2)))

      (T (CONS (CAR L2) (MY-MERGE L1 (CDR L2))))))

 

Thanks

 

Boris

 

Re: error by correct function definitions

"Prof. Dr. B. Stiefel" <b.stiefel@fh-sm.de> writes:

> Hi,
>
> I am new in LW. Former I used GCM. I don’t understand: some function
> definitions I can’t evaluate in the Editor – I get a error message:
> “The variable L1 is unbound.” though the definition is correct. In
> the Listener Window the same function definition has been evaluated.
> What is the matter?
>
> Example:
>

(DEFUN MY-MERGE (L1 L2)
  (COND ((NULL L1) L2)
        ((NULL L2) L1)
        ((< (CAR L1) (CAR L2))
         (CONS (CAR L1) (MY-MERGE (CDR L1) L2)))
        (T
         (CONS (CAR L2) (MY-MERGE L1 (CDR L2))))))

Yes, this function is correct.

Perhaps you're using L1 elsewhere?


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: error by correct function definitions

While the code is correct the indentation is not.  Depending on what
exactly you tried it could have happened that the IDE thought you
wanted to evaluate the form starting with "(COND" instead of the whole
DEFUN form.

Cheers,
Edi.




On Fri, Nov 27, 2015 at 9:17 AM, Prof. Dr. B. Stiefel
<b.stiefel@fh-sm.de> wrote:
> Hi,
>
> I am new in LW. Former I used GCM. I don’t understand: some function
> definitions I can’t evaluate in the Editor – I get a error message: “The
> variable L1 is unbound.” though the definition is correct. In the Listener
> Window the same function definition has been evaluated. What is the matter?
>
> Example:
>
>
>
> (DEFUN MY-MERGE (L1 L2)
>
> (COND ((NULL L1) L2)
>
>       ((NULL L2) L1)
>
>       ((< (CAR L1) (CAR L2)) (CONS (CAR L1) (MY-MERGE (CDR L1) L2)))
>
>       (T (CONS (CAR L2) (MY-MERGE L1 (CDR L2))))))
>
>
>
> Thanks
>
>
>
> Boris
>
>

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Updated at: 2020-12-10 08:32 UTC