History

add number? and boolean?

Sigrid Haflínudóttir committed 6 years ago

Commit cb7cf9c1 parent 49131f21 file · +14 −4Browse files

Unified · Split

aa.c+14−4
@@ -40,16 +40,18 @@ typedef struct { · 39 unmodified lines
40 40
41enum {41enum {
42 P_LET, P_SET, P_IF, P_LAMBDA, P_MAC, P_WHILE, P_QUOTE, P_AND, P_OR, P_DO, P_CONS,42 P_LET, P_SET, P_IF, P_LAMBDA, P_MAC, P_WHILE, P_QUOTE, P_AND, P_OR, P_DO, P_CONS,
43 P_CAR, P_CDR, P_SETCAR, P_SETCDR, P_LIST, P_NOT, P_EQ, P_ATOM, P_PRINT, P_EQN, P_LT,43 P_CAR, P_CDR, P_SETCAR, P_SETCDR, P_LIST, P_NOT, P_EQ, P_PRINT,
44 P_LTE, P_ADD, P_SUB, P_MUL, P_DIV,44 P_ATOM, P_NUMBER, P_BOOLEAN,
45 P_EQN, P_LT, P_LTE, P_ADD, P_SUB, P_MUL, P_DIV,
45 46
46 P_MAX47 P_MAX
47};48};
48 49
49static const char *primnames[P_MAX] = {50static const char *primnames[P_MAX] = {
50 "let", "define", "if", "lambda", "mac", "while", "quote", "and", "or", "do", "cons",51 "let", "define", "if", "lambda", "mac", "while", "quote", "and", "or", "do", "cons",
51 "car", "cdr", "setcar", "setcdr", "list", "not", "eq?", "atom?", "print", "=", "<",52 "car", "cdr", "setcar", "setcdr", "list", "not", "eq?", "print",
52 "<=", "+", "-", "*", "/",53 "atom?", "number?", "boolean?",
54 "=", "<", "<=", "+", "-", "*", "/",
53};55};
54 56
55static const char *typenames[AA_TMAX] = {57static const char *typenames[AA_TMAX] = {
@@ -834,6 +836,14 @@ eval(aaContext *ctx, aaObject *obj, aaObject *env, aaObject **newenv) · 778 unmodified lines
834 res = aa_bool(ctx, aa_type(ctx, evalarg()) != AA_TPAIR);836 res = aa_bool(ctx, aa_type(ctx, evalarg()) != AA_TPAIR);
835 break;837 break;
836 838
839 case P_NUMBER:
840 res = aa_bool(ctx, aa_type(ctx, evalarg()) == AA_TNUMBER);
841 break;
842
843 case P_BOOLEAN:
844 res = aa_bool(ctx, aa_type(ctx, evalarg()) == AA_TBOOL);
845 break;
846
837 case P_PRINT:847 case P_PRINT:
838 while(!ISNIL(arg)){848 while(!ISNIL(arg)){
839 aa_writefp(ctx, evalarg(), &ctx->fd[1]);849 aa_writefp(ctx, evalarg(), &ctx->fd[1]);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t