These were a few identifiers I just came up with. Enjoy :-).
$avrg: Find the average of a given set of numbers (seperated by a space)
Usage: $avrg(Numbers)
Example: $avrg(10 2 5 3)
-> Returns "5"
$qdrc: Quadratic Equation
Usage: $qdrc(a,b,c)
Example: $qdrc(1,4,1)
-> Returns: "-0.267949 -3.732051"
*Note: The .x1 and .x2 properties can be used as well, e.g. $qdrc(1,4,1).x1 returns "-0.267949"
$opst: Get the opposite of a number
Usage: $opst(Number)
Example: $opst(372)
-> Returns "-372"
/*
The text from line 1 to line 23 are comments. They may be deleted safely.
Math Aliases by vSkyzv
http://www.hawkee.com/
$avrg: Find the average of a given set of numbers (seperated by a space)
Usage: $avrg(Numbers)
Example: $avrg(10 2 5 3)
-> Returns "5"
$qdrc: Quadratic Equation
Usage: $qdrc(a,b,c)
Example: $qdrc(1,4,1)
-> Returns: "-0.267949 -3.732051"
*Note: The .x1 and .x2 properties can be used as well, e.g. $qdrc(1,4,1).x1 returns "-0.267949"
$opst: Get the opposite of a number
Usage: $opst(Number)
Example: $opst(372)
-> Returns "-372"
*/
alias avrg { return $calc(($replace($1,$chr(32),+)) / $numtok($1,32)) }
alias qdrc {
var %dscrm = $calc(($2 * $2) - 4($1 * $3)), %x1 = $calc(($opst($2) + $sqrt(%dscrm)) / 2($1)), %x2 = $calc(($opst($2) - $sqrt(%dscrm)) / 2($1))
if (!$prop) { return %x1 %x2 }
elseif ($prop == x1) { return %x1 }
elseif ($prop == x2) { return %x2 }
}
alias opst { return $iif($1 > 0,$calc($1 - $calc($1 * 2)),$abs($1)) }
@Purplebeard, You could do something like this:
on *:TEXT:!avarage*:#:{
if ($2 == $null) { notice $nick You must enter a string of numbers to return an avarage! | HALT }
if ($3 == $null) && ($2 isnum) { notice $nick The avarage of a single number is itself! | HALT }
if ($0 > 100) { notice $nick Please limit your list to 100 values! | HALT }
var %total $0
var %temp 2
while (%temp <= %total) {
if ($eval($ $+ %temp,2) isnum) { var %string %string $v1 }
else { notice $nick All values must be numbers | HALT }
inc %temp }
notice $nick The avarage of these numbers is: $avrg(%string)
}
}
Notice, I wrote this in the comment box, it is untested. You may need to make some modifications. For example, the if statement in the while loop.... you may need to change the second value in the $eval identifier (It is currently two, which I believe should work, but I haven't worked with it much.)
Best of luck!
can any of you guys help me, i'm trying to turn this script into a remote for a Bot (added to a !calc)
this is what i have so far:
on :text:!calc:#: {
if ( $2 == $null) { /msg $chan Put a Equation after !calc please }
elseif ( $3 == $null ) { /msg $chan $2 = $calc( $2 ) }
elseif ( $2 == avrg ) { /msg $chan The Average of your numbers is $calc(($replace($2,$chr(32),+)) / $numtok($2,32)) }
elseif ( $2 == Opp ) { /msg $chan $calc($1 - $calc($2 2)),$abs($2)) }
elseif ( $2 == qdrc ) { var %dscrm = $calc(($3 $3) - 4($2 * $4)), %x1 = $calc(($opst($2) + $sqrt(%dscrm)) / 2($1)), %x2 = $calc(($opst($3) - $sqrt(%dscrm)) / 2($2))
if (!$prop) { return %x1 %x2 }
elseif ($prop == x1) { return %x1 }
elseif ($prop == x2) { return %x2 }
} }
all help is SUPER appreciated