summaryrefslogtreecommitdiff
path: root/MLKCons.m
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-07 14:21:27 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-07 14:21:27 +0200
commit3329eeafa1f08c5b9d410e57f761011d2e1ac1d6 (patch)
treeeb7fbe019e09e569894f29c37fe9081060ace32c /MLKCons.m
parenta3f6140ef3dde8184ce2b46119e73d9dca63e73f (diff)
Centralise declaration and documentation string handling.
Diffstat (limited to 'MLKCons.m')
-rw-r--r--MLKCons.m46
1 files changed, 45 insertions, 1 deletions
diff --git a/MLKCons.m b/MLKCons.m
index ba543b9..67aba08 100644
--- a/MLKCons.m
+++ b/MLKCons.m
@@ -98,7 +98,42 @@
return array;
}
--(NSString *)bareDescriptionForLisp
+-(void) appendObject:(id)object
+{
+ MLKCons *rest;
+
+ rest = self;
+ while (rest->_cdr)
+ {
+ rest = rest->_cdr;
+ }
+
+ LASSIGN (rest->_cdr, object);
+}
+
+-(MLKCons *) listByAppendingObject:(id)object
+{
+ MLKCons *rest = _cdr;
+ MLKCons *new_list = [MLKCons cons:_car with:nil];
+ MLKCons *tail = new_list;
+
+ while (rest)
+ {
+ LASSIGN (tail->_cdr, [MLKCons cons:rest->_car with:nil]);
+ tail = tail->_cdr;
+ }
+
+ LASSIGN (tail->_cdr, object);
+
+ return new_list;
+}
+
+-(MLKCons *) copyList
+{
+ return [self listByAppendingObject:nil];
+}
+
+-(NSString *) bareDescriptionForLisp
{
if (!_cdr)
return [NSString stringWithFormat:@"%@",
@@ -130,6 +165,15 @@
return [NSString stringWithFormat:@"(%@)", [self bareDescriptionForLisp]];
}
+-(BOOL) isEqual:(id)object
+{
+ if ([object isKindOfClass:[MLKCons class]])
+ return ([((MLKCons*)object)->_car isEqual:_car]
+ && [((MLKCons*)object)->_cdr isEqual:_cdr]);
+ else
+ return NO;
+}
+
-(id) copyWithZone:(NSZone *)zone
{
MLKCons *copy = [MLKCons allocWithZone:zone];