#closures #pure #constant #function #composable #operations #combine

functional-closures

composable pure functions with the signature f(T) -> T

6 releases (3 breaking)

0.4.0 Sep 24, 2023
0.3.0 Sep 22, 2023
0.2.0 Sep 20, 2023
0.1.2 Sep 20, 2023

#1685 in Rust patterns

Download history 1/week @ 2024-02-19 8/week @ 2024-02-26 105/week @ 2024-04-01

105 downloads per month
Used in ajkcalc

GPL-3.0-or-later

11KB
303 lines

Function Closures

This crate allows you to create constant functions, and the identity function and combine them with a couple basic operations like follows

// for graphing this is y = x
let y = Function::default();

// f(x) = 3x
let f = Function::new(3.)*Function::default();

// note that Function implements From::<f64> no matter the underlying type
let f = Function::from(3.)*Function::default();

Development

Development is currently very active and many breaking changes are still to come

writen 9/20/23

docs


lib.rs:

This library allows you to do three things. It allows you to Create a function that returns a constant f(x) -> 4, create a function that returns its input f(x) -> x, and then do arithmatic with them and store the result f(x) -> x, g(x) -> 4, h = fg => h ~= 4x then you can do whatever you want with the resulting Arc<Fn(T) -> T> where T is essentially an f64 or other similar type

Dependencies

~470KB