Documentation
API
Calculator

Calculator

The Calculator module allows you to make custom calculators for functions. This is a form that's tied to a specific Squiggle function, where the inputs to the form are passed to that function, and the output of the function gets shown on the bottom.

Calculators can be useful for debugging functions or to present functions to end users.

make

Calculator.make takes in a function, a description, and a list of inputs. The function should take in the same number of arguments as the number of inputs, and the arguments should be of the same type as the default value of the input.

Inputs are created using the Input module. The Input module has a few different functions for creating different types of inputs.

For calculators that take a long time to run, we recommend setting autorun to false. This will create a button that the user can click to run the calculator.

Signatures
Calculator.make({fn: Function, title?: String, description?: String, inputs?: List(Input), autorun?: Bool, sampleCount?: Number}) => Calculator
Calculator.make(Function, params?: {title?: String, description?: String, inputs?: List(Input), autorun?: Bool, sampleCount?: Number}?) => Calculator
Examples