$avg
+ 0 likes
Please Register to submit score.
| Average Score | 4.0 |
| Scores Submitted | 1 |
| Date Added | Dec 12, 2007 |
| Last Updated | Dec 13, 2007 |
| Tags | average avg number numbers |
Introduction
Syntax: $avg(N.N.N.N,C)
N = numbers
. = delimeter
C = delimeter #
Ex:
$avg(1 5 2 1 6,32) » 3
$avg(2|4|6|8,124) » 5
$avg(1.1.1.1,46) » 1
Enjoy :P
mIRC Snippet:
$avg
Posted on Dec 13, 2007 4:52 pm
Posted on Dec 13, 2007 4:52 pm
this is meant to be an identifier, i cant see people doing /avg 1.2.3.4 46 :P
mIRC Snippet:
$avg
Posted on Dec 13, 2007 4:55 pm
Posted on Dec 13, 2007 4:55 pm
Noutrious, the problem with your code is the $1 and the $2, it would consider your a second number to be $2 and it would consider that the token separator. Also, it would only consider $1. Here is an updated code:
Supports as an identifier and an alias. :)
| Code: |
| alias avg { var %c = $iif($isid,$2,32), %1 = $iif($isid,$1,$1-) $iif($isid,return,echo -a) $calc(($replace($gettok(%1,1-,%c),$chr(%c),+)) / $numtok($gettok(%1,1-,%c),%c)) } |
Supports as an identifier and an alias. :)
mIRC Snippet:
$avg
Posted on Dec 13, 2007 4:58 pm
Posted on Dec 13, 2007 4:58 pm
| Quote: |
| Noutrious, the problem with your code is the $1 and the $2, it would consider your a second number to be $2 and it would consider that the token separator. |
Vague and confusing. ;P
Basically: if I had the string /avg 1 2 3 It would only average 1 separated by $chr(2).
| Quote: |
| Also, it would only consider $1. |
Sorry for the double post.
mIRC Snippet:
$avg
Posted on Dec 13, 2007 5:01 pm
Posted on Dec 13, 2007 5:01 pm
| Quote: |
| this is meant to be an identifier, i cant see people doing /avg 1.2.3.4 46 :P |
mIRC Snippet:
$avg
Posted on Dec 15, 2007 4:00 pm
Posted on Dec 15, 2007 4:00 pm
I would of done something more like this
The code being very small aint anything id care about.
Id rather have proper usage of identifiers...
eg:
$avg(1 2 3 4 5)
$avg(1 2 3 4 5,32)
$avg(1.2.3.4.5,46)
$avg(1 2 3 4,32).n
the $prop will round the value.
My version will depend on you using the correct syntax, since tokenize will return a value even if you didnt specefiy the correct delimiter.
Generally: $avg(string,N)
| Code: |
alias avg { if ($isid) { tokenize $iif($2,$2,32) $1 var %g = $calc(($replacecs($1-,$chr(32),+)) / $numtok($1-,32)) } return $iif($isid,$iif($prop,$round(%g,0),%g),* $avg: invalid parameters) } |
The code being very small aint anything id care about.
Id rather have proper usage of identifiers...
eg:
$avg(1 2 3 4 5)
$avg(1 2 3 4 5,32)
$avg(1.2.3.4.5,46)
$avg(1 2 3 4,32).n
the $prop will round the value.
My version will depend on you using the correct syntax, since tokenize will return a value even if you didnt specefiy the correct delimiter.
Generally: $avg(string,N)





