illegal parameter type in function set : 1

Started by dukester, August 17, 2007, 10:11:18 AM

Previous topic - Next topic

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...
duke

HPW

#1
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

#2
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:


(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...



http://artfulcode.net\">Artful code

cormullion

#3
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

#4
Quote from: "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:


(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!
duke

dukester

#5
Quote from: "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!


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.....
duke