AngouriMath

Navigation

← Back to list of members

Vars

 Property

Summary

Set of unique variables, for example
it extracts `x`, `goose` from (x + 2 * goose) - pi * x

Returns

Set of unique variables excluding mathematical constants
such as pi and e

Example

using System;
using static AngouriMath.MathS;

var (x, y) = Var("x", "y");
var expr1 = Lambda(x, x * 2 + Sin(y * pi));
Console.WriteLine(expr1);
Console.WriteLine("Variables:");
foreach (var var in expr1.Vars)
    Console.WriteLine($"  {var}");
Console.WriteLine("Variables and constants:");
foreach (var var in expr1.VarsAndConsts)
    Console.WriteLine($"  {var}");
Console.WriteLine("Only free variables:");
foreach (var var in expr1.FreeVariables)
    Console.WriteLine($"  {var}");

Prints
x -> x * 2 + sin(y * pi)
Variables:
  x
  y
Variables and constants:
  x
  y
  pi
Only free variables:
  y
  pi

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1534 pages online