Is there a way I can apply '+ to '( 1 2 3)?
有没有办法可以申请'+ to'(1 2 3)?
edit: what i am trying to say is that the function i get will be a symbol. Is there a way to apply that?
编辑:我想说的是我得到的功能将是一个符号。有办法申请吗?
Thanks.
6 个解决方案
#1
(apply (eval '+) '(1 2 3))
Should do it.
应该这样做。
#2
In R5RS you need
在R5RS中你需要
(apply (eval '+ (scheme-report-environment 5)) '(1 2 3))
The "Pretty Big" language in Dr. Scheme allows for:
Dr. Scheme中的“Pretty Big”语言允许:
(apply (eval '+) '(1 2 3))
#3
How about 'apply'? Use the variable + instead of the symbol + .
“申请”怎么样?使用变量+而不是符号+。
(apply + '(1 2 3))
#4
;; This works the same as funcall in Common Lisp:
(define (funcall fun . args)
(apply fun args))
(funcall + 1 2 3 4) => 10
(funcall (lambda (a b) (+ a b) 2 3) => 5
(funcall newline) => *prints newline*
(apply newline) => *ERROR*
(apply newline '()) => *prints newline*
Btw, what's the deal with this "syntax highlighting" ??
顺便问一下,这个“语法高亮”的处理方法是什么?
#5
In Racket's scheme it would be
在Racket的计划中它会是
#lang scheme
(define ns (make-base-namespace))
(apply (eval '+ ns) '(1 2 3))
#6
How about the scheme "apply"
该计划“适用”怎么样
(apply + `(1 2 3)) => 6
I hope that was what you were asking :)
我希望那就是你所要求的:)
#1
(apply (eval '+) '(1 2 3))
Should do it.
应该这样做。
#2
In R5RS you need
在R5RS中你需要
(apply (eval '+ (scheme-report-environment 5)) '(1 2 3))
The "Pretty Big" language in Dr. Scheme allows for:
Dr. Scheme中的“Pretty Big”语言允许:
(apply (eval '+) '(1 2 3))
#3
How about 'apply'? Use the variable + instead of the symbol + .
“申请”怎么样?使用变量+而不是符号+。
(apply + '(1 2 3))
#4
;; This works the same as funcall in Common Lisp:
(define (funcall fun . args)
(apply fun args))
(funcall + 1 2 3 4) => 10
(funcall (lambda (a b) (+ a b) 2 3) => 5
(funcall newline) => *prints newline*
(apply newline) => *ERROR*
(apply newline '()) => *prints newline*
Btw, what's the deal with this "syntax highlighting" ??
顺便问一下,这个“语法高亮”的处理方法是什么?
#5
In Racket's scheme it would be
在Racket的计划中它会是
#lang scheme
(define ns (make-base-namespace))
(apply (eval '+ ns) '(1 2 3))
#6
How about the scheme "apply"
该计划“适用”怎么样
(apply + `(1 2 3)) => 6
I hope that was what you were asking :)
我希望那就是你所要求的:)