Skip to content

Instantly share code, notes, and snippets.

@searler
Created June 3, 2015 22:26
Show Gist options
  • Save searler/d2b3461a11a8a9ce350c to your computer and use it in GitHub Desktop.
Save searler/d2b3461a11a8a9ce350c to your computer and use it in GitHub Desktop.
Simple example for scodec BitVector unfold
import scodec.bits._
object Unfolder extends App {
case class S(size:Int) {
def next:Option[(BitVector,S)] =
if (size > 0)
Some((BitVector(size), S(size-1)))
else
None
}
val bv = BitVector.unfold(S(10)){_.next }
println(bv)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment