newLISP Fan Club

Forum => Anything else we might add? => Topic started by: dukester on August 17, 2007, 10:11:18 AM

Title: illegal parameter type in function set : 1
Post by: dukester on August 17, 2007, 10:11:18 AM
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...
Title:
Post by: HPW on August 17, 2007, 11:00:15 AM
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) )
Title:
Post by: Jeff on August 17, 2007, 11:00:32 AM
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
Title:
Post by: cormullion on August 17, 2007, 11:08:16 AM
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!
Title:
Post by: dukester on August 17, 2007, 11:30:48 AM
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!
Title:
Post by: dukester on August 17, 2007, 11:34:19 AM
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.....