$max and $min
Posted by poiuy_qwert
Sunday, July 01, 2007
Description: $max and $min return the biggest or smallest number from their parameters respectively.
;;;;;;;;;;;;;;;;;;;;
; $min and $max by poiuy_qwert
;;;;;;;;;;;;;;;;;;;;
; Note: Neither commands have error checking, use valid parameters
;;;;;;;;;;;;;;;;;;;;
; $max(N[,N2,..,NN]) - Return the biggest number from the parameters
; $min(N[,N2,..,NN]) - Return the smallest number from the parameters
; - You can only supple a finite amount of numbers, depending on their sizes. This is becuase you'll get a line too long error
; - Using it with only 1 number is pointless
; - You can also specify multiple numbers in one parameter, seperated by spaces
;;;;;;;;;;;;;;;;;;;;
; Examples:
; $max(-1,0,1,2,3,4,5) = 5
; $max(-1 0 1 2 3 4 5) = 5
; $max(5,-1,0,1 2 3,4) = 5
; $min(-1,0,1,2,3,4,5) = -1
; $min(-1 0 1 2 3 4 5) = -1
; $min(5,-1,0,1 2 3,4) = -1
;;;;;;;;;;;;;;;;;;;;
; Contact:
; - Reply where downloaded
; - /server -m irc.gamesurge.net -j #eval,#EIRCD
;;;;;;;;;;;;;;;;;;;;
alias max {
tokenize 32 $1-
var %a 1,%n $2-,%m $1
while ($gettok(%n,%a,32) != $!) {
if ($v1 > %m) %m = $v1
inc %a
}
return %m
}
alias min {
tokenize 32 $1-
var %a 1,%n $2-,%m $1
while ($gettok(%n,%a,32) != $!) {
if ($v1 < %m) %m = $v1
inc %a
}
return %m
}