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
data Tuple a b c d = | |
OneTuple a | | |
TwoTuple a b | | |
ThreeTuple a b c | | |
FourTuple a b c d | |
tuple1 :: Tuple a b c d -> Maybe a | |
tuple1 (OneTuple a) = Just a | |
tuple1 (TwoTuple a b) = Just a | |
tuple1 (ThreeTuple a b c) = Just a |
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
data List a = | |
Nil | | |
Cons a (List a) | |
listLength :: Num b => List a -> b | |
listLength Nil = 0 | |
listLength (Cons x xs) = 1 + listLength xs | |
listHead :: List a -> a | |
listHead (Cons x xs) = x |
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
.section __TEXT,__text,regular,pure_instructions | |
.section __TEXT,__textcoal_nt,coalesced,pure_instructions | |
.section __TEXT,__const_coal,coalesced | |
.section __TEXT,__picsymbolstub4,symbol_stubs,none,16 | |
.section __TEXT,__StaticInit,regular,pure_instructions | |
.syntax unified | |
.section __TEXT,__text,regular,pure_instructions | |
.align 2 | |
.code 16 |
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
.section __TEXT,__text,regular,pure_instructions | |
.section __TEXT,__textcoal_nt,coalesced,pure_instructions | |
.section __TEXT,__const_coal,coalesced | |
.section __TEXT,__picsymbolstub4,symbol_stubs,none,16 | |
.section __TEXT,__StaticInit,regular,pure_instructions | |
.syntax unified | |
.section __TEXT,__text,regular,pure_instructions | |
.align 2 | |
.code 16 | |
.thumb_func "-[IvarWriteAppDelegate application:didFinishLaunchingWithOptions:]" |
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
@synthesize window=_window; | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
asm("#before"); | |
_window = nil; | |
asm("#after"); | |
// Override point for customization after application launch. | |
[self.window makeKeyAndVisible]; |
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
- (NSString *)myMethod { | |
NSString *str = nil; | |
scope { | |
NSAutoreleasePool *pool = [NSAutoreleasePool new]; | |
scope(exit) | |
[pool drain]; | |
str = [[NSMutableString alloc] initWithFormat:@"%i", 42]; |
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
// syntactic sugar for @onExit | |
#define releaseOnExit \ | |
ext_saveSelf]; @onExit { [ext_releaseObj release]; }; [(id)nil self | |
NSMutableString *str = [[@"foo" mutableCopy] releaseOnExit]; |
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
#define coroutine(ARGS) \ | |
__block unsigned long ext_coroutine_line_ = 0; \ | |
\ | |
return ^(ARGS){ \ | |
for (;; ext_coroutine_line_ = 0) \ | |
switch (ext_coroutine_line_) \ | |
default: | |
#define return_coroutine \ | |
} |
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
- (NSArray *)mapWithOptions:(NSEnumerationOptions)options usingBlock:(id (^)(id obj))block { | |
NSUInteger count = [self count]; | |
NSArray *result = nil; | |
if (options & NSEnumerationConcurrent) { | |
volatile id * restrict objects = malloc(sizeof(id) * count); | |
if (!objects) { | |
return nil; | |
} |
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
typedef id (^Tuple)(size_t); | |
#define tuple(...) \ | |
tupleMake(__VA_ARGS__, nil) | |
#define emptyTuple \ | |
tupleMake(nil) | |
Tuple tupleMake (id firstObject, ...) NS_REQUIRES_NIL_TERMINATION | |
{ |
OlderNewer