2k: Queue Logic

+to

Queue operations.

Container arm for +que operation arms. The contained arms inherit .a, its sample +que.

Accepts

.a is a tree.

Source

++  to
  =|  a=(tree)  ::  (qeu)
  |@

Discussion

+tree is the generic tree-shape mold. Maps, sets, and +ques all share that shape, but they put their elements in different places and have different interfaces. +to is the interface core for +qeu; it's not generic across all the different containers that use +tree.


+apt:to

Check correctness.

Test whether +que .a is correctly ordered, producing a $flag.

Accepts

.a is a +que.

Produces

A $flag.

Source

Examples


+bal:to

Balance.

Vertically rebalances +que .a.

Accepts

.a is a +qeu.

Produces

A +qeu.

Source

Examples


+dep:to

Maximum Depth.

Produces the maximum depth of leaves (.r.a and .l.a) in +que .a.

Accepts

.a is a +que.

Produces

An $atom.

Source

Examples


+gas:to

Push +list.

Push all elements of +list .b into the +que .a.

Accepts

.a is a +que, and is the sample of +to.

.b is a +list.

Produces

A +que.

Source

Examples


+get:to

Head-tail pair.

Produces the head and tail +que of .a.

Accepts

.a is a +que.

Produces

A cell of the last element in .a along with the rest of +que .a.

Source

Examples


+nap:to

Remove head.

Removes the head of +que .a, producing the resulting +que.

Accepts

.a is a +que.

Produces

A +que.

Source

Examples


+nip:to

Removes the root of +que .a, producing the resulting +que.

Accepts

.a is a +que.

Produces

A +que.

Source

Examples


+put:to

Insert.

Accept $noun .b and adds to +que .a as the head, producing the resulting +que.

Accepts

.a is a +que, and is the sample of +to.

.b is a $noun.

Produces

A +que.

Source

Examples


+tap:to

Queue to +list.

Produces +que .a as a +list from front to back.

Accepts

.a is a +que.

Produces

A +list.

Source

Examples


+top:to

Produce head.

Produces the head of +que .a as a +unit.

Accepts

.a is a +que.

Produces

A unit.

Source

Examples

Discussion

An empty +que has no head.


Last updated