Scala

JavaMail

import java.util.Properties import java.security.Security import javax.mail.URLName import javax.mail.Session import javax.mail.Store import javax.mail.Folder import javax.mail.search.FlagTerm import javax.mail.Flags import javax.mail.Mess…

PowerPointのスライドに対し、索引を作成する(2)

import scala.xml.XML import scala.xml.Elem import scala.io.Source // 索引を付けるPPTファイルから抽出したxml // <Slides> // <Slide> // <SlideNumber value=""> // <SlideBody></SlideBody> // </Slide> // </Slides> val f = new java.io.File("d:\\tmp\\text.pptx.x…

VBAでの単純な変換関数を生成する

こんなプログラムを作って、VBを自分で書く量を減らそうとしている。 def conv(funcName:String, params:List[(String,String)]): String = { val cases = params.map(p => s"""| Case "${p._1}" | result = "${p._2}" """.stripMargin).mkString val functi…

Multiplication table of Tetrahedral group

正四面体群の乗積表を手作業で作るのは、私には無理だった・・・https://gist.github.com/kencoba/6093972 id tl tm tn a1 a2 b1 b2 c1 c2 d1 d2 ------------------------------------- id| id tl tm tn a1 a2 b1 b2 c1 c2 d1 d2 tl| tl id tn tm c1 d2 d1 …

transformation between Excel column name and column number.

def toNum(col:String):Int = { def alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def char2num(c:Char):Int = alpha.indexOf(c) + 1 def digit(n:Int): Stream[Int] = Stream.cons(n,digit(n*26)) val nums = col.reverse.map(char2num) val zipped = nums.zip(di…

AstahCastle

AstahとC#の間の連携がショボい。C#のソースコードをインポートする、非サポートのAstahプラグインがあるけど、 「Doxygen使います」とか、コメントのインポートに対応してなかったりとか。悲しい。C#コードからヘルプファイル(.CHMなど)を生成するツールと…

redmine-scala-api

https://github.com/taskadapter/ ってところに、redmine-java-apiというのがある。規模的に、Scalaの練習にちょうど良いのでコンバートしている。https://github.com/kencoba/redmine-scala-api

Functional Programming Principles in Scala

https://www.coursera.org/course/progfun次回は2013/3/25開始。

年俸1000万の会社の試験問題

Scalaで。 selection関数の参考にさせていただいたサイトを失念・・・。 /** 4種類のアルファベット "A,C,G,T" から成るn文字の文字列のうち、"AAG"とい う並びが含まれる文字列を全て列挙するプログラムを書きなさい。ただし、nは 3以上の整数とし、文字列…

GoF Design Patterns in Scala - structural patterns

Adapter pattern https://gist.github.com/1875764Bridge pattern https://gist.github.com/1875758Composite pattern https://gist.github.com/1875890Decorator pattern https://gist.github.com/1875983

GoF Design Patterns in Scala - creational patterns

Singleton pattern https://gist.github.com/1874937Prototype pattern https://gist.github.com/1874918FactoryMethod pattern https://gist.github.com/1874123AbstractFactory pattern https://gist.github.com/1873880Builder pattern https://gist.gith…

Singleton pattern

https://gist.github.com/1874937これは敢えて言うまでもないScalaの機能のはず。

Prototype pattern

https://gist.github.com/1874918これもサンプルがあった。 http://d.hatena.ne.jp/nanjakkun/20100807/1281139973

FactoryMethod pattern

https://gist.github.com/1874123すばらしいお手本がありました。 http://blog.designrecipe.jp/2011/01/03/factory-method-strategy/

Builder pattern

https://gist.github.com/1874015これのJava版をそのままScalaにコピー、しようとしたのだが・・・ http://en.wikipedia.org/wiki/Builder_pattern PizzaBuilderとPizzaが相互参照してるので、 scalaプロンプト上では:loadできないですな。 しかたないのでab…

AbstractFactory pattern

https://gist.github.com/1873880これのJava版をそのままScalaにコピーした。 http://en.wikipedia.org/wiki/Abstract_factory_pattern

Enumeration.iterator

Enumerationのサンプルに WeekDay.iterator filter isWorkingDay foreach println とあるが、Enumeration.iteratorはdeprecated。values.iteratorを使う。 object Main extends Application { object WeekDay extends Enumeration { type WeekDay = Value va…

Scalaプログラミング入門リスト2-1 Sum.scala

val lines = input.getLines.collect は2.8では使えない。 import scala.io._ def toInt(in:String):Option[Int] = try { Some(Integer.parseInt(in.trim)) } catch { case e: NumberFormatException => None } def sum(in:Seq[String]) = { val ints = in.f…

GAE/Scala

GAE/Scalaを本気で調査しようかな。 単にWebアプリを作りたいだけならGAEの方が楽だ。id:hidemon:20091016:1255668728 id:hidemon:20100110:1263124777すでに先行してる人いるし。

第4回Scala言語仕様輪読会

3/3 19:00より豆蔵大会議室にて開きます。 http://atnd.org/events/3161

A Tiny Lisp in Scala

OKIソフトウェア。 http://www.okisoft.co.jp/esc/scala-lisp/ Step by Step Scalaでソースコードを読む勉強に使えそう。