Simple Calc alias's

By Zaff on Mar 09, 2009

Not sure if these have been posted but you can use these like this

$add(2,2) returns 4
$div(10,2) returns 5
$sub(2,1) returns 1
$mult(5,5) returns 25
$expo(2,2) returns 4

If I missed any, let me know and ill add them, Again its not much.

alias add return $calc($1 + $2)
alias div return $calc($1 / $2)
alias sub return $calc($1 - $2)
alias mult return $calc($1 * $2)
alias expo return $calc($1 ^ $2)


Sign in to comment.
Firstmate   -  Mar 10, 2009

Even better than Korvin's second one (nice change to kirbys, ha)

alias cal return $calc($replace($1-,$chr(32),$replace($prop,m,*,a,+,s,-,e,^,d,/)))
Korvin   -  Mar 09, 2009


alias add return $calc($replace($1-,$chr(32),+))

mine actually does what kirbys is supposed to do.

even better

alias cal return $calc($replace($1-,$chr(32),$$iif($prop = a,+,$iif($prop = m,*,$iif($prop = d,/,$iif($prop = s,-,$iif($prop = e,^)))))))

usage $cal(1,2,3,4).[m,a,s,e,d]
letters stand for obvious things.

PuNkTuReD   -  Mar 09, 2009


nice alias kirby

Aucun50   -  Mar 09, 2009

"I've devised a rather simple script for $add." simple eh? LOL

Kirby   -  Mar 09, 2009

Those identifiers only deal with two numbers. How about taking that further so you can perform calculations with multiple numbers?
I've devised a rather simple script for $add.

alias add { var %x 1 | while (%x <= $numtok($1-,32)) { var %y $calc($gettok($1-,%x,32) + %y) | inc %x } | return %y }

Usage: $add(1,2,3,4,5) returns 15
I think you can make better use with the other identifiers now, if you want, by using what I supplied as a guide.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.