Scala
みんな大好きScalaですが、immutableなPriorityQueueが標準で無かったので試しに作ってみました。想定バージョンはScala 2.7.7です。Immutable PriorityQueue in Scala — Gist データ構造 今回は優先順位つきキューの実装に、Leftist Heapというヒープを使い…
静的型付け教 const教 クロージャ教 メソッドチェイン教 まとめ: JavaとC++とRubyの影響
#!/usr/bin/scala !# { println((0 to 999 toList).filter(s => (s%3==0 || s%5==0)).foldLeft(0)((a,b)=>a+b)) } { def f(x:Int,y:Int,s:Int):Int = if (x <= 4000000) f(y,x+y,x*(1-x%2) + s) else s println(f(1,2,0)) } { def f(n:Long,x:Long):Long = i…