brazilofmux / tinymux

TinyMUX
www.tinymux.org
48 stars 21 forks source link

Add lmath() or equivalent #553

Open brazilofmux opened 9 years ago

brazilofmux commented 9 years ago

Original issue 550 created by brazilofmux on 2008-12-23T07:45:38.000Z:

There is a generic way of list-i-fying math functions in PennMUSH and Rhost.

brazilofmux commented 9 years ago

Comment #1 originally posted by brazilofmux on 2008-12-23T07:48:39.000Z:

Current functionality of RhostMUSH's strmath() function, which is functionally equivalent of this:

strmath()
Function: strmath(,,[,[,[,[,]]]])

The strmath function is used to apply math to the entire string. Numbers in the string are modified based on the math chosen applied to the number. You may specify optional input and output seperators. You may also specify the word to start () the math on and how many words () after the start you wish to use. If no math is specified, '+' is used as a default.

Valid math arguments are:

mrsenile commented 6 years ago

Actually, it'd be more similar to strfunc, not strmath :)

STRFUNC() Function: strfunc(<function>, <list of arguments>[,<delim>])

The strfunc (string function) function is used to transform a string of arguments into separate identified arguments and feed them into the specified function. If you do not have access to the function or if you give the target function an invalid number of arguments, an error message will be displayed.

This in effect will turn any function in the game into a string oriented function. Thus the name, 'strfunc'.

Examples: > say add(1,2,3,4) You say "10" > say strfunc(add,1 2 3 4) You say "10" > say strfunc(add,1@2@3@4,@) You say "10" > say hastype(me,player) You say "1" > say strfunc(hastype,me player) You say "1" > say switch(add(1,1),2,match,1,nope,0,nope,nope) You say "match" > say strfunc(switch,add(1,1) 2 match 1 nope 0 nope nope) You say "match"

See Also: strmath(), ladd(), lsub(), ldiv(), lmul()