This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArrayOps[A](val self: Array[A]) extends AnyVal { | |
def apply[I: ArrayIdx](i: I) = self(i.idx) | |
} | |
trait ToArrayOps { | |
implicit def ToArrayOps[A](array: Array[A]) = new ArrayOps[A](array) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playground - noun: a place where people can play | |
func fizzBuzz1(i: Int) -> String { | |
switch (i % 5, i % 3) { | |
case (0, 0): | |
return "FuzzBuzz" | |
case (0, _): | |
return "Buzz" | |
case (_, 0): | |
return "Fizz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class Regex { | |
let internalExpression: NSRegularExpression | |
let pattern: String | |
init(_ pattern: String) { | |
self.pattern = pattern | |
var error: NSError? | |
self.internalExpression = NSRegularExpression(pattern: pattern, options: nil, error: &error)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.softantenna.com/wp/software/5-programming-problems/ | |
object Prob { | |
def p1(list: List[Int]) = { | |
def addRec(list: List[Int], acc: Int): Int = list match { | |
case Nil => acc | |
case x :: xs => addRec(xs, acc + x) | |
} | |
addRec(list, 0) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!SLIDE | |
# gist-slideを試してみる | |
[これ](http://gist-slide.appspot.com/1191887/gist-slide) | |
!SLIDE | |
## どーよ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package iteratee.practice | |
import scalaz._ | |
import Scalaz._ | |
import effects._ | |
import java.io.File | |
/** | |
* http://code.google.com/codejam/contest/1343486/dashboard | |
* の問題ファイルを読み込んでみる練習 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package iteratee.practice | |
import scalaz._ | |
import Scalaz._ | |
import IterV._ | |
import effects._ | |
import java.io.File | |
/** | |
* scalazのIterateeを使ってファイルを読み込む練習 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Hello extends App { | |
println("Hello World!") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.{ BufferedReader, FileReader } | |
import scalaz._, Scalaz._ | |
import scalaz.effects._ | |
import IterV._ | |
object App { | |
def main(args: Array[String]) { | |
val br = new BufferedReader(new FileReader("test2.txt")) | |
val io = byEnumerator(br) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz._, Scalaz._ | |
trait ControllerHelper { | |
// Seq[String]から型Tのデータを抽出する型クラス | |
trait Extractor[T] { | |
def extract(data: Seq[String]): Option[T] | |
} | |
// Extractorを簡単に生成できるようにする |
OlderNewer