1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-09 13:33:26 +00:00

Add logic operations

This commit is contained in:
David Schmenk 2024-07-07 20:26:32 -07:00
parent 4b4b7e0683
commit 5ad6b0733c

View File

@ -552,6 +552,24 @@ def natv_eq(expr)
return eval_pred(eval_expr(expr=>car) == eval_expr(expr=>cdr=>car))
end
def natv_not(expr)
return eval_pred(eval_expr(expr=>car) == @pred_false)
end
def natv_and(expr)
while (expr and eval_expr(expr=>car) == @pred_true)
expr = expr=>cdr
loop
return eval_pred(!expr)
end
def natv_or(expr)
while (expr and eval_expr(expr=>car) == @pred_false)
expr = expr=>cdr
loop
return eval_pred(expr)
end
def natv_cons(expr)
var consptr
@ -748,6 +766,9 @@ def install_defaults#0
new_sym("CONS")=>natv = @natv_cons)
new_sym("ATOM")=>natv = @natv_atom)
new_sym("EQ")=>natv = @natv_eq)
new_sym("NOT")=>natv = @natv_not)
new_sym("AND")=>natv = @natv_and)
new_sym("OR")=>natv = @natv_or)
new_sym("COND")=>natv = @natv_cond)
new_sym("SET")=>natv = @natv_set)
new_sym("SETQ")=>natv = @natv_setq)