Added some methods to „Working With the Expression Tree“ section
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#import "MPFunction.h"
|
||||
#import "MPExpression.h"
|
||||
|
||||
#import "NSIndexPath+MPRemoveFirstIndex.h"
|
||||
|
||||
@implementation MPFunction
|
||||
|
||||
#pragma mark Creation Methods
|
||||
@@ -90,7 +92,7 @@
|
||||
|
||||
@implementation MPFunction (MPFunctionExtensionMethods)
|
||||
|
||||
#pragma mark Children
|
||||
#pragma mark Working With the Expression Tree
|
||||
|
||||
- (NSArray *)children
|
||||
{
|
||||
@@ -102,6 +104,26 @@
|
||||
return [children copy];
|
||||
}
|
||||
|
||||
- (NSUInteger)indexOfChild:(MPExpression *)child
|
||||
{
|
||||
NSUInteger index = 0;
|
||||
for (; index < [self numberOfChildren]; index++) {
|
||||
if ([[self childAtIndex:index] isEqualToExpression:child]) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return NSNotFound;
|
||||
}
|
||||
|
||||
- (id)symbolAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.length == 0) {
|
||||
return self;
|
||||
}
|
||||
MPExpression *child = [self childAtIndex:[indexPath indexAtPosition:0]];
|
||||
return [child symbolAtIndexPath:[indexPath indexPathByRemovingFirstIndex]];
|
||||
}
|
||||
|
||||
#pragma mark Evaluating Functions
|
||||
|
||||
- (float)floatValue
|
||||
|
||||
Reference in New Issue
Block a user