Skip to guide content
Graph Studio by NUM8ERSStudent guideOpen calculator
LEARN · TRY · EXPLORE

Expressions & functions12 / 68

Recursion & function values

Advanced definitions can call themselves, refer to another function or build a new named rule from existing ones.

Find it

Expressions

Named function values and aliases used in a graph.
Named function values and aliases used in a graph.Click to enlarge ↗

Try it step by step

  1. For recursion, start with a terminating base case.
  2. Define the recursive branch so that each call approaches that base case.
  3. Test a small input before trying a larger one.
  4. Use a named lambda or alias when you want to reuse a rule as a function value.

Examples to try

Each card is one input. For definitions, enter the cards in order. Formula-only cards belong in the tool described above.

Define a named function value.

Returns 9.

Reuse the rule under another name.

Compose the rules: apply f first, then g. Here is 16.

A rule with two inputs.

Fix the first input at 2. Now is 5.

A recursive factorial rule: the first branch stops the recursion. Try , which is 120.

Options explained

Recursive definitions
Bounded direct, mutual and typed recursive definitions are supported. Missing termination or excessive work causes a diagnostic.
Named lambda
A definition such as makes f a named function.
Aliases / composition
An alias reuses a function. compose combines compatible named functions.
Partial application
Supported named partial applications fix some arguments of a function.
Limits
Recursion depth is at most 64 and work budgets can stop earlier. Arbitrary runtime closures and functions stored in lists are outside the supported model.

Screenshot

Copy this text

Your browser could not copy automatically. Select and copy the text below.