Functions Index :: A :: ArrayOpFunc

[<< up one level]

Module:

array :: operators

Definition:

ArrayOpFunc(string array, string func, string "args")

Description:

Performs an operation of a function onto all elements of an array (ie func(array[i], ...)) and returns the resulting array.

Arguments:

array: The array who's elements will be the first argument of func.

func: The name of a function that accepts one required argument and possibly an arbitrary number of optional arguments (see args, below).

"args" (Optional, defaults to ""): A string in the form of a function call argument list (ie a comma delimited list of values) containing additional arguments to be passed to the func function.

Notes and conditions on arguments relations:

1] func must accept one required argument with type compatible to array elements' type(s). The argument must be first in func's argument list. An arbitrary number of other (possibly optional) arguments is allowed, but if any of them is not optional it must always be specified in args.

2] The args argument list string can only contain value literals and global names (expressions of them are supported also). Use the String() function to convert local variables to value literals.

Examples:

Function my_y(int x) { return Round(10 + 0.5*x - 0.1*Pow(x, 2)) }

ax = ArrayRange(0, 700, 50)

ay = ax.ArrayOpFunc("my_y")

# filter a set of clips

Function my_f(clip c, float f_hue) {

return c.ConvertToYV12().BilinearResize( \

720, 480).Tweak(hue=f_hue)

}

ac1 = ArrayCreate(AVISource(.1.), AVISource(.2.), ...)

ac2 = ac1.ArrayOpFunc("my_f", "25") # set f_hue to 25

 

[<< top]

 

More examples and in-depth explanation of operator functions can be found at the "Container operators" tutorial.