added random function
This commit is contained in:
+21
-8
@@ -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__), Lisp_Object_Type::Pair); \
|
||||||
assert_type(label(params,__LINE__)->value.pair.first, Lisp_Object_Type::Symbol); \
|
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); \
|
auto label(sfun,__LINE__) = Memory::create_lisp_object_cfunction(special); \
|
||||||
/*NOTE(Felix): for evaluating default args*/ \
|
/*NOTE(Felix): for evaluating default args*/ \
|
||||||
/*push_environment(get_root_environment());*/ \
|
/*push_environment(get_root_environment());*/ \
|
||||||
@@ -190,13 +190,13 @@ proc load_built_ins_into_environment() -> void {
|
|||||||
Globals::Current_Execution::envi_stack.next_index, \
|
Globals::Current_Execution::envi_stack.next_index, \
|
||||||
Globals::Current_Execution::envi_stack.next_index-1)
|
Globals::Current_Execution::envi_stack.next_index-1)
|
||||||
|
|
||||||
define((helper), "") {
|
define((helper), "") {
|
||||||
return Memory::create_lisp_object_number(101);
|
return Memory::create_lisp_object_number(101);
|
||||||
};
|
};
|
||||||
define((test (:k (helper))), "") {
|
define((test (:k (helper))), "") {
|
||||||
fetch(k);
|
fetch(k);
|
||||||
return k;
|
return k;
|
||||||
};
|
};
|
||||||
define((= . args),
|
define((= . args),
|
||||||
"Takes 0 or more arguments and returns =t= if all arguments are equal "
|
"Takes 0 or more arguments and returns =t= if all arguments are equal "
|
||||||
"and =()= otherwise.")
|
"and =()= otherwise.")
|
||||||
@@ -354,6 +354,19 @@ proc load_built_ins_into_environment() -> void {
|
|||||||
return Memory::create_lisp_object_number((int)a->value.number %
|
return Memory::create_lisp_object_number((int)a->value.number %
|
||||||
(int)b->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") {
|
define((assert test), "TODO") {
|
||||||
fetch(test);
|
fetch(test);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user