#def directive

#def (aliased #define) binds an identifier with some text. Any time you use the identifier in an expression, the text is substituted.

You can optionally have a defined identifier accept parameters, like a function.

Examples

#def sqrt(x) ${x ^ 0.5}

#def triangle_area_from_sides(a, b, c)
#let s ${(a + b + c) / 2}
${sqrt((s - a) * (s - b) * (s - c))}
#enddef