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
4040
4141 enum {
4242 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,
44− P_LTE, P_ADD, P_SUB, P_MUL, P_DIV,
43+ P_CAR, P_CDR, P_SETCAR, P_SETCDR, P_LIST, P_NOT, P_EQ, P_PRINT,
44+ P_ATOM, P_NUMBER, P_BOOLEAN,
45+ P_EQN, P_LT, P_LTE, P_ADD, P_SUB, P_MUL, P_DIV,
4546
4647 P_MAX
4748 };
4849
4950 static const char *primnames[P_MAX] = {
5051 "let", "define", "if", "lambda", "mac", "while", "quote", "and", "or", "do", "cons",
51− "car", "cdr", "setcar", "setcdr", "list", "not", "eq?", "atom?", "print", "=", "<",
52− "<=", "+", "-", "*", "/",
52+ "car", "cdr", "setcar", "setcdr", "list", "not", "eq?", "print",
53+ "atom?", "number?", "boolean?",
54+ "=", "<", "<=", "+", "-", "*", "/",
5355 };
5456
5557 static const char *typenames[AA_TMAX] = {
@@ -834,6 +836,14 @@ eval(aaContext *ctx, aaObject *obj, aaObject *env, aaObject **newenv) · 778 unmodified lines
834836 res = aa_bool(ctx, aa_type(ctx, evalarg()) != AA_TPAIR);
835837 break;
836838
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+
837847 case P_PRINT:
838848 while(!ISNIL(arg)){
839849 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