Battling with all the different scripting methods available, I'm curious to see how people would code this simple function.
$min(N1[,N2][,Nx...])
Returns the lowest value of one or more numbers passed.
I'm looking for two different examples, feel free to post one or both:
Fastest (benchmarked any way you choose)
Cleanest (using what you'd call neat-readable code)
You can use $0, $numtok, $ [ $+ [ %i ], $gettok, WHILE, GOTO, $eval, $+()... whatever you think is fastest or cleanest.
The purpose of this is to gleem some insight on the different basic methods people use.
- Raccoon
PS. Tip on built-in bounds checking:
if ( text < 1 ) == false
if ( text > 1 ) == true
This is useful bounds checking as it will automatically ignore invalid user input, and you can still use $ifmatch if you want to. If you were writing a $max function, you'd have to reverse this because text equates as greater-than a number.
- Raccoon