Partial applicationその4

部分適用は演算子にも使えたんですね。

using System;

def lst = [2, 3, 4];

// 匿名関数
Console.WriteLine (lst.FoldRight (1, fun (x, y) { x + y }));
Console.WriteLine (lst.FoldRight (1, fun (x, y) { x * y }));
// 部分適用で同等の内容
Console.WriteLine (lst.FoldRight (1, _ + _));
Console.WriteLine (lst.FoldRight (1, _ * _));

/* 結果
10
24
10
24
 */

HaskellのサンプルをNemerleに移植してて気づきました。(^^;

(追記) 適応じゃなくて適用だよ・・・寝ぼけているなぁ。