.n

TCO

.n

Scalaって末尾再帰の最適化してるの? - みずぴー日記 をねまーるでまねーる。 def fact(n){ | 0 => 1 | _ => n * fact(n - 1) } fact(1000000)Process is terminated due to StackOverflowException.def fact_i(n){ def loop(m, n){ | (_, 0) => 1 | _ => lo…

qsort

using System; def qsort(a : list[IComparable]){ | [] => [] | _ => def g = n => a.Filter(x => x.CompareTo(a.Head) == n); qsort(g(-1)) + g(0) + qsort(g(1)) } def r = Random(DateTime.Now.Millisecond); Console.Write(qsort($[r.Next()|_ in [0..9…

ねまーる

http://nemerle.org/ 「 class _{static void Main(){}} 」要らず セミコロンで文を区切るが末尾には不要(Pascal・Smalltalk風) using Nemerle.IO; print("Hello, world!") リスト操作・内包表記 簡潔なλ [1,2,3,4,5].Filter(fun(x){x%2>0}).Map(fun(x){x*…