Skip to main content

Function

The

Function module facilitates creation of imperative style transformation of Streams.

Example

// Create a function to add two integer streams, equivalent to the Javascript function
//
// function f(a, b) {
// let c = a + b;
// return { c };
// }
//
// f(1n, 2n) == 3n

const a = new SourceBuilder("a").value({ value: 1n })
const b = new SourceBuilder("b").value({ value: 2n })

const f = new FunctionBuilder("f")
.input("a", a.outputStream())
.input("b", b.outputStream())
.body(block => block
.let("c", vars => Add(vars.a, vars.b))
.return({ c: vars => vars.c })
)

Classes

  • FunctionBuilder
  • Procedure

On this page