Reputation: 4655
According to this document: http://cl-cookbook.sourceforge.net/functions.html
(defun adder (n)
(lambda (x) (+ x n)))
(funcall (adder 12) 1)
I have to use funcall to call (adder 12), And it is very ignoring to write funcall over and over, is there any way to write code like it in scheme:
((adder 12) 1)
Upvotes: 2
Views: 356
Reputation:
However, you could use something like this (not sure why would you, but the number of characters typed would be the same as it is in Scheme):
(set-macro-character
#\[
#'(lambda (stream char)
(declare (ignore char))
(set-syntax-from-char #\] #\;)
(let ((forms (read-delimited-list #\] stream t)))
(set-syntax-from-char #\] #\x)
(append '(funcall) forms))))
(defun adder (n)
#'(lambda (x) (+ x n)))
(format t "sum: ~s~&" [(adder 12) #x128]) ;; 308
This may give you some problems if you will encounter a variable name with brackets in it. Sure, using it is up to you, consider yourself warned.
Upvotes: 1
Reputation: 139261
No. There is none.
You can also see it as a feature: it makes calls of function objects explicit and improves understandability of source code.
Upvotes: 6