Skip to content

Instantly share code, notes, and snippets.

@chemacortes
Last active January 27, 2024 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemacortes/84847f9a8b623b79482ea74337dadd50 to your computer and use it in GitHub Desktop.
Save chemacortes/84847f9a8b623b79482ea74337dadd50 to your computer and use it in GitHub Desktop.
Fibonacci succession with scala3 (oneline versions)
val fibs: LazyList[BigInt] = BigInt(1) #:: BigInt(1) #:: (fibs zip fibs.tail).map(_+_)
val fibs: LazyList[BigInt] = 1 #:: fibs.scan(BigInt(1))(_+_)
val lucas: LazyList[BigInt] = 2 #:: fibs.scan(BigInt(1))(_+_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment