mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			33 lines
		
	
	
		
			764 B
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			33 lines
		
	
	
		
			764 B
		
	
	
	
		
			Matlab
		
	
| 
								 
											5 years ago
										 
									 | 
							
								#import "NSArray+Functional.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@implementation NSArray (Functional)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (BOOL)contains:(BOOL (^)(id))predicate {
							 | 
						||
| 
								 | 
							
								    for (id object in self) {
							 | 
						||
| 
								 | 
							
								        BOOL isPredicateSatisfied = predicate(object);
							 | 
						||
| 
								 | 
							
								        if (isPredicateSatisfied) { return YES; }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    return NO;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (NSArray *)filtered:(BOOL (^)(id))isIncluded {
							 | 
						||
| 
								 | 
							
								    NSMutableArray *result = [NSMutableArray new];
							 | 
						||
| 
								 | 
							
								    for (id object in self) {
							 | 
						||
| 
								 | 
							
								        if (isIncluded(object)) {
							 | 
						||
| 
								 | 
							
								            [result addObject:object];
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    return result;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (NSArray *)map:(id (^)(id))transform {
							 | 
						||
| 
								 | 
							
								    NSMutableArray *result = [NSMutableArray new];
							 | 
						||
| 
								 | 
							
								    for (id object in self) {
							 | 
						||
| 
								 | 
							
								        id transformedObject = transform(object);
							 | 
						||
| 
								 | 
							
								        [result addObject:transformedObject];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    return result;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@end
							 |