Skip to content

Instantly share code, notes, and snippets.

@ORBAT
Last active December 20, 2015 02:08
Show Gist options
  • Select an option

  • Save ORBAT/6053776 to your computer and use it in GitHub Desktop.

Select an option

Save ORBAT/6053776 to your computer and use it in GitHub Desktop.
I have no idea.
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