From: konane
Subject: Works on LispWorks but not  on CLISP
Date: 
Message-ID: <1137592811.518493.236130@g47g2000cwa.googlegroups.com>
This function works just fine using LispWorks but i get an error
message saying:
(cross 3 4)

** - Continuable Error
EVAL: la función Z no está definida
Si continúa (tecleando `continue'): Reintentar
The following restarts are also available:
STORE-VALUE    :R1      You may input a new value for (FDEFINITION 'Z).
USE-VALUE      :R2      You may input a value to be used instead of
(FDEFINITION 'Z).

Which means that function Z is not defined, but Z is no function. Is
it? Any ideas?

(defun cross (x y)
(setf cruz nil)
(dotimes (z tam)
	(if (and (= (mod (+ z y) 2) 0) (not(= z y)))
	   (setf cruz (cons (list x z) cruz))
	)
)
(dotimes (z tam)
	(if (and (= (mod (+ z x) 2) 0) (not(= z x)))
	   (setf cruz (cons (list z y) cruz))
	)	
)
)

Thanx in advance.

From: Eric Lavigne
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <1137596917.417795.170480@g47g2000cwa.googlegroups.com>
> Which means that function Z is not defined, but Z is no function. Is
> it? Any ideas?

I am also using CLisp, but it told me that variable "tam" was not
defined. I don't understand the error about z, but I agree that "tam"
seems to come out of nowhere.


> (setf cruz nil)

This statement changes the value of cruz to nil. As far as I can tell,
cruz didn't exist before this line, so changing it doesn't make sense.

If you want to create a new variable that is used only in this
function, you should use "let" instead of "setf".

If you want to define a variable that is used in many places in your
program, you should use "defvar" (or "defparameter" if that variable
will never be changed). In this case you should give the variable a
name that makes it obvious that it is a global variable. The convention
is to use asterisks like this:

(defvar *cruz* nil)


>            (setf cruz (cons (list z y) cruz))
>         )
> )
> )

Hanging parentheses is considered appropriate in the C++ community
(brackets in their case), but this is considered strange among Lisp
programmers. Try writing it like this:

(setf cruz (cons (list z y) cruz)))))

> (defun cross (x y)
> (setf cruz nil)

There should be some indenting here to show that the second line is a
statement that is part of the cross function definition:

(defun cross (x y)
     (setf cruz nil)

What is the purpose of your cross function? Maybe I can show you an
easier way to do this.

Eric
From: konane
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <1137598341.064495.189160@g49g2000cwa.googlegroups.com>
That fuction is called from another place. tam is defined somewhere
else and it is the size of a board, 8 is the default value. Im doing a
konane game, and this funcion returns  the places a certain piece can
move. For example in a 8x8 (which is really from 0 to 7) board i would
call (cross 3 4) and get something like ((3 0)(3 2)(3 6)(1 4) (5 4) (7
4)). Thats how it works with LispWorks.

I also tried cl:dotimes but didnt work.

It keeps saying z is a function :(
From: Geoffrey Summerhayes
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <3_vzf.13822$xk1.350187@news20.bellglobal.com>
"konane" <·········@gmail.com> wrote in message 
·····························@g49g2000cwa.googlegroups.com...
> That fuction is called from another place. tam is defined somewhere
> else and it is the size of a board, 8 is the default value. Im doing a
> konane game, and this funcion returns  the places a certain piece can
> move. For example in a 8x8 (which is really from 0 to 7) board i would
> call (cross 3 4) and get something like ((3 0)(3 2)(3 6)(1 4) (5 4) (7
> 4)). Thats how it works with LispWorks.
>

Changed it from altering a global to
returning the list of moves, and replaced
a few things...

(defparameter *tam* 8)

(defun cross (x y)
  (let ((cruz '()))
    (dotimes (z *tam*)
      (when (and (evenp (+ z y)) (/= z y))
        (push (list x z) cruz)))
    (dotimes (z *tam*)
      (when (and (evenp (+ z x)) (/= z x))
        (push (list z y) cruz)))
    cruz))

---
Geoff
From: konane
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <1137616122.046508.104100@g47g2000cwa.googlegroups.com>
That version looks much nicer.
And the problem with the parenthesis is that unless i do that i get
lost with so many of them. In small funcions maybe is not that hard,
but big ones can be a pain in the ass if you forgot a parenthesis, and
its easier to see where if, lets, loops,... begin and end. But i guess
ill have to get used to lisp indenting.

Thanks all for your help.

PS:Had i known you people were so helpful i wouldve asked you to code
the konane game for me ;)
From: Eric Lavigne
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <1137617988.812922.242990@z14g2000cwz.googlegroups.com>
> That version looks much nicer.
> And the problem with the parenthesis is that unless i do that i get
> lost with so many of them. In small funcions maybe is not that hard,
> but big ones can be a pain in the ass if you forgot a parenthesis, and
> its easier to see where if, lets, loops,... begin and end. But i guess
> ill have to get used to lisp indenting.
>

Sounds like your editor is broken. Any decent Lisp editor, when you
place the cursor over one of the parentheses, will highlight its match.
Figuring out where statements begin and end should never require
counting parentheses.

Any decent Lisp editor will also automatically indent your code for
you, so you don't need to learn all the indenting rules yourself.

Some items in the "any decent Lisp editor" line of products:
Allegro IDE
     http://franz.com/downloads/trial.lhtml
LispWorks IDE
     http://www.lispworks.com/downloads/index.html
LispInABox (emacs w/slime)
     http://common-lisp.net/project/lispbox/
From: Peter Seibel
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <m2slrbim1h.fsf@gigamonkeys.com>
"Eric Lavigne" <············@gmail.com> writes:

>> That version looks much nicer.
>> And the problem with the parenthesis is that unless i do that i get
>> lost with so many of them. In small funcions maybe is not that hard,
>> but big ones can be a pain in the ass if you forgot a parenthesis, and
>> its easier to see where if, lets, loops,... begin and end. But i guess
>> ill have to get used to lisp indenting.
>>
>
> Sounds like your editor is broken. Any decent Lisp editor, when you
> place the cursor over one of the parentheses, will highlight its match.
> Figuring out where statements begin and end should never require
> counting parentheses.
>
> Any decent Lisp editor will also automatically indent your code for
> you, so you don't need to learn all the indenting rules yourself.

> LispInABox (emacs w/slime)
>      http://common-lisp.net/project/lispbox/

This project has, as far as I know, not been updated in a year or two.
You might want to check out my Lispbox (which was inspired by that
project and also the OS X version originally written by Mikel Evins):

  <http://www.gigamonkeys.com/lispbox/>

-Peter


-- 
Peter Seibel           * ·····@gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/
From: Geoffrey Summerhayes
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <1oRzf.8216$924.200968@news20.bellglobal.com>
"konane" <·········@gmail.com> wrote in message 
·····························@g47g2000cwa.googlegroups.com...
>
> PS:Had i known you people were so helpful i wouldve asked you to code
> the konane game for me ;)

Looked kind of interesting, so I already started coding. :)
The only problem is the lack of consistency in the rulesets
I've come across.

An 8x8 board should be completely solvable with the
application of a modest(sic) amount of computer power.
The state space is only 2^64 and a game must end within
64 plies, maximum number of moves on a ply, what ...
around 70?

--
Geoff
From: David Sletten
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <6Bvzf.990$eV4.893@tornado.socal.rr.com>
konane wrote:

> That fuction is called from another place. tam is defined somewhere
> else and it is the size of a board, 8 is the default value. Im doing a
> konane game, and this funcion returns  the places a certain piece can
> move. For example in a 8x8 (which is really from 0 to 7) board i would
> call (cross 3 4) and get something like ((3 0)(3 2)(3 6)(1 4) (5 4) (7
> 4)). Thats how it works with LispWorks.
> 
> I also tried cl:dotimes but didnt work.
> 
> It keeps saying z is a function :(
> 

There's something you're not telling us if DOTIMES isn't working... 
Can't help you there.

But you can make the logic clearer by using some built-in Lisp functions 
(or defining your own if what you need doesn't exist).

(if (and (= (mod (+ z y) 2) 0) (not(= z y)))
	   (setf cruz (cons (list x z) cruz))
	)

Becomes

(when (and (evenp (+ z y)) (/= z y))
   (push (list x z) cruz))

Using WHEN also makes it clear that there is no "else" clause side 
effect to your IF expression.

Aloha,
David Sletten
From: Thomas A. Russ
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <ymilkxdgv0o.fsf@sevak.isi.edu>
David Sletten <·····@slytobias.com> writes:

> konane wrote:
> > I also tried cl:dotimes but didnt work.
> > 
> > It keeps saying z is a function :(
> > 
> 
> There's something you're not telling us if DOTIMES isn't working... 
> Can't help you there.

Yes, that's pretty fundamental.  And it would also explain why the
original error message referred to Z not being a function.

To the original poster:  
What version of CLISP are you using?

-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: ···············@yahoo.com
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <1137607839.586398.313120@g44g2000cwa.googlegroups.com>
Also, you can write
(setf cruz (cons xxx cruz))
as
(push xxx cruz)
From: R. Mattes
Subject: Re: Works on LispWorks but not  on CLISP
Date: 
Message-ID: <pan.2006.01.18.14.57.19.957266@mh-freiburg.de>
On Wed, 18 Jan 2006 06:00:11 -0800, konane wrote:

> This function works just fine using LispWorks but i get an error
> message saying:
> (cross 3 4)
> 
> ** - Continuable Error
> EVAL: la funci�n Z no est� definida
> Si contin�a (tecleando `continue'): Reintentar
> The following restarts are also available:
> STORE-VALUE    :R1      You may input a new value for (FDEFINITION 'Z).
> USE-VALUE      :R2      You may input a value to be used instead of
> (FDEFINITION 'Z).
> 
> Which means that function Z is not defined, but Z is no function. Is
> it? Any ideas?
> 
> (defun cross (x y)
> (setf cruz nil)
> (dotimes (z tam)
> 	(if (and (= (mod (+ z y) 2) 0) (not(= z y)))
> 	   (setf cruz (cons (list x z) cruz))
> 	)
> )
> (dotimes (z tam)
> 	(if (and (= (mod (+ z x) 2) 0) (not(= z x)))
> 	   (setf cruz (cons (list z y) cruz))
> 	)	
> )
> )

This pretty much looks like 'dotimes' isn't treated/recognized
as a macro. Does your code work if you write 'cl:dotimes' instead
of just 'dotimes'.

 HTH Ralf Mattes

> 
> Thanx in advance.
From: Pascal Bourguignon
Subject: Re: Works on LispWorks but not  on CLISP
Date: 
Message-ID: <87psmpr0p9.fsf@thalassa.informatimago.com>
"konane" <·········@gmail.com> writes:

> This function works just fine using LispWorks but i get an error
> message saying:
> (cross 3 4)
>
> ** - Continuable Error
> EVAL: la funci�n Z no est� definida
> Si contin�a (tecleando `continue'): Reintentar
> The following restarts are also available:
> STORE-VALUE    :R1      You may input a new value for (FDEFINITION 'Z).
> USE-VALUE      :R2      You may input a value to be used instead of
> (FDEFINITION 'Z).
>
> Which means that function Z is not defined, but Z is no function. Is
> it? Any ideas?
>
> (defun cross (x y)
> (setf cruz nil)
> (dotimes (z tam)
> 	(if (and (= (mod (+ z y) 2) 0) (not(= z y)))
> 	   (setf cruz (cons (list x z) cruz))
> 	)
> )
> (dotimes (z tam)
> 	(if (and (= (mod (+ z x) 2) 0) (not(= z x)))
> 	   (setf cruz (cons (list z y) cruz))
> 	)	
> )
> )
>
> Thanx in advance.

Try to indent it correctly, and it'll work even in CLISP:

[303]>(defparameter cruz nil)
CRUZ
[304]>(defparameter tam 5)
TMA
[305]> (defun cross (x y)
        (setf cruz nil)
        (dotimes (z tam)
          (if (and (= (mod (+ z y) 2) 0) (not(= z y)))
              (setf cruz (cons (list x z) cruz))))
        (dotimes (z tam)
          (if (and (= (mod (+ z x) 2) 0) (not(= z x)))
              (setf cruz (cons (list z y) cruz)))))
CROSS
[306]> (cross 3 4)
NIL
[307]> cruz
((1 4) (3 2) (3 0))
[308]> 

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

This universe shipped by weight, not volume.  Some expansion may have
occurred during shipment.
From: konane
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <1137601813.672197.88970@g49g2000cwa.googlegroups.com>
Thanx a lot. it works now.
From: Sam Steingold
Subject: Re: Works on LispWorks but not  on CLISP
Date: 
Message-ID: <uacdth4as.fsf@gnu.org>
> * Pascal Bourguignon <····@zbhfr-cbgngb.pbz> [2006-01-18 16:54:26 +0100]:
>
> "konane" <·········@gmail.com> writes:
>
>> This function works just fine using LispWorks but i get an error
>> message saying:
>> (cross 3 4)
>>
>> ** - Continuable Error
>> EVAL: la función Z no está definida
>> Si continúa (tecleando `continue'): Reintentar
>> The following restarts are also available:
>> STORE-VALUE    :R1      You may input a new value for (FDEFINITION 'Z).
>> USE-VALUE      :R2      You may input a value to be used instead of
>> (FDEFINITION 'Z).
>>
>> Which means that function Z is not defined, but Z is no function. Is
>> it? Any ideas?
>>
>> (defun cross (x y)
>> (setf cruz nil)
>> (dotimes (z tam)
>> 	(if (and (= (mod (+ z y) 2) 0) (not(= z y)))
>> 	   (setf cruz (cons (list x z) cruz))
>> 	)
>> )
>> (dotimes (z tam)
>> 	(if (and (= (mod (+ z x) 2) 0) (not(= z x)))
>> 	   (setf cruz (cons (list z y) cruz))
>> 	)	
>> )
>> )
>>
>> Thanx in advance.
>
> Try to indent it correctly, and it'll work even in CLISP:

I am confused.
how can indentation change code/data processing by a CL reader?


-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
http://www.mideasttruth.com http://pmw.org.il http://www.camera.org
http://www.iris.org.il http://www.honestreporting.com http://ffii.org
I don't want to be young again, I just don't want to get any older.
From: ···············@yahoo.com
Subject: Re: Works on LispWorks but not on CLISP
Date: 
Message-ID: <1137607744.804889.246590@z14g2000cwz.googlegroups.com>
Maybe the problem is with converting the error messages to Spanish.  It
could be a misplaced ~A in the format string in the Spanish file.
Maybe 'tam' wasn't defined in some context, and Lisp tried to say so,
but said that z wasn't defined instead.  All this is speculative.
From: Barry Margolin
Subject: Re: Works on LispWorks but not  on CLISP
Date: 
Message-ID: <barmar-4D15D7.21190618012006@comcast.dca.giganews.com>
In article <·············@gnu.org>, Sam Steingold <···@gnu.org> wrote:

> > Try to indent it correctly, and it'll work even in CLISP:
> 
> I am confused.
> how can indentation change code/data processing by a CL reader?

By helping the CL *writer* code it properly before handing it off to the 
CL reader.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Pascal Bourguignon
Subject: Re: Works on LispWorks but not  on CLISP
Date: 
Message-ID: <87d5ipqnzj.fsf@thalassa.informatimago.com>
Sam Steingold <···@gnu.org> writes:

>> * Pascal Bourguignon <····@zbhfr-cbgngb.pbz> [2006-01-18 16:54:26 +0100]:
>>
>> "konane" <·········@gmail.com> writes:
>>
>>> This function works just fine using LispWorks but i get an error
>>> message saying:
>>> (cross 3 4)
>>>
>>> ** - Continuable Error
>>> EVAL: la funci�n Z no est� definida
>>> Si contin�a (tecleando `continue'): Reintentar
>>> The following restarts are also available:
>>> STORE-VALUE    :R1      You may input a new value for (FDEFINITION 'Z).
>>> USE-VALUE      :R2      You may input a value to be used instead of
>>> (FDEFINITION 'Z).
>>>
>>> Which means that function Z is not defined, but Z is no function. Is
>>> it? Any ideas?
>>>
>>> (defun cross (x y)
>>> (setf cruz nil)
>>> (dotimes (z tam)
>>> 	(if (and (= (mod (+ z y) 2) 0) (not(= z y)))
>>> 	   (setf cruz (cons (list x z) cruz))
>>> 	)
>>> )
>>> (dotimes (z tam)
>>> 	(if (and (= (mod (+ z x) 2) 0) (not(= z x)))
>>> 	   (setf cruz (cons (list z y) cruz))
>>> 	)	
>>> )
>>> )
>>>
>>> Thanx in advance.
>>
>> Try to indent it correctly, and it'll work even in CLISP:
>
> I am confused.
> how can indentation change code/data processing by a CL reader?

Ssshh!  Have them indent correctly first! ;-)




But my bet is that it's a badly placed C-x C-e.

If you type C-x C-e at the end of the line (dotimes (z tam), you get
this error message.

(dotimes (z tam)
	(if (and (= (mod (+ z x) 2) 0) (not(= z x)))
 	   (setf cruz (cons (list z y) cruz))
 	)	

When you have emacs re-indent your code, your cursor ends at the end
of the form and C-x C-e works better.




Anyways, even with the Spanish language I get the same good results:

;; Loading file /home/pjb/.clisprc.lisp ...
;; Reading ASDF packages from /home/pjb/asdf-central-registry.data...
; loading system definition from /usr/local/share/lisp/packages/net/sourceforge/cclan/asdf-install/asdf-install.asd into #<PACKAGE ASDF3925>
; registering #<SYSTEM ASDF-INSTALL #x2046F7BE> as ASDF-INSTALL
0 errores, 0 advertencias
[1]> (defun cross (x y)
        (setf cruz nil)
        (dotimes (z tam)
          (if (and (= (mod (+ z y) 2) 0) (not(= z y)))
              (setf cruz (cons (list x z) cruz))))
        (dotimes (z tam)
          (if (and (= (mod (+ z x) 2) 0) (not(= z x)))
              (setf cruz (cons (list z y) cruz)))))
CROSS
[2]> (cross 3 4)

*** - EVAL: la variable TAM no tiene ning�n valor
Es posible continuar en los siguientes puntos:
USE-VALUE      :R1      You may input a value to be used instead of TAM.
STORE-VALUE    :R2      You may input a new value for TAM.
ABORT          :R3      ABORT
Break 1 [3]> :q
[4]> (defparameter tam 5)
TAM
[5]> (cross 3 4)
NIL
[6]> (z tam)

*** - EVAL: la funci�n Z no est� definida
Es posible continuar en los siguientes puntos:
USE-VALUE      :R1      You may input a value to be used instead of (FDEFINITION 'Z).
RETRY          :R2      Reintentar
STORE-VALUE    :R3      You may input a new value for (FDEFINITION 'Z).
ABORT          :R4      ABORT
Break 1 [7]> 

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"A TRUE Klingon warrior does not comment his code!"