Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
42.fibonacci
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// Assuming code is in Integer.fibonacci() method
|
||||
() Integer
|
||||
[
|
||||
if this < 2 [this] else [[this - 1].fibonacci + [this - 2].fibonacci]
|
||||
]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// Assuming in fibonacci(n) procedure
|
||||
(Integer n) Integer
|
||||
[
|
||||
if n < 2 [n] else [fibonacci(n - 1) + fibonacci(n - 2)]
|
||||
]
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Assuming code is in Integer.fibonacci() method
|
||||
() Integer
|
||||
[
|
||||
if this < 2
|
||||
[this]
|
||||
else
|
||||
[
|
||||
!prev: 1
|
||||
!next: 1
|
||||
2.to_pre this
|
||||
[
|
||||
!sum : prev + next
|
||||
prev := next
|
||||
next := sum
|
||||
]
|
||||
|
||||
next
|
||||
]
|
||||
]
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Bind : is faster than assignment :=
|
||||
// loop is faster than to_pre (which uses a closure)
|
||||
() Integer
|
||||
[
|
||||
if this < 2
|
||||
[this]
|
||||
else
|
||||
[
|
||||
!prev: 1
|
||||
!next: 1
|
||||
!sum
|
||||
!count: this - 2
|
||||
loop
|
||||
[
|
||||
if count = 0 [exit]
|
||||
count--
|
||||
sum : prev + next
|
||||
prev : next
|
||||
next : sum
|
||||
]
|
||||
|
||||
next
|
||||
]
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue