最近、こういう理由で(?)Scalaがアツイと僕の周りの人が騒いでいたので僕もその流れに乗ってみました。

周りがMacばっかりなので、Gentooにインストールしてみたいと思います。

Scalaをインストール

まず、このような操作をしてみました。

   1  # emerge scala -pv
   2  
   3  These are the packages that would be merged, in order:
   4  
   5  Calculating dependencies... done!
   6  
   7  !!! All ebuilds that could satisfy "dev-lang/scala" have been masked.
   8  !!! One of the following masked packages is required to complete your request:
   9  - dev-lang/scala-2.7.5 (masked by: ~x86 keyword)
  10  - dev-lang/scala-2.7.4-r1 (masked by: ~x86 keyword)
  11  - dev-lang/scala-2.7.4 (masked by: ~x86 keyword)
  12  - dev-lang/scala-2.7.3-r1 (masked by: ~x86 keyword)
  13  - dev-lang/scala-2.7.3 (masked by: ~x86 keyword)
  14  - dev-lang/scala-2.7.2 (masked by: ~x86 keyword)

maskedパッケージでした。

なので、ACCEPT_KEYWORDS="~x86"とします。

   1  # ACCEPT_KEYWORDS="~x86" emerge scala

これでOKかと思いきや、scalaのコンパイルでエラーという悲しい状況になりました。

Gentooではソースからコンパイルする以外にバイナリをインストールすることが可能なので、そちらで試してみます。

   1  # USE="binary" ACCEPT_KEYWORDS="~x86" emerge scala 

これでscalaのバイナリがインストールされます。

ScalaでHello, World!

インストールが済んだら、早速使ってみましょう。まず、インタラクティブシェルを立ち上げます。

   1  $ scala
   2  Welcome to Scala version 2.7.5.r0-b20090605191508 (Java HotSpot(TM) Client VM, Java 1.6.0_13).
   3  Type in expressions to have them evaluated.
   4  Type :help for more information.
   5  
   6  scala> 

よくわからず、書いてみました

   1  scala> object HelloWorld {
   2       |     def main( arg : Array[String] ) = {
   3       |         println("Hello, World!")
   4       |     }
   5       | }                               
   6  defined module HelloWorld
   7  
   8  scala> HelloWorld.main(null)
   9  Hello, World!

真面目に勉強するなら、Scala By Example(英語/PDF)とかを読むと良いのかも知れません。

とりあえず、今回はこれだけで。

面白そうなのは、ScalaのコードをAndroidで動かすとかですかね。

Android携帯ほしい><

posted by Png y_tsuda on Mon 6 Jul 2009 at 07:10

RGB値と三刺激値(tristimulus values)XYZの相互変換を行う方法のメモ。

   1  def xyz2rgb(x, y, z)
   2    r =  3.240479 * x - 1.53715  * y - 0.498535 * z;
   3    g = -0.969256 * x + 1.875991 * y + 0.041556 * z;
   4    b =  0.055648 * x - 0.204043 * y + 1.057311 * z;
   5    [r, g, b]
   6  end
   7  
   8  def rgb2xyz(r, g, b)
   9    x = 0.412453 * r + 0.35758  * g + 0.180423 * b;
  10    y = 0.212671 * r + 0.71516  * g + 0.072169 * b;
  11    z = 0.019334 * r + 0.119193 * g + 0.950227 * b;
  12    [x, y, z]
  13  end

posted by Png genki on Mon 6 Jul 2009 at 03:44
Contents
GentooにScalaをインストールしてみた
RGBとXYZの相互変換
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ