亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 3760 | 回復(fù): 3
打印 上一主題 下一主題

( (lambda x x) 2 3 4 5) [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2009-01-25 22:23 |只看該作者 |倒序?yàn)g覽
scheme
lambda 的syntax  是: (lambda  (formals) (body) )

( (lambda x x) 2 3 4 5)  什么意思。
這里 第一個(gè)x 是 形參? 第二個(gè)x 是 body ?  2 3 4 5  其實(shí)是一個(gè) 傳遞給它的 實(shí)參列表 ' (2 3 4 5) ??

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2009-01-25 22:40 |只看該作者
可以參考 “The Scheme Programming Language" 的 2.5 [點(diǎn)這里]

相關(guān)的是這一段:

As mentioned above, the general form for lambda is a bit more complicated than the form we saw earlier, in that the formal parameter specification, (var ...), need not be a proper list, or indeed even a list at all. The formal parameter specification can be in any of the following three forms.

    * a proper list of variables, (var1 ... varn), such as we have already seen,

    * a single variable, varr, or

    * an improper list of variables, (var1 ... varn . varr).

In the first case, exactly n actual parameters must be supplied, and each variable is bound to the corresponding actual parameter. In the second, any number of actual parameters is valid; all of the actual parameters are put into a single list and the single variable is bound to this list. The third case is a hybrid of the first two cases. At least n actual parameters must be supplied. The variables var1 ... varn are bound to the corresponding actual parameters, and the variable varr is bound to a list containing the remaining actual parameters. In the second and third cases, varr is sometimes referred to as a "rest" parameter because it holds the rest of the actual parameters beyond those that are individually named.

[ 本帖最后由 win_hate 于 2009-1-25 22:42 編輯 ]

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2009-01-26 00:04 |只看該作者

回復(fù) #1 pigjj 的帖子

(lambda x x) 表示:
這是個(gè)匿名函數(shù), 參數(shù)列表為x, 函數(shù)體只有一個(gè)表達(dá)式, 就是返回參數(shù)列表x.
(lambda (x) x)表示:
這個(gè)函數(shù)的參數(shù)列表是(x), 這里x表示它的第一個(gè)參數(shù).

無(wú)論如何, lambda表達(dá)式的第二個(gè)元素是它的參數(shù)列表.

再看
(lambda (x . y) y) 表示:
這個(gè)函數(shù)的參數(shù)列表是(x . y), x是第一個(gè)參數(shù), y表示余下參數(shù)組成的列表.

評(píng)分

參與人數(shù) 1可用積分 +10 收起 理由
win_hate + 10 新春首貼,送紅包。

查看全部評(píng)分

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2009-02-27 01:01 |只看該作者
原帖由 pigjj 于 2009-1-25 22:23 發(fā)表
scheme
lambda 的syntax  是: (lambda  (formals) (body) )

( (lambda x x) 2 3 4 5)  什么意思?
這里 第一個(gè)x 是 形參? 第二個(gè)x 是 body ?  2 3 4 5  其實(shí)是一個(gè) 傳遞給它的 實(shí)參列表 ' (2 3 4 5 ...


你理解得很正確,第一個(gè)就是形參,第二個(gè)是body。
如果你不敢確認(rèn)后面的2 3 4 5不是list,那分開(kāi)調(diào)用可以看得清楚些:
(define fun
(lambda x
x))    ;什么都不做,直接返回傳入值
執(zhí)行(fun 2 3 4 5),結(jié)果
'(2 3 4 5)

(lambda x x)這樣的寫(xiě)法容易引起混亂,比較規(guī)矩的寫(xiě)法還是把參數(shù)列表括起來(lái),這樣:
(lambda (x) x)就不會(huì)引起混淆了。
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP