型推論
id:kuripさんのところより
http://d.hatena.ne.jp/kurip/20060606#c
List.ConvertAll<U>(delegate {...});
コイツが上手く推論してくれないため、型パラメータを明示的に指定することを要求されます。Nemerleだと型推論が頑張るので、
using System; using System; using System.Collections.Generic; def arr = array ["", "aaa", "bbb", "", "", "ccc", ""]; def arrList = List(arr); def decoratedList = arrList.ConvertAll (s => "/* " + s + " */"); decoratedList.ForEach (s => Console.WriteLine (s));
nCr
http://d.hatena.ne.jp/Ozy/20060603#p2より
Nemerleで挑戦してみました。
using Nemerle.IO; mutable n,r; def c(){ scanf("%d %d",n,r); match*1; c() } } c()
改行、空白削っても147B・・・勝負になりません。(^^;
(追記)
matchをやめてメモ帳で保存して131B。viだと最後に改行が追加されるのを忘れてました(笑)。
using Nemerle.IO; mutable n,r; def c(){ scanf("%d %d",n,r); when(n|r!=0){ printf("%d\n",$[1..r].FoldLeft(1,(i,a)=>a*(n-i+1)/i));c() } } c()
*1:n,r) ){ |(0,0)=>() |_=>printf("%d\n",$[1..r].FoldLeft(1,(i,a)=>a*(n-i+1)/i
LINQ対応
ついにSystem.Query.dllが使えるようになりました。
using System; using System.Collections.Generic; using System.Query; def nums = $ [0 .. 10]; def q = nums .Where (x => x % 2 == 0) .OrderByDescending (x => x) .Select (x => x) : IEnumerable [int]; foreach (x in q) Console.WriteLine (x); /* 結果 10 8 6 4 2 0 */
カタコトの英語でメールしまくってゴメンなさい。(^^;>Nemerleの中の人。