This file contains hidden or 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._ | |
| import Scalaz._ | |
| // Haskell には Thunk 潰しという遊戯があるらしい。 | |
| // <http://d.hatena.ne.jp/route150/20111108/1320736981> | |
| // そこで、scala でも「名前渡し潰し」で遊ぼうという趣旨 | |
| // むしろ、名前渡しでドツボな状況を作るのを苦労したというイミフな企画。 | |
| // ようやく -Xmx2G などで動いた。。。ヨ | |
| object PE249 extends App { |
This file contains hidden or 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._ | |
| import Scalaz._ | |
| object Bubble { | |
| def bubbleSort[A: Order](xs: List[A]) = xs.unfold[Stream, A] { | |
| _.foldr[Option[(A, List[A])]](none){ (x, zs) => | |
| zs.fold({case (y, ys) => (x lt y).fold((x, y::ys), (y, x::ys))}, (x, nil[A])).some | |
| } | |
| } | |
| } |
This file contains hidden or 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
| // Route150 さんの Project Euler 12 の答案を scala に移植した | |
| // <http://d.hatena.ne.jp/route150/20111107/1320630501> | |
| import scalaz._ | |
| import Scalaz._ | |
| import scalaz.effects._ | |
| // scalaz の不備を補う | |
| trait ScalazEffectsPatch { | |
| // scalaz.effect.STArray はサイズを取得する(#size())際に |
This file contains hidden or 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
| name := "ExcelConv" | |
| scalaVersion := "2.9.1" | |
| libraryDependencies += "org.scalaz" %% "scalaz-core" % "6.0.3" |
This file contains hidden or 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
| name := "ExcelConv" | |
| scalaVersion := "2.9.1" | |
| libraryDependencies += "org.scalaz" %% "scalaz-core" % "6.0.3" |
This file contains hidden or 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
| require 'json' | |
| require 'httparty' | |
| $username = 'put your username here' | |
| $password = 'put your password here' | |
| require 'net/http' | |
| class Gists | |
| include HTTParty |
This file contains hidden or 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 gist4z._ | |
| import Gist4z._ | |
| import gist4z.objects._ | |
| import scalaz._ | |
| import Scalaz._ | |
| // sample application | |
| object GistyZ { | |
| def main(args: Array[String]) { |
This file contains hidden or 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._ | |
| import Scalaz._ | |
| object Main extends App { | |
| val a = List(40, 50, 60) | |
| val b = List(1, 2, 3) | |
| val f = ((_: Int) * (_: Int)).curried | |
| // scalaz applicative style | |
| val scalazStyle = a <*> b ∘ f |
This file contains hidden or 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
| // 参考文献:Groovy + XLSBeans でエクセルから HTML に流し込み | |
| // <http://another.maple4ever.net/archives/1515/> | |
| import java.io._ | |
| import java.util.Date | |
| import java.util.{List => JList, _} | |
| import net.java.amateras.xlsbeans._ | |
| import net.java.amateras.xlsbeans.annotation._ | |
| import scala.reflect.BeanProperty | |
| import scala.annotation.target.beanSetter |
This file contains hidden or 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._ | |
| import Scalaz._ | |
| // 下記文献を参考に、あえて Scalaz と Either でやってみた。 | |
| // http://applicative-errors-scala.googlecode.com/svn/artifacts/0.6/pdf/index.pdf | |
| case class Person(age: Int, name: String, postcode: String) | |
| object Main { | |
| implicit def LeftSemigroupEitherApply[X: Semigroup]: Apply[PartialApply1Of2[Either, X]#Apply] = new Apply[PartialApply1Of2[Either, X]#Apply] { |