Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1 @@
42.fibonacci

View file

@ -0,0 +1,5 @@
// Assuming code is in Integer.fibonacci() method
() Integer
[
if this < 2 [this] else [[this - 1].fibonacci + [this - 2].fibonacci]
]

View file

@ -0,0 +1,5 @@
// Assuming in fibonacci(n) procedure
(Integer n) Integer
[
if n < 2 [n] else [fibonacci(n - 1) + fibonacci(n - 2)]
]

View file

@ -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
]
]

View file

@ -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
]
]