This file contains hidden or 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
| static void(^stream_composition_demo)(void) = ^{ | |
| typedef typeof(unsigned long) predicate; | |
| typedef typeof(predicate(^)(predicate)) predicate_function; | |
| typedef typeof(predicate(^(*))(predicate)) predicate_function_t; | |
| typeof(predicate_function) stream_op; | |
| typeof(predicate_function_t) stream_op_t = &stream_op; | |
| typeof(predicate_function) predicate_op; | |
| typeof(predicate_function_t) predicate_op_t = &predicate_op; |
This file contains hidden or 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
| static void(^swap_pointers)(void) = | |
| ^{ | |
| typedef typeof(unsigned long(^)(unsigned long)) predicate_function; | |
| typedef typeof(unsigned long(^*)(unsigned long)) predicate_function_t; | |
| predicate_function func_a, func_b; | |
| __block void * current = (predicate_function_t)&func_a; | |
| __block void * swap = (predicate_function_t)&func_b; | |
| func_a = ^ unsigned long (unsigned long predicate) { |
This file contains hidden or 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
| clock_t recursive_function(clock_t count) { | |
| // Code to measure goes here (lower numbers are better) | |
| return (clock_t)(((((clock_t)nil ^ count) && recursive_function(~-count)))); | |
| } | |
| static void (^speed_test)(void) = ^{ | |
| printf("recursive function == %lu\n", -clock() & (recursive_function(clock()) ^ clock())); | |
| }; |
This file contains hidden or 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
| // Adds log entries to a UITextView | |
| typedef typeof(NSString *) LogEntry; | |
| typedef typeof(NSMutableAttributedString *) LogEntryComposition; | |
| typedef const typeof(LogEntryComposition * restrict) LogEntryCompositionPtr; | |
| typedef typeof(void(^)(LogEntry)) LogEngine; | |
| static void (^(^log_engine)(UITextView *))(LogEntry) = ^ (UITextView * text_view) { | |
| __block LogEntryComposition entry_composition = [[NSMutableAttributedString alloc] init]; | |
| return ^ (LogEntry entry) { | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| NSAttributedString * attributed_entry = [[NSAttributedString alloc] initWithString:entry attributes:^ NSDictionary * (void) { |
This file contains hidden or 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
| // | |
| // AggregateOperations.h | |
| // AggregateOperationsPlayground | |
| // | |
| // Created by Xcode Developer on 9/22/22. | |
| // | |
| #ifndef AggregateOperations_h | |
| #define AggregateOperations_h |
This file contains hidden or 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 const typeof(id(^)(void)) retained_object; | |
| static id (^retainable_object)(id(^)(void)) = ^ id (id(^object)(void)) { | |
| return ^{ | |
| return object(); | |
| }; | |
| }; | |
| typeof (retained_object) *(^(^retain_object)(id (^__strong)(void)))(void) = ^ (id(^retainable_object)(void)) { | |
| typeof(retained_object) * object_address; |
This file contains hidden or 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
| #import "Clocking.h" | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdint.h> | |
| #include <time.h> | |
| #define CONDITION(x) ((clock_t)nil ^ x) | |
| #define DECREMENT(x) (x = ~-x) | |
| #define ADJUST_TIME(x) x / CLOCKS_PER_SEC |
This file contains hidden or 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 typeof(unsigned long (^ _Nonnull __strong (* _Nonnull))(unsigned long)) predicate_function_ptr; | |
| struct predicate_functions_arr_struct | |
| { | |
| unsigned long len; | |
| predicate_function_ptr functions[]; | |
| }; | |
| static void(^test_flexible_array_member)(void) = ^{ | |
| struct predicate_functions_arr_struct * p_functions = malloc(sizeof(struct predicate_functions_arr_struct) + (10 * sizeof(predicate_function_ptr))); | |
| p_functions->len = 10; |
This file contains hidden or 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
| // | |
| // PredicateFunctions.h | |
| // PredicateFunctions | |
| // | |
| // Created by Xcode Developer on 9/10/22. | |
| // | |
| #ifndef PredicateFunctions_h | |
| #define PredicateFunctions_h |
This file contains hidden or 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
| #import "SimpleBlockComposition.h" | |
| typedef typeof(unsigned long(^)(unsigned long)) block; | |
| typedef typeof(block *) block_t; | |
| typedef typeof(block(^)(block)) block_object; | |
| static block (^compose)(block, block) = ^ (block composition, block component) { | |
| block temp_comp = composition; | |
| block new_comp = ^ (unsigned long c) { printf("composing block chain...\n"); return component(temp_comp(c)); }; | |
| return new_comp; |