September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -1,28 +1,37 @@
import extensions.
import extensions;
fib(n)
[
{
if (n < 0)
[ InvalidArgumentException new:"Must be non negative"; raise ].
{ InvalidArgumentException.raise() };
^ (:n)
[
if (n > 1)
[ ^ @self(n - 2) + @self(n - 1) ];[ ^ n ]
](n)
]
public program
[
-1 to:10 do(:i)
[
try (console printLine("fib(",i,")=",fib(i)))
^ (n)
{
on(Exception e)
[
console printLine:"invalid"
]
if (n > 1)
{
^ this self(n - 2) + (this self(n - 1))
}
else
{
^ n
}
}(n)
}
public program()
{
for (int i := -1, i <= 10, i += 1)
{
console.print("fib(",i,")=");
try
{
console.printLine(fib(i))
}
].
console readChar
]
catch(Exception e)
{
console.printLine:"invalid"
}
};
console.readChar()
}