Commit a2ff7909 authored by Juergen Nickelsen's avatar Juergen Nickelsen

Brandom

parent 6eefd524
......@@ -17,11 +17,16 @@ use Util;
use Eval;
use Interp;
# helper functions
# Builtins get their arguments directly as a Lisp list, have names
# beginning with 'B', and are defined here (except for, well, exceptions)
sub Brandom {
my ($arglist) = @_;
my ($limit) = checkargs($arglist, ':n');
$limit = 1 if is_nil($limit);
return rand($limit);
}
sub Bsqrt {
my ($arglist) = @_;
my ($arg) = checkargs($arglist, 'n');
......@@ -1028,6 +1033,8 @@ my @builtins = # [name, func, is_special, doc]
"split STRING into parts SEPARATED by SEP and return the list"],
["sqrt", \&Bsqrt, 0, "return the square root of numeric ARG"],
["isqrt", \&Bsqrt, 0, "return the integer square root of numeric ARG"],
["random", \&Brandom, 0,
"return a random number a with 0 <= a < LIMIT (or 1)"]
);
for my $b (@builtins) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment