Wilang Documentation1.0.0+4

Interactive variables#

Bind a control to a variable#

Write an assignment followed by a control directive. Moving the control changes the bound value and refreshes the cells and plots that depend on it.

Each control needs a named binding, so a standalone numeric expression has no variable to control.

Example
a = 2 // @slider(min=0, max=5, step=0.1)
plot(sin(a * x))

Changes in documentation examples are temporary. In a note, a committed control change updates its assignment and can be undone. Editing the source changes the control definition.

Slider#

@slider(min=...,max=...,step=...) controls a number. Min and max are required, and step is optional. Add tick=true to request ticks.

Example
a=2 // @slider(min=0,max=5,step=0.1)
a^2

Range#

Bind a two-number vector and use @range for two handles. It shares the slider's min, max, optional step, and tick settings.

Example
r=[1,4] // @range(min=0,max=5,step=0.1)
r[2]-r[1]

Stepper#

@stepper(min=...,max=...) changes an integer with plus and minus controls. Use integer bounds and an integer initial value.

Example
n=3 // @stepper(min=0,max=10)
n^2

Switch#

Bind true or false, then use @switch with no arguments.

Example
enabled=true // @switch
enabled ? 10 : 0

Select#

@select(options=[...],style=dropdown) picks from a nonempty list. Use style=segmented for a segmented control.

Options accept the supported scalar strings, numbers, and booleans. Enter an initial value that matches the representation of the option you intend.

Example
mode="small" // @select(options=["small","large"],style=segmented)
mode

Syntax and troubleshooting#

A directive can follow the assignment or sit on its own comment line. Named arguments use = and commas, and completion shows the accepted fields and values. Missing bounds, invalid options, or a mismatched binding can each prevent a useful control from appearing.

Place a bound variable above the cells that read it. Keep slider and animation parameter names separate when they represent different inputs. A whole drag is one undo step, and the transient drag values are separate from the final committed assignment.

Directives and plot options · Animating plots · Variables, globals and REPL