Skip to content

Instantly share code, notes, and snippets.

@n4to4
Created September 20, 2016 21:49
Show Gist options
  • Save n4to4/3db547a9e728bfc9bddd8dbd9046311b to your computer and use it in GitHub Desktop.
Save n4to4/3db547a9e728bfc9bddd8dbd9046311b to your computer and use it in GitHub Desktop.
iteratee sample
object Main extends App {
import io.iteratee.modules.id._
val singleNumE = enumOne(42)
val singleNumI = takeI[Int](1)
val singleNumResult = singleNumE.into(singleNumI)
println(singleNumResult)
val incrementNumEE = map[Int, Int](_ + 1)
val incrementedNumResult = singleNumE.through(incrementNumEE).into(singleNumI)
println(incrementedNumResult)
val naturalsE = iterate(1)(_ + 1)
val moreThan100EE = filter[Int](_ >= 100)
val evenFilterEE = filter[Int](_ % 2 == 0)
val first10I = takeI[Int](10)
println(naturalsE.through(moreThan100EE).through(evenFilterEE).into(first10I))
{
import io.iteratee.scalaz.task._
val naturalsE = iterate(1)(_ + 1)
val limit1kEE = take[Int](30000)
val sumI = fold[Int, Int](0) { (acc, next) => acc + next }
println(naturalsE.through(limit1kEE).into(sumI).run)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment