Update all new Tasks

This commit is contained in:
Ingy döt Net 2015-02-20 09:02:09 -05:00
parent 00a190b0a6
commit 91df62d461
5697 changed files with 93386 additions and 804 deletions

View file

@ -0,0 +1,41 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method brenfordDeveation(nlist = Rexx[]) public static
observed = 0
loop n_ over nlist
d1 = n_.left(1)
if d1 = 0 then iterate n_
observed[d1] = observed[d1] + 1
end n_
say ' '.right(4) 'Observed'.right(11) 'Expected'.right(11) 'Deviation'.right(11)
loop n_ = 1 to 9
actual = (observed[n_] / (nlist.length - 1))
expect = Rexx(Math.log10(1 + 1 / n_))
deviat = expect - actual
say n_.right(3)':' (actual * 100).format(3, 6)'%' (expect * 100).format(3, 6)'%' (deviat * 100).abs().format(3, 6)'%'
end n_
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method fibonacciList(size = 1000) public static returns Rexx[]
fibs = Rexx[size + 1]
fibs[0] = 0
fibs[1] = 1
loop n_ = 2 to size
fibs[n_] = fibs[n_ - 1] + fibs[n_ - 2]
end n_
return fibs
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg n_ .
if n_ = '' then n_ = 1000
fibList = fibonacciList(n_)
say 'Fibonacci sequence to' n_
brenfordDeveation(fibList)
return