define val = Sort ((define x) => x % 3) (Filter (IsEven) ([12,9,3,1,4,5]));
This can be inlined at compile time as well.
Filter (IsEven) ([12,9,3,1,4,5]) becomes FilteredArray([12, 9, 3, 1, 4, 5], IsEven(ArrayElement())))Sort ((define x => x % 3 == 0)) (FilteredArray([12,9,3,1,4,5], IsEven(ArrayElement()))) becomes SortedArray(FilteredArray(..), ArrayElement() % 3 == 0)
Now all of the runtime checking is gone, saving elements, subroutines, and perf cost without hurting ergonomics.
Right now, if you do something like
it will turn each of the lambdas into a function group and put it into a subroutine. However, this can be inlined as such:
Another example would be:
This can be inlined at compile time as well.
Filter (IsEven) ([12,9,3,1,4,5])
becomesFilteredArray([12, 9, 3, 1, 4, 5], IsEven(ArrayElement())))
Sort ((define x => x % 3 == 0)) (FilteredArray([12,9,3,1,4,5], IsEven(ArrayElement())))
becomesSortedArray(FilteredArray(..), ArrayElement() % 3 == 0)
Now all of the runtime checking is gone, saving elements, subroutines, and perf cost without hurting ergonomics.