I just began to play with Lisp and I'm trying to use funcall inside cons.
This is what I'm trying to do:
(cons '(1 2 3) '(1 (funcall #'rest '(a b)) ))
The result should be:
((1 2 3) 1 (b))
I know this works:
(cons '(1 2 3) (funcall #'rest '(a b)))
And I tried this already and it didn't work
(cons '(1 2 3) `,'(1 (funcall #'rest '(a b)) ))
(cons '(1 2 3) '(1 (apply 'rest '(a b))))
(cons '(1 2 3) '(1 `,(apply 'rest '(a b))))
Thanks in advance.
When you quote a list, everything is quoted inside the list, so there is no function call. You can achieve what you want like this:
[1]> (cons '(1 2 3) (list 1 (funcall #'rest '(a b)) ))
((1 2 3) 1 (B))
[2]>
(cons '(1 2 3) `(1 ,(funcall #'rest '(a b))))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.