This new release includes support for declaring and passing operations as parameters of other operations. The actual operation passed can be a nested operation, an operation of a module, or a lambda expression. (Passing operations as parameters in module instantiations is not yet supported.)
Additional updates in this release:
- optional outputs of an operation are now default initialized to the null value;
- nested operations can now correctly make up-level references to variables of enclosing operations;
- the Univ_String module now includes operations To_Vector and From_Vector for converting a Univ_String to/from a Vector of Univ_Characters; this is useful because Univ_String values are immutable;
- the ZString module includes corresponding operations To_ZVector and From_ZVector for converting to/from a ZVector of Univ_Characters.
interface Mapper<Element_Type is Assignable<>> is func Apply (func Op(Input : Element_Type) -> Element_Type; Vec : Vector<Element_Type>) -> Vector<Element_Type>; // Apply "Op" to each element of vector and return the result end interface Mapper; class Mapper is exports func Apply (func Op(Input : Element_Type) -> Element_Type; Vec : Vector<Element_Type>) -> Vector<Element_Type> is // Apply "Op" to each element of vector and return the result return [for I in 1..Length(Vec) => Op(Vec[I])]; end func Apply; end class Mapper; . . . type Univ_Int_Mapper is Mapper<Univ_Integer>; const Squares : Vector<Univ_Integer> := [for I in 1..100 => I ** 2]; const Triple_Squares : Vector<Univ_Integer> := Univ_Int_Mapper::Apply (lambda (X : Univ_Integer) -> Univ_Integer is (X * 3), Squares); // Triple each element of Squares