Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
20
Task/Time-a-function/Sidef/time-a-function.sidef
Normal file
20
Task/Time-a-function/Sidef/time-a-function.sidef
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
var benchmark = frequire('Benchmark')
|
||||
|
||||
func fac_rec(n) {
|
||||
n == 0 ? 1 : (n * __FUNC__(n - 1))
|
||||
}
|
||||
|
||||
func fac_iter(n) {
|
||||
var prod = 1
|
||||
n.times { |i|
|
||||
prod *= i
|
||||
}
|
||||
prod
|
||||
}
|
||||
|
||||
var result = benchmark.timethese(-3, Hash(
|
||||
'fac_rec' => { fac_rec(20) },
|
||||
'fac_iter' => { fac_iter(20) },
|
||||
))
|
||||
|
||||
benchmark.cmpthese(result)
|
||||
Loading…
Add table
Add a link
Reference in a new issue