Scheme 过程表达式 lambda

 

过程表达式
语法: (lambda  <formals> <body> )
语法中 <formals> 需要满足以下描述的正规参数列表, <body> 是一个或多个表达式序列。
guile> (lambda (x) (+ x x))
#<procedure #f (x)>
guile> ((lambda (x) (+ x x)) 4)
8
 
guile> (define reverse-subtract
  (lambda (x y) (- y x)))
guile> (reverse-subtract 7 10)   
3
 
guile> (define add4
  (let ((x 4))
    (lambda (y) (+ x y))))
guile> (add4 6)
10
 
<formals> 需要满足以下形式:
(<variable 1 > ...)
<variable>
(<variable 1 ...   <variable n .  <variable n +1 >)
 
 
guile> ((lambda (x y . z) z)
 3 4 5 6) 
(5 6)
guile> ((lambda x x) 3 4 5 6) 
(3 4 5 6)
 
 
> (define (fx1 x) (display x))
> (fx1 "this is input")
this is input$14 = "this is input"
 
> (define fx2 (lambda (x) (display x)))
> (fx2 "this is input")
this is input$16 = "this is input"
 
> (define-method (fx3 x) (display x))
> (fx3 "this is input")
this is input$18 = "this is input"
 
 
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值