Created
June 3, 2015 22:26
-
-
Save searler/d2b3461a11a8a9ce350c to your computer and use it in GitHub Desktop.
Simple example for scodec BitVector unfold
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 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