Well you can write functions like: map, filter, sort, ...
In fact some do already exist: TStringList.CustomSort()
But, you can not write the "helper function" (e.g. compare for sort) on the fly.
You have to declare it upfront.
And also when you write your sort, you have to decide what kind of "function" it accepts.
This is not about the function arguments, which obviously must match.
This is about:
- plain function: "function Foo(); begin end"
- Method (of a class): "function TMyClass.Foo; begin end"
- Nested functions: Afaik needs a special modeswitch.
They all have different signatures, and are not assignment compatible.
You also do not have closures (not the same as anonymous functions / even though a lot of languages only offer the two as one bundled package).
But there is one good thing as well.
generic functions.
You can write a sort function as a generic, and then specialize it (afaik possible on the fly) for any type (int, real, string, even class).
However, only if the operators are available or overloaded. => If you use > and < then those must be available for whatever type you want to compare.