| Sign In/My Account | View Cart |
| Article: |
Embedding F-Script into Cocoa Applications | |
| Subject: | Re: Eg.2, passing and retrieving | |
| Date: | 2002-08-07 10:22:51 | |
| From: | pmougin | |
|
Response to: Eg.2, passing and retrieving
|
||
|
> So, I believe, this translates into obj c-code: > [a at: [a location]='CHICAGO" & [a capacity] >= 200] Not exactly. F-Script is an array language that let you manipulates arrays as a whole, taking care of iterating though the arrays’ elements automatically. This is not the case in Objective-C, where you have to explicitly code your loops. In this particular example, the equivalent Objective-C code would looks like: NSArray *airplanes . . . int i, nb; NSArray *selectedAirplanes = [NSMutableArray array]; for (i=0, nb=[airplanes count]; i < nb; i++) { Airplane *currentAirplane = [airplanes objectAtIndex:i]; if ([currentAirplane location] isEqualToString:@"CHICAGO"] && [currentAirplane capacity] >= 200) [selectedAirplanes addObject:currentAirplane]; } > Does this mean return a if true and nil if not true? No. In the example, "a" is an array of Airplanes. And the argument passed to the "at:" method is an array of booleans, with the same number of elements than in the array "a". The result will be an array of Airplaines where only the elements in "a" that correspond to a Boolean with a value of true in the bollean array will be selected. Phil |
||
Showing messages 1 through 2 of 2.
Need to figure out how to pencil around an F-Script sentence like :
"[:a| a at:a location = 'CHICAGO' & (a capacity >=200)]"
Also, might like to know if at: was short for attribute or where to go look it up, eg. examples on how to navigate your pdf book on F-Script. Maybe further columns will get up my nerve to navigate or I shall simply read the book when I get enough confidence.