This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

just a basic for beginner.

2 posts · 4210 views

(defun op(n)
	(nth (mod n 3) '(+ - *))
)
(defun pre-op(n)
	(nth (mod n 4) '(sqrt sin log))
)
(defun const(n)
	(nth (mod n 11) '(0.1 1 2 3 4 5 6 7 8 9))
)
(defun main()
	((op 0) 3 2)
)
(main)
how do I make it become (+ 3 2)

Re: just a basic for beginner.

You use *defun* and that implies Common Lisp. Common Lisp is a LISP2 and it has separate namespace for everything in operator position and argument/variable position. To be able to use a function returned from a function or passed as argument you need to use *funcall*
(defun main()
   (funcall (op 0) 3 2))
Good luck
Br,
Syl
I'm the author of two useless languages that uses BF as target machine.
Currently I'm planning a Scheme compiler :p