added random function
This commit is contained in:
+14
-1
@@ -170,7 +170,7 @@ proc load_built_ins_into_environment() -> void {
|
||||
); \
|
||||
assert_type(label(params,__LINE__), Lisp_Object_Type::Pair); \
|
||||
assert_type(label(params,__LINE__)->value.pair.first, Lisp_Object_Type::Symbol); \
|
||||
auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
|
||||
static auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
|
||||
auto label(sfun,__LINE__) = Memory::create_lisp_object_cfunction(special); \
|
||||
/*NOTE(Felix): for evaluating default args*/ \
|
||||
/*push_environment(get_root_environment());*/ \
|
||||
@@ -354,6 +354,19 @@ proc load_built_ins_into_environment() -> void {
|
||||
return Memory::create_lisp_object_number((int)a->value.number %
|
||||
(int)b->value.number);
|
||||
};
|
||||
define((get-random-between a b), "TODO") {
|
||||
fetch(a, b);
|
||||
try assert_type(a, Lisp_Object_Type::Number);
|
||||
try assert_type(b, Lisp_Object_Type::Number);
|
||||
|
||||
double fa = a->value.number;
|
||||
double fb = b->value.number;
|
||||
double x = (double)rand()/(double)(RAND_MAX);
|
||||
x *= (fb - fa);
|
||||
x += fa;
|
||||
|
||||
return Memory::create_lisp_object_number(x);
|
||||
};
|
||||
define((assert test), "TODO") {
|
||||
fetch(test);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user