September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,31 +1,35 @@
#import system.
#import extensions.
import extensions.
#class(extension)mathOp
extension mathOp
{
#method fib
fib
[
(self < 0)
? [ #throw InvalidArgumentException new &message:"Must be non negative". ].
if (self < 0)
[ InvalidArgumentException new:"Must be non negative"; raise ].
^ control eval:self &for:
^ control do:self with
(:n)
[
(n > 1) ? [ this eval:(n - 2) + this eval:(n - 1) ] ! [ n ]
if (n > 1)
[ ^ $closure eval(n - 2) + $closure eval(n - 1) ];
[ ^ n ]
].
]
}
#symbol program =
program =
[
-1 to:10 &doEach: (:i)
-1 to:10 do(:i)
[
console writeLiteral:"fib(":i:")=".
console print("fib(",i,")=").
console writeLine:(i fib) | if &InvalidArgumentError: e
try (console printLine(i fib))
{
on(Exception e)
[
console writeLine:"invalid".
].
console printLine:"invalid"
]
}.
].
console readChar.