Top

Math Identifiers


mIRC Code
+ 2 likes
Please Register to submit score.
Bookmark and Share
Average Score  7.0 (of 1 scores)
Date Added  Jan 30, 2009
Last Updated  Jan 31, 2009
Tags  constants  functions  identifiers  math 

Introduction

I don't know how useful this will be to other people, but I use some of these quite often. Anyways, this has 8 (so far) mathematical identifiers. I will try to add more as requests or as I need them.

It has:
$ispo(N): Returns $true if N is a positive number
$isneg(N): Returns $true if N is a negative number
$average(N1 N2 N3...): Returns the average of the series (Separated by a space)
$max(N1 N2 N3...): Returns maximum number from a series (Separated by a space)
$min(N1 N2 N3...): Returns minimum number from a series (Separated by a space)
$e: Returns the mathematical constant for e. (useful in things like a natural logarithm)
$logb(N,B): Returns logarithm of N with base B
$factor(N): Returns a list of factors for N (must be greater than 3)
$angle(N): Returns a conversion from either degree-radians or radians-degree. The desired output should be used as the property. (e.g. $angle(5pi).degree)

New:
$even(N): Returns true if N is even
$odd(N): Returns true if N is odd.
$nDeriv(N,f(x)): Returns the derivative at N from the equation f(x). Also assuming f(x) is derivable at that point. (e.g. $nDeriv(2,x^2) will give you 4)

I do take requests! So please if you have any more, do share so I can add to this.

Thanks:
korvin

Grab the Code

alias ispos { return $iif($1 > 0,$true,$false) }
alias isneg { return $iif($1 < 0,$true,$false) }
alias average { return $calc(($replace($1-,$chr(32),+)) / $numtok($1,32)) }
alias min { var %x = $numtok($1-,32), %i = 0, %p = $calc(10^308) | while (%i < %x) { inc %i | if ($gettok($1-,%i,32) isnum && $gettok($1-,%i,32) < %p) { %p = $gettok($1-,%i,32) } } | return %p }
alias max { var %x = $numtok($1-,32), %i = 0, %p = 0 | while (%i < %x) { inc %i | if ($gettok($1-,%i,32) isnum && $gettok($1-,%i,32) > %p) { %p = $gettok($1-,%i,32) } } | return %p }
alias e { return 2.71828182845904523536 }
alias even { return $iif(2 // $1,$true,$false) }
alias odd { return $iif(2 \\ $1,$true,$false) }
alias nDeriv { var %x $1, %eq $2- | return $calc(($replace(%eq,x,(%x + .001)) - $replace(%eq,x,(%x - .001))) /((%x + .001) - (%x - .001))) }
 
alias angle {
  if ($1 && $prop) {
    if ($prop == degree) { return $calc($1 * (180/$pi)) }
    if ($prop == radian) { return $calc(($1 * $pi) / 180) }
  }
}
alias logb {
  if ($1 && $2) {
    var %n = $1, %b = $2
    if ((%n !== 0) && (%n > 0) && (%b !== 0) && (%b > 0)) {
      return $calc($log(%n) / $log(%b))
    }
    else { echo -a *$logb Invalid Parametersx | halt }
  }
  else { echo -a *$logb Invalid Parameters | halt }
}
alias factor {
  var %num = $1, %i = 1, %p 
  while (%i < $calc(%num / 2)) {
    if ($istok(%p,$calc(%num / %i),32) == $false) {
      if ($calc(%num % %i) == 0) { 
        var %p = %p %i $calc(%num / %i)
      }
    }
    inc %i
  }
  return $sorttok(%p,32,n)
}
 
 

Comments

  (10)  RSS
Aucun50
Comments: 548
 
mIRC Snippet:  Math Identifiers
Posted on Jan 30, 2009 6:56 pm
Looks neat.
TheImrac
Comments: 64
 
mIRC Snippet:  Math Identifiers
Posted on Jan 30, 2009 7:47 pm
Alot of these could be consolidated.
Code:
alias ispos { return $iif($1 > 0,$true,$false) }
alias isneg { return $iif($1 < 0,$true,$false) }
alias average { return $calc(($replace($1,$chr(32),+)) / $numtok($1,32)) }
alias min { return $gettok($sorttok($1,32,n),1,32) }
alias max { return $gettok($sorttok($1,32,nr),1,32) }

Bluepower10
Comments: 93
 
mIRC Snippet:  Math Identifiers
Posted on Jan 30, 2009 8:00 pm
Is this like an IRC Calculator? Or what is it..?
Firstmate
Comments: 119
 
mIRC Snippet:  Math Identifiers
Posted on Jan 30, 2009 8:06 pm
@bluepower: Not really. Just adds some more identifiers to work with.

@TheImrac: Hmm, I'll update those. I've had those for quite a while so I didn't really update those.

Edit: I realize now why I didn't use something like your $max identifier.
If you do something like $max($ip a 21 13) = $ip
$min($ip a 21 13) = a
TheImrac
Comments: 64
 
mIRC Snippet:  Math Identifiers
Posted on Jan 30, 2009 8:08 pm
Oh BTW technically, 0 could be postive or negative. so you might want to do >= and <=, but I wasn't sure.
Korvin
Comments: 336
 
mIRC Snippet:  Math Identifiers
Posted on Jan 31, 2009 2:25 am
well.. i cant remember if there is an even/odd feature with mirc
Code:
alias even { return $iif($1 // 2,$true,$false) }
alias odd { return $iif($1 \\ 2,$true,$false) }
TheImrac
Comments: 64
 
mIRC Snippet:  Math Identifiers
Posted on Jan 31, 2009 5:07 pm
Korvin, the $1 and 2 should be switched, good addition though:
Code:
alias even { return $iif(2 // $1,$true,$false) }
alias odd { return $iif(2 \\ $1,$true,$false) }
Korvin
Comments: 336
 
mIRC Snippet:  Math Identifiers
Posted on Jan 31, 2009 7:21 pm
mybad =]
Firstmate
Comments: 119
 
mIRC Snippet:  Math Identifiers
Posted on Jan 31, 2009 7:42 pm
Added and fixed. Thanks.

Any other ones?

Added:
$even
$odd
$nDeriv
dashh
Comments: 22
 
mIRC Snippet:  Math Identifiers
Posted on Feb 23, 2009 12:21 pm
$pi <- a hidden id in mirc return the pi number.

3.14159265358979323846

xD

Code:

;- prop's
;         cir ->  with a diameter get a perimeter of a circle (diam)
;         rad -> with a radius get a perimeter of the diameter
;         sqr -> perimeter of a square with a side.
;- no prop -> get any perimeter of a polygon.
;-  - - - - - - - -  by dashh xD

alias perimeter {
  if ( $prop = cir ) { return $calc($1 * $pi) }
  if ( $prop = rad ) { return $calc((2 * $pi) * $1) }
  if ( $prop = sqr ) { return $calc(4 * $1 ) }
  return $calc($replace($remove($1-,+,-),$chr(32),$chr(43)))
}

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom