pure

pure, contextual keyword

The pure modifier declares a user-defined function as a side-effect-free mapping over its arguments.

Examples

def pure diskSurface(r: number) with
  return 3.1416 * r * r

show scalar "Area" with diskSurface(2)

This outputs the following scalar:

Area
12.5664
table Audience = with
  [| as Folks |]
  [| "Ladies" |]
  [| "Gentlemen" |]
  [| "Mr. President" |]

def pure hello(a: text) with
  return "Hello \{a}"

show table "Greetings" with
  hello(Audience.Folks) as "Hello"

This outputs the following table:

Hello
Hello Ladies
Hello Gentlemen
Hello Mr. President

Remarks

A pure function has no side effects and its arguments cannot be assigned. When a vector is passed as an argument, the function is applied line by line and returns a vector.

See also

User Contributed Notes
0 notes + add a note