Skip to content

Instantly share code, notes, and snippets.

@lyricallogical
Created September 29, 2012 12:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyricallogical/3803850 to your computer and use it in GitHub Desktop.
Save lyricallogical/3803850 to your computer and use it in GitHub Desktop.
ocaml like module(functor) programming in scala
imoprt Iteratee._
lazy val takeOdds = {
val aux = for {
one <- headOption[Byte[Array]] // ダサい
_ <- headOption[Byte[Array]] // ダサい
} yield one
for {
odds <- aux
rest <- takeOdds
} yield for {
odds <- odds
rest <- rest
} yield odds ++ rest
}
object ByteArrayIteratee extends IterateeBase[Array[Byte]]
imoprt ByteArrayIteratee._
lazy val takeOdds = {
val aux = for {
one <- headOption // やった
_ <- headOption // やった
} yield one
for {
odds <- aux
rest <- takeOdds
} yield for {
odds <- odds
rest <- rest
} yield odds ++ rest
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment