An Open Source Application Generator
This project provides math functions to Magic. More specifically, it provides the following slots.
All of the above besides the two last slots can be given any number of arguments, including as its value, and will treat the first argument as the “base”, and performing the rest of the arguments self assigning the base as it proceeds. For instance, the following code will first divide 100 by 4, then divide that result by 5 again, resulting in 5.
math.divide:int:100 :int:4 :int:5
The value of the above [math.divide] node after evaluating the above Hyperlambda will be 5.
All of the above slots will also evaluate the children collection as a lambda, before starting the actual math function, allowing you to recursively raise signals to retrieve values that are supposed to be mathematically handled somehow. This allows you to recursively nest math operations, such as for instance.
.one:int:5 .two:int:2 math.multiple .:int:3 math.add get-value:x:@.one get-value:x:@.two
The above of course will first add 5 and 2, then multiple the result of that with 3, resulting in 21.
The above [math.increment] and [math.decrement] slots, will instead of yielding a result, inline modify the value of the node(s) it is pointing to, assuming its value is an expression. In addition these two slots can take an optional [step] argument, allowing you to declare how much the incrementation/decrementation process should add/reduce the original node’s value by. Below is an example that decrements the value found in its expression by 2.
.value:int:5 math.decrement:x:- step:int:2
After executing the above, the result of [.value] will be 3.
The modulo slot divides its argument(s) by its base, and returns the remainder.
.int:17 math.modulo:x:- .:int:10
The above results in 7.
The source code for this repository can be found at github.com/polterguy/magic.lambda.math, and you can provide feedback, provide bug reports, etc at the same place.
This project is the copyright(c) 2020-2021 of Thomas Hansen email@example.com, and is licensed under the terms of the LGPL version 3, as published by the Free Software Foundation. See the enclosed LICENSE file for details.