“@”在方案语言中是什么意思?
what is '@' means in scheme language?
我正在尝试理解以下函数:
((lambda 'b
((lambda 'a '''''a) 'b `(this)))
(lambda (x)
(lambda (z)
`(,x ,@z)))
(car ''unquote))
输出是:
(quote quote quote quote quote this)
我正在尝试理解'@z'
的意思,有人知道吗?
'
是 syntax-sugar for quote
`
是 quasiquote
的语法糖
,
是 unquote
的语法糖
,@
是 unquote-splicing
的语法糖
看这个简单的例子:
`(1 ,(+ 1 1) ,@(list 3 4)) ;==> (1 2 3 4)
你可以这样重写,你会得到相同的结果:
(quasiquote (1 (unquote (+ 1 1)) (unquote-splicing (list 3 4)))) ;==> (1 2 3 4)
https://www.cs.rpi.edu/academics/courses/fall00/ai/scheme/reference/schintro-v14/schintro_129.html
https://docs.racket-lang.org/reference/quasiquote.html
https://courses.cs.washington.edu/courses/cse341/04wi/lectures/14-scheme-quote.html
我正在尝试理解以下函数:
((lambda 'b
((lambda 'a '''''a) 'b `(this)))
(lambda (x)
(lambda (z)
`(,x ,@z)))
(car ''unquote))
输出是:
(quote quote quote quote quote this)
我正在尝试理解'@z'
的意思,有人知道吗?
'
是 syntax-sugar for quote
`
是 quasiquote
的语法糖
,
是 unquote
的语法糖
,@
是 unquote-splicing
的语法糖
看这个简单的例子:
`(1 ,(+ 1 1) ,@(list 3 4)) ;==> (1 2 3 4)
你可以这样重写,你会得到相同的结果:
(quasiquote (1 (unquote (+ 1 1)) (unquote-splicing (list 3 4)))) ;==> (1 2 3 4)
https://www.cs.rpi.edu/academics/courses/fall00/ai/scheme/reference/schintro-v14/schintro_129.html
https://docs.racket-lang.org/reference/quasiquote.html
https://courses.cs.washington.edu/courses/cse341/04wi/lectures/14-scheme-quote.html