FunVec1T(FuncInt32, T, Opt`1Int32) Constructor

1-dimensional vector with optional length, values of which are determined by the getValueByIndex function.
C#
static int Factorial(int number) { .. }

FunVec1<int> factorials = new(Factorial);
Assert(factorials.Length1 == int.MaxValue); // since length1 is omitted
Assert(factorials[3] == 6);
Assert(factorials[5] == 120);

FunVec1<int> factorialsUpTo4 = new(Factorial, Some(4));
Assert(factorialsUpTo4.Length1 == 4);
Assert(factorialsUpTo4[3] == 6);
// Assert(factorialsUpTo4[5] == 120); // out-of-bounds, throws!
Assert(factorialsUpTo4.Get(5).IsNone);

Definition

Namespace: Orx.Fun.FunVec
Assembly: Orx.Fun.FunVec (in Orx.Fun.FunVec.dll) Version: 1.0.0
C#
public FunVec1(
	Func<int, T> getValueByIndex,
	Opt<int> length1 = default
)

Parameters

getValueByIndex  FuncInt32, T
Function (index -> value) that returns the value of the element at the given index-th position.
length1  OptInt32  (Optional)
Optional length of the jagged array; will default to None (int.MaxValue) when omitted.

See Also