Permalink
Browse files

Perform equality test on multiple arguments.

  • Loading branch information...
andrewschleifer committed Nov 28, 2010
1 parent 4e9edcd commit 741c6d2eeaf7215fb10b77381b8c0f6c95291bac
Showing with 10 additions and 12 deletions.
  1. +10 −12 objc/NuOperator.m
View
@@ -176,20 +176,18 @@ @interface Nu_eq_operator : NuOperator {}
@implementation Nu_eq_operator
- (id) callWithArguments:(id)cdr context:(NSMutableDictionary *)context
{
- id cadr = [cdr car];
- id caddr = [[cdr cdr] car];
- id value1 = [cadr evalWithContext:context];
- id value2 = [caddr evalWithContext:context];
NuSymbolTable *symbolTable = [context objectForKey:SYMBOLS_KEY];
- if ((value1 == nil) && (value2 == nil)) {
- return [symbolTable symbolWithCString:"t"];
- }
- else if ([value1 isEqual:value2]) {
- return [symbolTable symbolWithCString:"t"];
- }
- else {
- return Nu__null;
+ id cursor = cdr;
+ id current = [[cursor car] evalWithContext:context];
+ cursor = [cursor cdr];
+ while (cursor && (cursor != Nu__null)) {
+ id next = [[cursor car] evalWithContext: context];
+ if (![current isEqual:next])
+ return Nu__null;
+ current = next;
+ cursor = [cursor cdr];
}
+ return [symbolTable symbolWithCString:"t"];
}
@end

0 comments on commit 741c6d2

Please sign in to comment.