void loli_init_tl(){ top_env = addToEnv(top_env, cons(mksym("a"), mkflt(10.0011011))); top_env = addToEnv(top_env, cons(t, t)); top_env = addToEnv(top_env, cons(nil, nil)); top_env = addToEnv(top_env, cons(quote, quote)); top_env = addToEnv(top_env, cons(mksym("top_env"), top_env)); //Creating Primitive Operators loliObj* loli_sum = mkproc(proc_sum); loliObj* loli_mul = mkproc(proc_mul); loliObj* loli_sub = mkproc(proc_sub); loliObj* loli_div = mkproc(proc_div); loliObj* loli_add1 = mkproc(proc_add1); loliObj* loli_sub1 = mkproc(proc_sub1); loliObj* loli_mod = mkproc(proc_mod); loliObj* loli_greater = mkproc(proc_greater); loliObj* loli_lesser = mkproc(proc_lesser); top_env = addToEnv(top_env, cons(mksym("+"), loli_sum)); top_env = addToEnv(top_env, cons(mksym("*"), loli_mul)); top_env = addToEnv(top_env, cons(mksym("-"), loli_sub)); top_env = addToEnv(top_env, cons(mksym("/"), loli_div)); top_env = addToEnv(top_env, cons(mksym("add1"), loli_add1)); top_env = addToEnv(top_env, cons(mksym("sub1"), loli_sub1)); top_env = addToEnv(top_env, cons(mksym("mod"), loli_mod)); top_env = addToEnv(top_env, cons(mksym(">"), loli_greater)); top_env = addToEnv(top_env, cons(mksym("<"), loli_lesser)); loliObj* test = cons(mkint(1), cons(mkflt(2.5), cons(mkint(5), nil))); std::cout<<toString(apply(loli_sum, test))<<"\t"<<toString(apply(loli_mul, test))<<"\n"<<toString(apply(loli_sub, test))<<"\t"<<toString(apply(loli_div, test))<<std::endl; std::cout<<toString(top_env)<<std::endl; }
int main(int argc, char * argv[]){ std::cout<<nil->value<<std::endl; std::cout<<t->value<<std::endl; // std::cout<<mkflt(1.2356).value<<std::endl; // loliObj* c = cons(t, nil); // loliObj* b = cons(t, c); // std::cout<<tail(tail(b))->value<<std::endl; std::cout<<"CREATING TEST:"<<std::endl; loliObj* test = cons(mksym("a"), cons(mkint(3), cons(mkint(0), nil))); // std::cout<<"TEST HEAD: "<<head(test).value<<std::endl; // std::cout<<"SUM (1 2 3): "<<proc_sum(test)->value<<std::endl; std::cout<<"SUB (\"a\" 3 0): "<<proc_sub(test)->value<<std::endl; /// std::cout<<"MUL (1 2 3): "<<proc_mul(test)->value<<std::endl; std::cout<<"DIV (\"a\" 3 0): "<<proc_div(test)->value<<std::endl; std::cout<<"MOD (\"a\" 3 0): "<<proc_mod(test)->value<<std::endl; std::cout<<"Length of (\"a\" 3 0) is: "<<prim_length(test)<<std::endl; loliObj* testSUM = mkproc(proc_sum); //cleanUp(); //delete test; exit(0); }