When you apply a function to some piece of data, functions will often test to be sure you are giving it the right kind. For example, many math functions will require that you provide a number, so that the answer is actually valid. But, with Version 0.13, there is a twist. If you give any one of a dozen or so math functions a list of numbers, it will return the result of applying that function to all list elements. And in fact, it will work with a nested list as well. So:
Print(Ln(3.5) )
Print(Ln([1,3,4,6,6,7,8]))
Produces values:
1.25276
[0, 1.09861, 1.38629, 1.79176, 1.79176, 1.94591, 2.07944]
This is actually an old feature that worked five or eight version ago, but it fell by the wayside at some point and was never re-implemented. In fact, some functions that take TWO arguments will work as well, recursing on the first argument. So
LogN(1,10)
LogN([1,10,100],10)
Produce results:
0
[0,1,2]
Importantly, you don't provide a list for the second argument.
This only currently works for a set of math-related functions:
Log10
Log2
Ln
Exp
Sqrt
Tan
Sin
Cos
ATan
ASin
ACos
DegToRad
RadToDeg
Round
Floor
Ceiling
AbsFloor
Sign
Abs
And a handful of two-parameter functions:
LogN Pow NthRoot
In the future, it could be enabled for more functions (let me know!), and there may be a way to make the functionality available through a new PEBL function; but all this would take some careful thought and planning.
So, keep an eye out for additional new functions that are available in PEBL 0.13
No comments:
Post a Comment