magic.lambda.math 15.5.0

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package magic.lambda.math --version 15.5.0
NuGet\Install-Package magic.lambda.math -Version 15.5.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="magic.lambda.math" Version="15.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.lambda.math --version 15.5.0
#r "nuget: magic.lambda.math, 15.5.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install magic.lambda.math as a Cake Addin
#addin nuget:?package=magic.lambda.math&version=15.5.0

// Install magic.lambda.math as a Cake Tool
#tool nuget:?package=magic.lambda.math&version=15.5.0

magic.lambda.math - Performing math from Hyperlambda

This project provides math functions to Magic. More specifically, it provides the following slots.

  • [math.multiply] - Multiplication
  • [math.divide] - Division
  • [math.add] - Addition
  • [math.subtract] - Subtraction
  • [math.modulo] - Modulo
  • [math.decrement] - Decrements a node's value, optionally by [step], defaulting to 1
  • [math.increment] - Increments a node's value, optionally by [step], defaulting to 1
  • [math.dot] - Returns the dot product of two lists, where each list must be a double value

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.multiply
   .: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.

Incrementing and decrementing values

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:-
   .:int:2

After executing the above, the result of [.value] will be 3. The default "step" value if ommitted will be 1. Below is an example.

.value:int:5

math.increment:x:-

Notice - You can use any slot invocation to retrieve the step value for the increment/decrement slots, including for instance an invocation to [get-value], or your custom slots. This is dues to that the first argument supplied to these slots will be assumed to be the "step" value you want.

How to use [math.multiply]

This slot multiplies two or more values with each other, and can be given as many arguments as you wish, such as the following illustrates.

.arg:int:5
math.multiply
   get-value:x:@.arg
   .:int:3

It accepts both slot invocations, retrieving some value by invoking a slot, in addition to static values such as illustrated above where we provide the number 3 as one of its values.

How to use [math.divide]

This slot divides two or more values with each other, and can be given as many arguments as you wish, such as the following illustrates.

.arg:int:5
math.divide
   get-value:x:@.arg
   .:int:2

It accepts both slot invocations, retrieving some value by invoking a slot, in addition to static values such as illustrated above where we provide the number 3 as one of its values.

How to use [math.add]

This slot adds two or more values with each other, and can be given as many arguments as you wish, such as the following illustrates.

.arg:int:5
math.add
   get-value:x:@.arg
   .:int:2

How to use [math.subtract]

This slot subtracts two or more values with each other, and can be given as many arguments as you wish, such as the following illustrates.

.arg:int:5
math.subtract
   get-value:x:@.arg
   .:int:2

It accepts both slot invocations, retrieving some value by invoking a slot, in addition to static values such as illustrated above where we provide the number 3 as one of its values.

How to use [math.modulo]

This slot calculates the modulo of two or more values with each other, and can be given as many arguments as you wish, such as the following illustrates.

.arg:int:5
math.modulo
   get-value:x:@.arg
   .:int:2

It accepts both slot invocations, retrieving some value by invoking a slot, in addition to static values such as illustrated above where we provide the number 3 as one of its values.

How to use [math.decrement]

This slot decrements the value of some expression in place, by mutating the value of the node its expression is leading to.

.arg:int:5
math.decrement:x:@.arg

It can optionally be given a [step] argument, such as illustrated below.

.arg:int:5
math.decrement:x:@.arg
   .:int:2

How to use [math.increment]

This slot increments the value of some expression in place, by mutating the value of the node its expression is leading to.

.arg:int:5
math.increment:x:@.arg

It can optionally be given a [step] argument, such as illustrated below.

.arg:int:5
math.increment:x:@.arg
   .:int:2

How to use [math.dot]

This slot returns the dot product of two lists.

.list1
   .:double:0.5
   .:double:0.7
   .:double:0.1
.list2
   .:double:0.56
   .:double:0.89
   .:double:0.33
math.dot
   get-nodes:x:@.list1/*
   get-nodes:x:@.list2/*

This slot is useful for calculating similarities between two different objects in Machine Learning, where each list is an "embedding" or a vector.

Project website for magic.lambda.math

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.

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Coverage
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on magic.lambda.math:

Package Downloads
magic.library

Helper project for Magic to wire up everything easily by simply adding one package, and invoking two simple methods. When using Magic, this is (probably) the only package you should actually add, since this package pulls in everything else you'll need automatically, and wires up everything sanely by default. To use package go to https://polterguy.github.io

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
15.9.0 154 3/24/2023
15.8.2 188 3/20/2023
15.7.0 109 3/6/2023
15.5.0 894 1/28/2023
15.2.0 391 1/18/2023
15.1.0 883 12/28/2022
14.5.7 431 12/13/2022
14.5.5 529 12/6/2022
14.5.1 399 11/23/2022
14.5.0 347 11/18/2022
14.4.5 422 10/22/2022
14.4.1 424 10/22/2022
14.4.0 373 10/17/2022
14.3.1 824 9/12/2022
14.3.0 384 9/10/2022
14.1.3 661 8/7/2022
14.1.2 408 8/7/2022
14.1.1 414 8/7/2022
14.0.14 444 7/26/2022
14.0.12 419 7/24/2022
14.0.11 418 7/23/2022
14.0.10 417 7/23/2022
14.0.9 411 7/23/2022
14.0.8 483 7/17/2022
14.0.5 546 7/11/2022
14.0.4 523 7/6/2022
14.0.3 467 7/2/2022
14.0.2 427 7/2/2022
14.0.0 537 6/25/2022
13.4.0 1,473 5/31/2022
13.3.4 1,039 5/9/2022
13.3.0 670 5/1/2022
13.2.0 823 4/21/2022
13.1.0 716 4/7/2022
13.0.0 485 4/5/2022
11.0.5 994 3/2/2022
11.0.4 512 2/22/2022
11.0.3 529 2/9/2022
11.0.2 541 2/6/2022
11.0.1 506 2/5/2022
10.0.21 512 1/28/2022
10.0.20 504 1/27/2022
10.0.19 505 1/23/2022
10.0.18 488 1/17/2022
10.0.15 670 12/31/2021
10.0.14 379 12/28/2021
10.0.7 990 12/22/2021
10.0.5 507 12/18/2021
9.9.9 1,288 11/29/2021
9.9.3 590 11/9/2021
9.9.2 410 11/4/2021
9.9.0 533 10/30/2021
9.8.9 487 10/29/2021
9.8.7 438 10/27/2021
9.8.6 423 10/27/2021
9.8.5 496 10/26/2021
9.8.0 991 10/20/2021
9.7.9 440 10/19/2021
9.7.8 414 10/19/2021
9.7.5 905 10/14/2021
9.7.0 596 10/9/2021
9.6.6 864 8/14/2021
9.2.0 4,793 5/26/2021
9.1.4 897 4/21/2021
9.1.0 685 4/14/2021
9.0.0 622 4/5/2021
8.9.9 779 3/30/2021
8.9.3 1,223 3/19/2021
8.9.2 767 1/29/2021
8.9.1 758 1/24/2021
8.9.0 865 1/22/2021
8.6.9 2,507 11/8/2020
8.6.6 1,602 11/2/2020
8.6.0 3,224 10/28/2020
8.5.0 1,521 10/23/2020
8.4.0 4,580 10/13/2020
8.3.1 2,156 10/5/2020
8.3.0 977 10/3/2020
8.2.2 1,617 9/26/2020
8.2.1 1,029 9/25/2020
8.2.0 1,062 9/25/2020
8.1.19 2,676 9/21/2020
8.1.18 1,005 9/15/2020
8.1.17 2,793 9/13/2020
8.1.16 450 9/13/2020
8.1.15 1,484 9/12/2020
8.1.11 2,061 9/11/2020
8.1.10 1,069 9/6/2020
8.1.9 1,015 9/3/2020
8.1.8 1,003 9/2/2020
8.1.7 888 8/28/2020
8.1.4 916 8/25/2020
8.1.3 971 8/18/2020
8.1.2 927 8/16/2020
8.1.1 998 8/15/2020
8.1.0 425 8/15/2020
8.0.1 2,141 8/7/2020
8.0.0 942 8/7/2020
7.0.1 1,044 6/28/2020
7.0.0 940 6/28/2020
5.0.0 6,165 2/25/2020
4.0.4 6,507 1/27/2020
4.0.3 996 1/27/2020
4.0.2 1,108 1/16/2020
4.0.1 1,090 1/11/2020
4.0.0 1,046 1/5/2020
3.1.0 5,277 11/10/2019
3.0.0 3,166 10/23/2019
2.0.1 6,842 10/15/2019
2.0.0 1,246 10/13/2019
1.1.8 1,031 10/11/2019
1.1.7 1,015 10/10/2019
1.1.6 426 10/9/2019
1.1.5 414 10/6/2019
1.1.4 416 10/6/2019
1.1.3 412 10/5/2019
1.1.2 431 10/5/2019
1.0.0 482 9/26/2019