Apply a transform function to each element of an array. The block takes an int and returns an int.
| 28 | // Apply a transform function to each element of an array. |
| 29 | // The block takes an int and returns an int. |
| 30 | void apply_transform(const TArray<int32_t> & arr, int32_t * results, |
| 31 | const TBlock<int32_t, int32_t> & blk, |
| 32 | Context * context, LineInfoArg * at) { |
| 33 | for (uint32_t i = 0; i < arr.size; ++i) { |
| 34 | // das_invoke<RetType>::invoke(ctx, lineinfo, block, args...) |
| 35 | results[i] = das_invoke<int32_t>::invoke(context, at, blk, arr[i]); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | // A simpler example: call a void block with two arguments. |
| 40 | void with_values(int32_t a, int32_t b, |