(def map (B (B reverse) (B (B (Z (B (S (S (B (eq nil) (2 cdr)) (B car cdr))) (C B (S (B cons car) (Phi cons (Phi cons (S car (B (B car cdr) cdr)) (B car cdr)) (3 cdr))))))) (C (B B cons) (cons nil)))))
-(def fold (B (S (C (C (eq nil) nil) (Z (B (S (S (B (eq nil) (B cdr cdr)) (B car cdr))) (C B (S (B cons car) (Phi cons (S (S car (B car cdr)) (B car (2 cdr))) (3 cdr)))))))) cons))
\ No newline at end of file
+(def fold (B (S (C (C (eq nil) nil) (Z (B (S (S (B (eq nil) (B cdr cdr)) (B car cdr))) (C B (S (B cons car) (Phi cons (S (S car (B car cdr)) (B car (2 cdr))) (3 cdr)))))))) cons))
return cons(first_arg, cons(from_quote(newrest), from_nil()));
}
+Sexpr* c_unquote(Sexpr* b, Sexpr* rest, Sexpr* env) {
+ // now the question here is, is it necessarily wrong
+ // to do this to non-quotes?
+ // this... needs an eval...
+ if(CORE_UNQUOTE_ARGS != u64_get_num_args(b))
+ return cons(b, rest);
+ Sexpr* first_arg = car(b->value.b.args);
+ Sexpr* newthing = eval(clone(unquote(first_arg)), env);
+ sexpr_free(b);
+ return cons(newthing, rest);
+}
Sexpr* c_applyn(Sexpr* b, Sexpr* rest, Sexpr* env) {
// possible commentary for the future:
return c_atom(b, rest, env);
case CORE_REST:
return c_rest(b, rest, env);
+ case CORE_UNQUOTE:
+ return c_unquote(b, rest, env);
case CORE_APPLYN:
return c_applyn(b, rest, env);
case CORE_DEF:
load_builtin(CORE_NOT_STR, (CORE_PREFIX << 8) | CORE_NOT, env);
load_builtin(CORE_ATOM_STR, (CORE_PREFIX << 8) | CORE_ATOM, env);
load_builtin(CORE_REST_STR, (CORE_PREFIX << 8) | CORE_REST, env);
+ load_builtin(CORE_UNQUOTE_STR, (CORE_PREFIX << 8) | CORE_UNQUOTE, env);
load_builtin(CORE_DEF_STR, (CORE_PREFIX << 8) | CORE_DEF, env);
load_builtin(CORE_EXIT_STR, (CORE_PREFIX << 8) | CORE_EXIT, env);
#define CORE_REST 0x08
#define CORE_REST_ARGS 2
#define CORE_REST_STR "rest"
-
-#define CORE_APPLYN 0x0f
+#define CORE_UNQUOTE 0x09
+#define CORE_UNQUOTE_ARGS 1
+#define CORE_UNQUOTE_STR "unquote"
+#define CORE_APPLYN 0x0a
#define CORE_APPLYN_ARGS 3
#define CORE_APPLYN_STR "applyn"