illegal parameter type in function set : 1

For the Compleat Fan
Locked
dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

illegal parameter type in function set : 1

Post by dukester »

Hi...

I cannot get the following example to work:

(set 'data (1 1 2 2 2 2 2 2 2 3 2 4 4 4 4) )
(unique data)
(println data)

I keep on getting the subject error -- yet the example is out of "Introduction to newLISP" - except for the (println .. ) line.
What am I missing? TIA...

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Try:

(set 'data '(1 1 2 2 2 2 2 2 2 3 2 4 4 4 4) )

Or:

(set 'data (list 1 1 2 2 2 2 2 2 2 3 2 4 4 4 4) )
Hans-Peter

Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Post by Jeff »

You need to quote the list you are assigning to 'data. The interpreter always assumes the first atom in a list is a function to be applied to the rest of the elements in the list unless the list is quoted:

Code: Select all

(set 'data (1 2 3)) ; => tries to set data to the value of applying function 1 to values 2 and 3
(set 'data '(1 2 3)) ; => sets data to a list containing values 1 2 3
(set 'data (list 1 2 3)) ; => same as previous
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

oops - yes there were some apostrophe problems and I see that I hadn't caught all of them...

Also - you seem to be going through this very carefully, and I'm not sure that it's been that thoroughly 'road-tested' before (It's notoriously difficult for a writer to test their own work as comprehensively as others can). You're doing a great service as a 'tester', even though it must be frustrating to encounter typos that stop you in your tracks.

but thanks for finding and reporting the problems!

dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

Post by dukester »

Jeff wrote:You need to quote the list you are assigning to 'data. The interpreter always assumes the first atom in a list is a function to be applied to the rest of the elements in the list unless the list is quoted:

Code: Select all

(set 'data (1 2 3)) ; => tries to set data to the value of applying function 1 to values 2 and 3
(set 'data '(1 2 3)) ; => sets data to a list containing values 1 2 3
(set 'data (list 1 2 3)) ; => same as previous
Got it! I should have been able to rationalize it out myself. I've got to get used to newLISP and cormullion's "3 Rules of LISP"! Thanks again!

dukester
Posts: 115
Joined: Tue May 08, 2007 1:06 pm
Location: Alberta, Canada

Post by dukester »

cormullion wrote:oops - yes there were some apostrophe problems and I see that I hadn't caught all of them...

Also - you seem to be going through this very carefully, and I'm not sure that it's been that thoroughly 'road-tested' before (It's notoriously difficult for a writer to test their own work as comprehensively as others can). You're doing a great service as a 'tester', even though it must be frustrating to encounter typos that stop you in your tracks.

but thanks for finding and reporting the problems!
No worries! Believe me when I say that I'm not fault-finding -- I'm simply working through the examples and getting acquainted with newLISP. In the process, I'm fine-tuning my HTML version of your excellent tutorial. I'll be sending you an update soon. Thanks. L8r.....

Locked