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.


Calculator.make: ({
  fn: ...arguments => any,
  title?: string,
  description?: string,
  fields: list<input>,
  autorun?: boolean = true,
  sampleCount?: number,
}) => calculator

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

Calculators require a list of Inputs to be passed in. 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 produce a button that the user can click to run the calculator.



Inputs are now only used for creating calculators. They are created using the Input module.