January 2020
Intermediate to advanced
532 pages
13h 31m
English
As we have seen earlier in this section, Julia creates a unique function type for every function, and they are all subtypes of the Function abstract type. We seem to be missing an opportunity for multiple dispatch. Taking the all function from Base as an example, it would be very nice if we could design a type that represents predicate functions rather than letting all fail miserably when an incompatible function is passed.
In order to work around this limitation, let's define a parametric type called PredicateFunction as follows:
struct PredicateFunction{T,S} f::Functionend
The PredicateFunction parametric type just wraps a function f. The type parameters T and S are used to represent the types ...
Read now
Unlock full access