Skip to content

fn

a function, which can be passed around like any value

1
# fn: a function
2
|x| x * 2<fn>
3
# a typed function
4
fn(x: int) -> int { x * 2 }<fn>
Example outputCtrl+Enter to run
1
# f(x) calls it
2
(|x| x * 2)(4)8
Example outputCtrl+Enter to run
  • doc attach a description to your own function, shown by help
  • plot a graph of the function f from x = a to x = b, drawn with braille dots, 60 characters wide and 16 lines tall
  • root an x where f(x) = 0
  • deriv the slope of f at x (its derivative), estimated from f just either side of x, or with n its nth derivative
  • minimize the x between lo and hi where f is smallest
  • maximize the x between lo and hi where f is largest
  • limit what f(x) approaches as x approaches a, which can be inf or -inf
  • integrate the area under f between a and b (its integral), where a and b can be inf or -inf
  • elasticity how many percent demand changes per 1% change in price, for demand f at price
  • timeit how long it takes to call f, which takes no arguments
  • animate play an animation in the terminal at fps frames a second

Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.