aboutsummaryrefslogtreecommitdiffstats
path: root/NSArray+LispExtensions.m
blob: 308516e9b83bd0c92e27be2eb655165b6424953c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
//  NSArray+LispExtensions.m
//  Moxie
//
//  Created by Brian Cully on Tue Sep 07 2004.
//  Copyright (c) 2004 Brian Cully. All rights reserved.
//

#import "NSArray+LispExtensions.h"

@implementation NSArray (LispExtensions)
- (NSString *)lispForm
{
    NSEnumerator *objectEnum;
    NSMutableString *result;
    id obj;

    if ([self count] == 0)
        return @"NIL";
    
    objectEnum = [self objectEnumerator];
    result = [NSMutableString stringWithString: @"("];
    obj = [objectEnum nextObject];
    while (obj != nil) {
        NSString *form;
        
        form = [obj lispForm];
        [result appendString: form];
        obj = [objectEnum nextObject];
        if (obj)
            [result appendString: @" "];
    }
    [result appendString: @")"];
    return result;
}
@end