Post by IshaanPost by Arseny SlobodyukPost by IshaanHi,
I'm a high school student interested in programming and I need some
help with lisp.
Post by Arseny SlobodyukPost by IshaanI've been trying to learn the basics for the past few days and
everything about it confuses me. I'm ok at javascript and python, but
this really trips me up. I just can't anything to work, and I've never
been so frustrated at a computer. Also how long should it take to be
able to write decent programs in lisp and descendent dialects?
Post by Arseny SlobodyukI recommend "Lisp Notes" https://www.cs.ccu.edu.tw/~dan/lispnotes.txt to
everybody. It never works out but anyway. I think it contains just a
necessary amount to feel the spirit. It is an excerpt from the
D.Touretzky's "A gentle introduction to symbolics computation".
Thanks, I really like the humane voice it's written in!
I have not quite come to the end of those lispnotes.txt.
I wanted to distill a test that I pass to clisp (apparently some
common lisp) that is installed on my ubuntu system.
I have a list of mistakes and inaccuracies attached, with tentative fixes
mostly.
In particular I'd like help with the following numbers that I couldn't
fix myself:
14
17
21 no clue
22
24
25
26
-------------------------------------------------
1 O is used instead of 0
l is used instead if 1
2 d is used instead of e
3. (number 5.0) doesn't give a random float.
(random 5.0) however does
4. /SUM is not known in clisp
5. (last )(a b c . d))
must be
. (last '(a b c . d))
6. (remove 'a) ](b a n a n a))
must be
(remove 'a '(b a n a n a))
7
; fails, commented out
;(give-title '(john peterson))
;(mr john peterson)
8
(assoc 'four quatre)
;(four words)
must be ??
(assoc 'four words)
;(four quatre)
9
; fails, commented out
;(quality-difference 'object2 'object3)
;material
;
10
; fails
;(quality-difference 'object2 'object3)
;material
11
( eq 3 3)
; Error: wrong input type
;
in clisp this results in
;t
12
(funcall fn 'a 'b) a
must be
(funcall fn 'a 'b)
13
(eval ''boing)
;'boing
in clisp this results in
; boing
14
;(eval (eval ''boing))
;boing
in clisp this results in
*** - EVAL: variable BOING has no value
15
(mapcar #'(lambda (n) (* n n)) '(1 2 3 4 5)
must be
(mapcar #'(lambda (n) (* n n)) '(1 2 3 4 5))
16
(mapcar #'(lambda (n) (* 10 n)) '(1 2 3 4 5)
must be
(mapcar #'(lambda (n) (* 10 n)) '(1 2 3 4 5))
17
(lambda (n) (* n 10))
;Error: undefined function lambda
in clisp this is
#<FUNCTION :LAMBDA (N) (* N 10)>
18
(find-if #'oddp ](2 4 6 7 8 9))
must be
(find-if #'oddp '(2 4 6 7 8 9))
19
(reduce #'(lambda (x y)
(+ (* x X) (* y y))))
'(1 2 3))
must be
(reduce #'(lambda (x y)
(+ (* x X) (* y y)))
'(1 2 3))
20
(defun fact (n)
(cond ((zerop n) 1)
(t (* n (fact (- n 1)))))
one closing bracket is missing.
21
(defun my-length (1)
(cond ((null 1) 0)
(t (+ 1 (my-length (cdr 1))))))
meets with error message
*** - DEFUN: Invalid lambda list element 1. A lambda list may only contain
symbols and lists.
22
(defun fib (n)
(+ (fib (- n 1)
(fib - n 2))))
tracin fails with "too many arguments given to FIB"
replaced with
too many arguments given to FIB
23
(find-first-atom '(((a b) c) d)) a
The a is spurious
24
(my-nth 2 '(a b c d e))
fails with error
USE-VALUE :R1 Input a value to be used instead of I.
The problem is probably with:
(defun my-nth (n x) (cond ((zerop n) (car x))
(t (my-nth (- n i) (cdr x)))))
;
25
There is probably an error in
(defun fib (n)
(cond ((equal n 0) 1)
((equal n 1) 1)
(t (+ (fib (- n 1)
(- n 2))))))
because (fib 3 ) gives
*** - EVAL/APPLY: too many arguments given to FIB
26
count-up is not defined in clisp
--
This is the first day of the end of your life.
It may not kill you, but it does make your weaker.
If you can't beat them, too bad.
***@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst