FunVec2T Conversion (FuncInt32, Int32, T to FunVec2T)
2-dimensional jagged collection with optional lengths, values of which are determined by the
getValue function.
static int GetDistance(int from, int to) { return Math.Abs(to - from); }
FunVec2<int> distances = new(GetDistance);
Assert(distances.Length1 == int.MaxValue); // since length1 is omitted
Assert(distances.Length2(100) == int.MaxValue); // since length2 is omitted
Assert(distances[1, 2] == 1);
Assert(distances[10, 5] == 5);
FunVec2<int> distancesUpTo4 = new(GetDistance, Some(4));
Assert(distancesUpTo4.Length1 == 4);
Assert(distancesUpTo4[3, 1] == 2);
// Assert(distancesUpTo4[5, 1] == 4); // out-of-bounds, throws!
Assert(distancesUpTo4.GetOrNone(5, 1).IsNone);
FunVec2<int> distancesUpTo4 = new(GetDistance, Some(4), Some<Func<int, int>>(i => 2*i));
Assert(distancesUpTo4.Length1 == 4);
Assert(distancesUpTo4.Length2(2) == 4);
Assert(distancesUpTo4[3, 5] == 2);
// Assert(distancesUpTo4[3, 6] == 3); // out-of-bounds, throws!
// Assert(distancesUpTo4[4, 0] == 4); // out-of-bounds, throws!
Assert(distancesUpTo4.GetOrNone(3, 6).IsNone); // since Length2(3) is 6, index 6 is out of bounds.
Assert(distancesUpTo4.GetOrNone(4, 0).IsNone); // since Length1 is 4, index 4 is out of bounds.
Namespace: Orx.Fun.FunVecAssembly: Orx.Fun.FunVec (in Orx.Fun.FunVec.dll) Version: 1.0.0
public static implicit operator FunVec2<T> (
Func<int, int, T> getValueByIndex
)
- getValueByIndex FuncInt32, Int32, T
FunVec2T