I've written a console script, with a simple implementation of the Fibonacci recursive algorithm.
However, I searched in the docs and still cannot find how to get a number param from the command line. How is that possible?
Code:
#!/usr/local/bin/lgm -l
import core.number;
fibo(x) =>
{
x<=1 :==> 1;
==> fibo(x-1)+fibo(x-2);
}
Command line arguments are stored in the __Args
variable.
So, you can use them pretty much like any normal array.
@G.Stevens is correct.
Commands line arguments can be accessed via the global __Args
variable.
So, in your case, if you need the first argument, all you have to do is __Args[0]
.
And since you want is as number :
__Args[0].fromBase(10)
from core.number
(which you're already importing anyway...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With