SmallBASIC icon indicating copy to clipboard operation
SmallBASIC copied to clipboard

min() and max(): Wrong result if parameter is a function

Open Joe7M opened this issue 2 years ago • 1 comments

If you have a function wich returns an array and you want to know the minimum or maximum value of that returned array, then you can't use the function as the parameter for min() or max(). You always have to do an additional step of saving into a variable.

func TestFunction(byref A)
    TestFunction = 5*A
end func

A = seq(1,3,3)

Result1 = min(TestFunction(A))
print Result1  'Prints [5,10,15]

'Workaround
temp = TestFunction(A)
Result2 = min(temp)
print Result2  'Prints 5

Joe7M avatar Feb 28 '22 16:02 Joe7M

I have checked the source code, but I don't think I can fix this.

Joe7M avatar Feb 28 '22 16:02 Joe7M