Created
February 16, 2012 21:07
-
-
Save MaxGabriel/1847858 to your computer and use it in GitHub Desktop.
CS193p Fall 2011 Assignment 2--Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Iterates through program, an array of operations and NSNumbers | |
//Returns human-readable list of numbers and operations in RPN | |
+ (NSString *)descriptionOfProgram:(id)program | |
{ | |
NSString *description = [[NSString alloc] init]; | |
if ([program isKindOfClass:[NSArray class]]) { | |
for (int i=0; i<[program count]; i++) { | |
if ([[program objectAtIndex:i] isKindOfClass:[NSNumber class]]) { | |
description = [description stringByAppendingString:[[program objectAtIndex:i] stringValue]]; | |
} else { | |
description = [description stringByAppendingFormat:@"%@",[program objectAtIndex:i]]; | |
} | |
description = [description stringByAppendingString:@" "]; | |
} | |
} | |
return description; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment