mkmarek / mx2fn

Small utility CLI to convert math expressions from Maxima to various languages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MX2FN

A small utility program for conversion of math expressions from Maxima to functions in various programming languages.

Sometimes I find myself prototyping math expressions in wxMaxima just to use them later in code. It can then be quite hassle to convert them, so this should make it a bit easier.

I also wanted to try out Haskell, so don't take the code here very seriously.

Usage

Javascript

echo "2*(a+b)^2" | mx2fn --js myFuncName

Will output:

function myFuncName (a, b) {
  return 2.0 * (a + b) ** 2.0;
}

Typescript

echo "2*(a+b)^2" | mx2fn --ts myFuncName

Will output:

function myFuncName (a: number, b: number): number {
  return 2.0 * (a + b) ** 2.0;
}

Rust

echo "2*(a+b)^2" | mx2fn --rs my_func_name

Will output:

fn my_func_name (a: f32, b: f32) -> f32 {
  2.0 * (a + b).powf(2.0)
}

About

Small utility CLI to convert math expressions from Maxima to various languages

License:MIT License


Languages

Language:Haskell 100.0%