CSMic.StandardLibrary (2.1.1)

Published 2026-06-30 01:37:22 -05:00 by wagesj45 in wagesj45/cs-mic

Installation

dotnet nuget add source --name wagesj45 --username your_username --password your_token 
dotnet add package --source wagesj45 --version 2.1.1 CSMic.StandardLibrary

About this package

Package Description

CSMic.StandardLibrary

CSMic.StandardLibrary adds optional functions and constants to the core CS-MIC interpreter. It is intended for applications that want end-user convenience functions without having to implement and register each one manually.

This package references CSMic.

dotnet add package CSMic.StandardLibrary

Basic Usage

using CSMic;
using CSMic.StandardLibrary;

var interpreter = new InputInterpreter();
Initializer.InitializeAll(interpreter);

decimal result = interpreter.Interpret("max(10, abs(-12))");
// result == 12

Initializer.InitializeAll registers every standard function and constant. Use a narrower initializer when you only want part of the library:

  • InitializeAllFunctions
  • InitializeConstants
  • InitializeBaseFunctions
  • InitializeAngleFunctions
  • InitializeRoundingFunctions
  • InitializeTrigonometryFunctions
  • InitializeNumberTheoryFunctions
  • InitializeRandomFunctions

Constants

InitializeConstants registers:

  • pi
  • e
  • tau
  • phi
  • goldenratio
  • eurler
  • euler
  • omega

Constants are stored as interpreter variables, so they can be used in normal expressions:

interpreter.Interpret("2 * pi");
interpreter.Interpret("tau / pi");

Functions

Base functions:

  • abs(value)
  • sign(value)
  • min(left, right)
  • max(left, right)
  • sqrt(value)
  • pow(base, exponent)
  • log(value, base)
  • ln(value)
  • lerp(start, end, amount)
  • smoothstep(startEdge, endEdge, value)
  • map(value, oldMinimum, oldMaximum, newMinimum, newMaximum)
  • normalize(value, minimum, maximum)

Angle functions:

  • degrees(radians)
  • radians(degrees)
  • wrapangle(value, minimum, maximum)

Rounding functions:

  • floor(value)
  • ceiling(value)
  • truncate(value)
  • frac(value)
  • round(value, precision)
  • clamp(value, minimum, maximum)

Trigonometry functions:

  • sin(value)
  • cos(value)
  • tan(value)
  • asin(value)
  • acos(value)
  • atan(value)
  • atan2(y, x)

Hyperbolic trigonometry functions:

  • sinh(value)
  • cosh(value)
  • tanh(value)
  • asinh(value)
  • acosh(value)
  • atanh(value)

Number theory functions:

  • fac(value)
  • ncr(n, r)
  • npr(n, r)
  • gcd(left, right)
  • lcm(left, right)
  • fib(index)
  • iseven(value)
  • isodd(value)
  • isint(value)
  • isprime(value)

Random functions:

  • flip()
  • bern(probability)
  • rand()
  • rands(minimum, maximum)
  • randn()
  • randns(minimum, maximum)

Package Role

CSMic.StandardLibrary does not replace the core interpreter. It extends an InputInterpreter instance by registering ICodedFunction implementations and assigning constants. You can combine these functions with your own custom functions on the same interpreter.

Dependencies

ID Version Target Framework
CSMic 2.1.0 .NETStandard2.1
Details
NuGet
2026-06-30 01:37:22 -05:00
3
CSMic.StandardLibrary
35 KiB
Assets (2)
Versions (11) View all
2.1.1 2026-06-30
2.1.0 2026-06-28
2.0.2 2026-06-24
2.0.1 2026-06-24
2.0.0 2026-06-23