Last active
December 20, 2015 02:08
-
-
Save ORBAT/6053776 to your computer and use it in GitHub Desktop.
I have no idea.
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
| def produceFibList(count: Int, minLen: Int = 16, padding: Char = 'X') = { | |
| import math.BigInt | |
| // lazy so that this'll work in the REPL or a worksheet, too | |
| lazy val fib: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fib.zip(fib.tail).map(tup => tup._1 + tup._2) | |
| def bigIntToStr(b: BigInt): String = { | |
| def pad(s: String): String = { | |
| val paddingLen = minLen - s.length | |
| if(paddingLen > 0) | |
| (padding.toString) * paddingLen + s | |
| else | |
| s | |
| } | |
| pad(b.toString(20).toUpperCase) | |
| } | |
| fib map bigIntToStr | |
| } | |
| val paddedFibs = produceFibList(100, 16, '0') | |
| paddedFibs take 10 foreach println |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment