History

add equal?

Sigrid Haflínudóttir committed 6 years ago

Commit 927bc581 parent acabca52 files · +17 −1Browse files

Unified · Split

2 files
  1. README.md +1 −0
  2. aa.c +16 −1
README.md+1−0
@@ -53,6 +53,7 @@ atom? · 52 unmodified lines
53boolean?53boolean?
54defined?54defined?
55eq?55eq?
56equal?
56nan?57nan?
57null?58null?
58number?59number?
aa.c+16−1
@@ -63,6 +63,7 @@ enum { · 62 unmodified lines
63 P_NOT,63 P_NOT,
64 P_DISPLAY,64 P_DISPLAY,
65 P_EQ_HUH,65 P_EQ_HUH,
66 P_EQUAL_HUH,
66 P_ATOM_HUH,67 P_ATOM_HUH,
67 P_NUMBER_HUH,68 P_NUMBER_HUH,
68 P_BOOLEAN_HUH,69 P_BOOLEAN_HUH,
@@ -103,6 +104,7 @@ static const char *primnames[P_MAX] = { · 34 unmodified lines
103 "not",104 "not",
104 "display",105 "display",
105 "eq?",106 "eq?",
107 "equal?",
106 "atom?",108 "atom?",
107 "number?",109 "number?",
108 "boolean?",110 "boolean?",
@@ -299,7 +301,7 @@ equal(aaObject *a, aaObject *b) · 190 unmodified lines
299 if(a == b)301 if(a == b)
300 return 1;302 return 1;
301 303
302 if(TYPE(a) != TYPE(b))304 if(TYPE(a) != TYPE(b) || TYPE(a) == AA_TBOOL)
303 return 0;305 return 0;
304 306
305 if(TYPE(a) == AA_TNUMBER)307 if(TYPE(a) == AA_TNUMBER)
@@ -313,6 +315,14 @@ equal(aaObject *a, aaObject *b) · 7 unmodified lines
313 return a == b;315 return a == b;
314 }316 }
315 317
318 if(TYPE(a) == AA_TPAIR){
319 for(; !ISNULL(a); a = CDR(a), b = CDR(b)){
320 if(!equal(CAR(a), CAR(b)))
321 return 0;
322 }
323 return a == b;
324 }
325
316 return 0;326 return 0;
317}327}
318 328
@@ -882,6 +892,11 @@ eval(aaContext *ctx, aaObject *obj, aaObject *env, aaObject **newenv) · 563 unmodified lines
882 noargs();892 noargs();
883 break;893 break;
884 894
895 case P_EQUAL_HUH:
896 res = aa_bool(ctx, equal(evalarg(), evalarg()));
897 noargs();
898 break;
899
885 case P_ATOM_HUH:900 case P_ATOM_HUH:
886 res = aa_bool(ctx, aa_type(ctx, evalarg()) != AA_TPAIR);901 res = aa_bool(ctx, aa_type(ctx, evalarg()) != AA_TPAIR);
887 noargs();902 noargs();

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