Skip to content

Functions #4

Description

@krainboltgreene

Defining a function will return a Function object.
A Function can only take one argument, but that argument can be an Index List or Pair List.

Single line function definitions are expressed thusly:

ƒ(x): x +(1)

For multiple arguments you can express it thusly:

ƒ({x, z}): x +(z)

Defaults can be expressed as such:

ƒ(x: 0): x +(1)

Multiline functions are expressed thusly (Only the last line is returned):

ƒ(x):
  log("Hello, World.")
  x +(1)

Function invocation is expressed thusly:

increment: ƒ(x): x +(1)
increment(1)

For multiple arguments you would express it thusly:

increment: ƒ({value, by}): x +(z)
increment({value: 1, by: 1})

Of course for currying you would express thusly:

ƒ(x): ƒ(y): x +(y)

And currying with multiline is express thusly:

ƒ(x):
  ƒ(y):
    x +(y)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions