型レベルプログラミング in Scala(Type-Level Programming in Scala) — Japanese translation of Apocalisp v1.0 documentation
型レベルプログラミング in Scala(Type-Level Programming in Scala) — Japanese translation of Apocalisp v1.0 documentation
scala の parallel collection は、普通の collection を使うように使っているだけで、並列計算の恩恵を受けられる場合も多いのですが、そうではない場合も多いです。 その典型例が、ソートです。実は、並列のソートは、まだ実装されていません。 じゃあ、自分で実装すればいいのか、というと、これは半分正しくて半分間違いです。 どういう事かというと、シングルスレッドの java.util.Arrays.sort がとても高速なので、これより速いソートを自前で実装するのは難しいのです。Arrays.sort が速いのは、単にアルゴリズムだけの問題ではありません。自分で Array の整列処理を書くとすると、当然、配列の要素に添字でアクセスしますよね。すると、JVMは配列の範囲内かどうかをチェックしますよね。このオーバヘッドがあるために、java.util.Arrays.s
秀和システムさんからScalaの本が出ます。発売は多分6月くらいです。 "オープンソース徹底活用"シリーズとして、Scalaをより実践的に使うための色々な事を盛り込みました。タイトルはまだ未定です。 @kmizu, @ryugate ITプランニングさんから(@osiire @keigoi 他)、 監修 @keisuke_n というメンバーと俺で共著という形で執筆しました。 4月末に脱稿して今校正作業中です。自分で言うのもアレですけど、今までのScala本とはまったく異なった面白い内容に仕上がったと自負しています。ITプランニングさんには貴重な経験を提供して頂きましたし、@kmizu や @ryugate は精力的に原稿の取り纏めやスケジュールの管理をしてもらいました。俺はほとんど何もできてないんですが、宣伝くらいはさせてもらおうと思ってコレを書いてます。 どんな内容なの? 最初に断ってお
まだ、loopとかreactとか、その辺りが動くかなーって感じで中途ハンパだけど。 元scalaのコード(http://www.scala-lang.org/node/54から転載) abstract class PingMessage case object Start extends PingMessage case object SendPing extends PingMessage case object Pong extends PingMessage abstract class PongMessage case object Ping extends PongMessage case object Stop extends PongMessage object pingpong extends Application { val pong = new Pong val pi
このエントリはScala Advent Calendar jp 2010 : ATNDの25日のものです。 メリークリスマス! クリスマスは楽しくみんなでパズルを解いて遊びましょう。 パズルみたいな探索問題をScalaで解く場合は、リストモナドを使うとキレイに書けます。 例: SEND+MORE=MONEY 例として覆面算を解いてみましょう。 各アルファベットに異なる数字が割り当てれる。その数字は何か? ただし最上位桁が0ではない。 普通にforループを使って解くと、ネストの深さが酷いことになります:)。 // int(1,2,3)を123にする関数 def int(xs : Int*) : Int = xs.foldLeft(0)( _ * 10 + _) // SEND+MORE=MONEYの答えを探索する def solve : (Int,Int,Int) = { for( s <-
Scala Advent Calendar jp 2010の 12/20 を担当しました。Day 14です。 よろしくお願いします。 色々何か書こうか迷ったけど、traitについて書こうと思います。 scalaのtraitって、インタフェースのようでありながら実装を持てるので、色々便利ですよね。 javaからscalaと移行してきた人にとってtraitとはなんぞや?と思ってしまうので、そのあたりを書いてみようかと思います。 Slateによるtrait まず、traitだけを見ると、scalaのtraitは他の言語のソレと違っています。 例えが悪い(?)ですが、traitを持つSlateという言語(SELF系の言語で、small talkによく似ている言語です) の場合、traitはどちらかというと、メソッドの集合であって、そのtraitを使うことで多重継承等を行うようにできるヤツです
2010-11-03 Debasish Ghosh さん (@debasishg) の “Scala Implicits : Type Classes Here I Come” を翻訳しました. 元記事はこちら: http://debasishg.blogspot.com/2010/06/scala-implicits-type-classes-here-i.html (翻訳の公開は本人より許諾済みです) 翻訳の間違い等があれば遠慮なくご指摘ください. 先日 Twitter 上で Daniel と Scala での型クラスについて論議していると,突然このトピックに関する書きかけだった記事を発見した.これを読んでもあなたは特に目新しい事を発見するわけではないが,型クラスに基づいた思考はあなたの設計の幅に価値を与えることができると思う.この記事を書き始めたのはしばらく前に設計の直交性についての
今日はScalaの例外処理について解説しますよ。 基本 - try,catch,finally 例外処理の基本は、try,catch,finallyです。これはJavaと同じですね。 ただし、Scalaでのtry,catch,finallyは値を生成します。つまり、実行されたブロックの値が評価されます。 scala> val n = try{ "99".toInt } catch { case e:Exception => -99 } n: Int = 99 scala> val n = try{ "foo".toInt } catch { case e:Exception => -99 } n: Int = -99 上記のように、catch節には "case e:Exception => ..."のようなパターンマッチを書くことで、対応する例外の型に応じて補足することができます。try,
Scala に関するいろんな話題が飛び交ってたのでまとめました。時間軸にすると到底把握しきれないので話題ごとに分離してあります。全部に絡んでる @kmizu さんのパワフルさに脱帽です。
SacalaZa #1View more presentations from mzpi. http://scalaza.com/ScalaZa01/で発表してきました。 Ustもあるらしいですが、怖くて確認できていないです。 LTでもないのにScalaとあんまり関係ない話をするとか空気読めてない感じでごめんなさい。 感想 わらびもち! 受け付けしてました。 「弊社にくればScalaのお仕事あります!」っていっている人がそこそこ居て、わくわくしました。 懇親会で何を話したかほとんど記憶にないのですが、id:bleis-tiftさんとかid:a-hisameさんのブログを見る感じだと、いろんな言語の話で盛り上ったり、名古屋ハッカソンの話をしてたっぽいです。名古屋ハッカソンは是非やりましょう。
正式版まではと思っていたけど、RC7まで増えつづけてるのでしびれをきらして試してみる。 環境 Ubuntu 10.04 64bit(ディスクトップ) 試したもの: scala 2.8.0 RC7 Eclipse + scala plugin NetBeans + scala plugin vim 7.2 補完とか色々便利になるIDEは必須かなと思ってまず、試してみた Eclipse すごく不安定。何でだろう。まぁ、補完できないみたいだし、いっか。 NetBeans 補完は出きるみたい。起動もEclipseより軽いなぁ。 でも・・なんか、カーソルキー無視して画面のカーソルが上に登っていく・・・。なんなの? ということで、断念して、 Vim scalaを展開ディレクトリのmisc/scala-tool-support/vim の下のファイルを、~/vimというディレクトリを作ってコピー。 co
Not your computer? Use a private browsing window to sign in. Learn more about using Guest mode
● [Scala] RubyからScalaに乗り換えた15くらいの理由 [注意] この文章を読むと、既存のRubyコードをScalaでrewriteしたくなる、 Rubyコードで型チェックをやるのが鬱になる、Ruby案件でやる気が出なくなる、 などの幻覚や異常行動が報告されています。 現在関わっているプロジェクトや家族のことを常に意識し、 気を強く持って冷静に読むとよいでしょう。 「Scalaプログラミング入門」を読みはじめて、いきなり大きく頷いてしまった。 "コーディング時間の半分をテスト作成に費やさなければならなかった"(p.3) "Railsによって得られた生産性の向上は、テスト作成の作業に失われてしまいました"(p.3) まさにここ数年私が抱いてた漠然としたストレスの正体が、的確に文章となっていたからだ。そしてほどなく、「あ、この機能がRubyに欲しかった!」という驚きと共に Sc
Javaな人から見ると、「Scalaって難しい」ってイメージがありますね。俺も最初はそう思ってました。今もですけど。 で、考えてみたんですが、何が難しいって考え方・イディオムになじみがないのが原因かと思ったんです。 ここでは、俺が今までScalaをやってきて得た考え方を紹介します。「Scalaをちょっとやってみたんだけど、とっつきにくくて…」と思われている方は、ぜひご一読ください。 参考資料: Scala入門 - Scalaで書きはじめたJava使い向け - Scala勉強会@東北 Dropbox - 404 神は言われた。「リストあれ。」 Lisperは、リストをどう作るかをまず考えるらしいです。適切なリストが出来たら、プログラムはもうできたも同然だと。同じ考え方は、Scalaでも通用すると思います。 大まかに、こんな流れで考えてます。(リストは最初から与えられることもあるでしょう) 「
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く