2n: Functional Hacks

+aftr

Pair after.

+aftr first takes gate .a, producing a wet gate. The new wet gate then takes .b, producing the inverted pair of [b a]. This is the inverted version of +fore.

Accepts

.a is a gate, and the sample of +aftr.

.b is a gate, and the sample of (aftr a).

Produces

(pair b a).

Source

++  aftr  |*(a=$-(* *) |*(b=$-(* *) (pair b a)))

Examples

> =a (aftr @ud)

> `(a @t)`['foo' 42]
[p='foo' q=42]

+cork

Compose forward.

Call gate .a, then call gate .b with its product.

This is a wet gate that takes two gates and produces a new gate.

This is the inverse of +corl.

Accepts

.a is a gate.

.b is a gate.

Source

Examples


+corl

Compose backward.

Call gate .b, then call gate .a with its product.

This is a wet gate that takes two gates and produces a new gate.

This is the inverse of +cork.

Accepts

.a is a gate.

.b is a gate.

Source

Examples


+curr

Right curry.

Right-curry a gate, binding the tail of its sample

Accepts

.a is a gate.

.c is a $noun.

Produces

A gate.

Source

Examples


+cury

Curry left.

Curry a gate, binding the head of its sample.

Accepts

.a is a gate.

.b is a $noun.

Produces

A gate.

Source

Examples


+fore

Pair before.

+fore first takes gate .a, producing a wet gate. The new wet gate then takes .b, producing the pair of [a b].

Accepts

.a is a gate, and is the sample of +fore.

.b is a gate, and is the sample of (fore a).

Produces

(pair a b).

Source

Examples


Get head.

Produces the head of a cell.

Accepts

A cell.

Produces

A $noun.

Source

Examples


+same

Identity.

Produces the same value that it was given.

Accepts

A $noun.

Produces

A $noun.

Source

Examples


+succ

Successor.

Increment an $atom.

Accepts

An $atom.

Produces

An $atom.

Source

Examples


+tail

Get tail.

Produces the tail of a cell.

Accepts

A cell.

Produces

A $noun.

Source

Examples


+test

Test for equality.

Checks if a and b are equal, producing a $flag.

Accepts

a is a $noun.

b is a $noun.

Produces

A $flag.

Source

Examples


+lead

Put head.

(lead a) produces a wet gate, then ((lead a) b) produces [a b].

Accepts

a is a $noun, and is the sample of +lead.

b is a $noun, and is the sample of ((lead a) b)

Produces

A cell of [a b].

Source

Examples


+late

Put tail.

(late a) produces a wet gate, then ((late a) b) produces the inverted cell [b a]. This is the inverted version of +lead.

Accepts

a is a $noun, and is the sample of +late.

b is a $noun, and is the sample of (late a).

Produces

A cell of [b a].

Source

Examples


Last updated