Qu

diagram_pipeline

Builtin index · Plotting

result = diagram_pipeline(fn, [file=])

Input: fn, file · Output: result

What it is

Renders a |> pipe chain as a left-to-right chain of labeled boxes, one per stage. fn is a zero-parameter lambda whose body is the pipeline (() := data |> lowpass(fc=1000) |> fft() |> abs()) — a call argument is normally evaluated before any builtin sees it, which would run the pipeline instead of describing it, so the pipeline has to be wrapped so its |> chain survives as an expression. A function name (string) defined the same one-line way (mypipe() := data |> f() |> g()) is also accepted. The source expression should be a variable or parenthesized, not a bare to range literal — 0 to 99 |> f() parses as 0 to (99 |> f()), since |> binds tighter than to.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = diagram_pipeline(fn, [file=])
fn —fn is a zero-parameter lambda whose body is the pipeline (() := data |> lowpass(fc=1000) |> fft() |> abs()) — a call argument is normally evaluated before any builtin sees it, which would run the pipeline instead of describing it, so the pipeline has to be wrapped so its |> chain survives as an expression.
file optionalnot documented yet
result string
Returns the SVG (string).

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

function classify(x)
  if x > 0
    y = 1
  else
    y = -1
  end if
  return y
end function
svg = algorigram("classify")
data = 0 to 99
print(diagram_pipeline(() := data |> lowpass(fc=1000) |> fft() |> abs()))
output
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 830.00 124.00" width="830.00" height="124.00" font-family="Inter, Helvetica, Arial, sans-serif">
<rect x="0" y="0" width="830.00" height="124.00" fill="#ffffff"/>
<line x1="191.00" y1="62.00" x2="233.60" y2="62.00" stroke="#333333" stroke-width="1.4"/>
<polygon points="239.00,62.00 230.00,65.60 230.00,58.40" fill="#333333" stroke="none" stroke-width="1.00" opacity="1"/>
<line x1="391.00" y1="62.00" x2="433.60" y2="62.00" stroke="#333333" stroke-width="1.4"/>
<polygon points="439.00,62.00 430.00,65.60 430.00,58.40" fill="#333333" stroke="none" stroke-width="1.00" opacity="1"/>
<line x1="591.00" y1="62.00" x2="633.60" y2="62.00" stroke="#333333" stroke-width="1.4"/>
<polygon points="639.00,62.00 630.00,65.60 630.00,58.40" fill="#333333" stroke="none" stroke-width="1.00" opacity="1"/>
<rect x="40.00" y="40.00" width="150.00" height="44.00" rx="22" fill="#e6f4ea" stroke="#333333" opacity="1"/>
<text x="115.00" y="66.55" font-size="13" text-anchor="middle" fill="#333333">data</text>
<rect x="240.00" y="40.00" width="150.00" height="44.00" rx="6" fill="#eef3fb" stroke="#333333" opacity="1"/>
<text x="315.00" y="66.55" font-size="13" text-anchor="middle" fill="#333333">lowpass(fc=1000)</text>
<rect x="440.00" y="40.00" width="150.00" height="44.00" rx="6" fill="#eef3fb" stroke="#333333" opacity="1"/>
<text x="515.00" y="66.55" font-size="13" text-anchor="middle" fill="#333333">fft()</text>
    ... 3 more lines

from plotting

How it works

diagram_pipeline(fn, [file=]) (2026-09-18) — a left-to-right box diagram of a |> pipe chain, one box per stage. Unlike algorigram's by-name lookup, the pipeline is usually written INLINE (diagram_pipeline(() := data |> f() |> g())) rather than as a separate named function, so the argument has to reach here as unevaluated syntax -- a call argument is otherwise always eagerly evaluated (see eval_pipe), which would just RUN the pipeline instead of describing it. A lambda is the one existing value shape that carries its body as AST rather than a result (Value::Func's own doc comment), so that is what this reads; a plain function name (string, or an unparenthesized reference) is also accepted and resolved through self.methods, same as algorigram.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.