Skip to main content

Verb

Enum Verb 

Source
pub enum Verb {
Show 36 variants Prim(Prim), Rank(Box<Verb>, [i64; 3]), Reduce(Box<Verb>), Windowed(Box<Verb>, WindowKind), Commute(Box<Verb>), PowerN(Box<Verb>, Power), Fork(Box<Verb>, Box<Verb>, Box<Verb>), NounFork(Array, Box<Verb>, Box<Verb>), Hook(Box<Verb>, Box<Verb>), Atop(Box<Verb>, Box<Verb>), Compose(Box<Verb>, Box<Verb>), BondLeft(Array, Box<Verb>), BondRight(Box<Verb>, Array), Each(Box<Verb>, Enclose), Fit(Box<Verb>, f64), Amend(Array), AmendVerb(Box<Verb>), ShiftFill(Array), Memo(Box<Verb>, MemoCache), Level { u: Box<Verb>, level: i64, spread: bool, }, Characteristics(Box<Verb>), Before(Box<Verb>, Box<Verb>), UserDerived { def: Box<Verb>, alpha: Box<Verb>, omega: Option<Box<Verb>>, }, KeyPairs(Box<Verb>), Key(Box<Verb>), Cut(Box<Verb>, i64), PowerV(Box<Verb>, Box<Verb>), PowerUntil(Box<Verb>, Box<Verb>), AlongAxis(Box<Verb>, usize), Explicit(Arc<ExplicitDef>), SelfRef, Named(String), WithObverse(Box<Verb>, Box<Verb>), Agenda(Vec<Verb>, Box<Verb>), Adverse(Box<Verb>, Box<Verb>), Beside(Box<Verb>, Box<Verb>),
}
Expand description

A verb: primitive or derived. Language-agnostic; frontends decide which combinations their syntax produces (e.g. APL +/ becomes Rank(Reduce(+), [1,1,1]) — reduce the last axis).

Variants§

§

Prim(Prim)

§

Rank(Box<Verb>, [i64; 3])

Apply the verb to cells of the given ranks (J ", APL ).

§

Reduce(Box<Verb>)

Insert the verb between items, folding right to left (J /, APL ).

§

Windowed(Box<Verb>, WindowKind)

Apply the verb to runs of consecutive items (J \ and \., APL \ and ). The valence chooses the runs; see WindowKind.

§

Commute(Box<Verb>)

J u~, APL u⍨: monad u~ y = y u y; dyad x u~ y = y u x.

§

PowerN(Box<Verb>, Power)

J u^:n, APL u⍣n: apply the verb n times, or to convergence.

§

Fork(Box<Verb>, Box<Verb>, Box<Verb>)

(f g h) y = (f y) g (h y); x (f g h) y = (x f y) g (x h y).

§

NounFork(Array, Box<Verb>, Box<Verb>)

(n g h) y = n g (h y); x (n g h) y = n g (x h y).

§

Hook(Box<Verb>, Box<Verb>)

(f g) y = y f (g y); x (f g) y = x f (g y). (J hook)

§

Atop(Box<Verb>, Box<Verb>)

f@:g / [: f g: monad f (g y); dyad f (x g y).

§

Compose(Box<Verb>, Box<Verb>)

f&:g: monad f (g y); dyad (g x) f (g y). J’s & is this wrapped in Verb::Rank at g’s monadic rank; &: is this on its own.

§

BondLeft(Array, Box<Verb>)

m&v: the noun bonded as the left argument — monad m v y. J gives a bond no dyadic valence at all.

§

BondRight(Box<Verb>, Array)

u&n: the noun bonded as the right argument — monad y u n.

§

Each(Box<Verb>, Enclose)

J u&.> and APL : open each box, apply u, put the result back in a box. Cell rank 0 on every side, so the frames pair as usual.

§

Fit(Box<Verb>, f64)

J u!.n: apply u with the comparison tolerance replaced by n.

§

Amend(Array)

J x m} y: y with the items at the indices m replaced by x.

§

AmendVerb(Box<Verb>)

J u}: the same amend, with the indices computed rather than written — u} y is (u y)} y and x u} y is x (x u y)} y.

§

ShiftFill(Array)

J |.!.f: shift instead of rotate, the vacated positions taking the fill f.

§

Memo(Box<Verb>, MemoCache)

J u M.: u, with the results it has already computed kept and returned again for the same arguments. The cache belongs to this derived verb, so it lives exactly as long as the program does.

§

Level

J u L: n and u S: n: apply u to every subarray at boxing level n or below. L: puts each result back where its operand was; S: spreads them into the items of one array.

Fields

§level: i64
§spread: bool
§

Characteristics(Box<Verb>)

J u b.: answers questions about u rather than applying it. 0 asks for its three ranks.

§

Before(Box<Verb>, Box<Verb>)

APL f⍛g (before): g’s LEFT argument is prepared by f — monad (f y) g y, dyad (f x) g y. The mirror of Verb::Beside.

§

UserDerived

APL f OP and f OP g: a dfn that mentions ⍺⍺ or ⍵⍵ is an OPERATOR, and this is that operator with its operands supplied. They are bound under those two names for as long as the body runs.

Fields

§def: Box<Verb>
§alpha: Box<Verb>
§omega: Option<Box<Verb>>
§

KeyPairs(Box<Verb>)

APL f⌸ (key, Dyalog): the major cells are grouped by value, and f is applied to each key and the group that shares it. Monadically the group is the positions the key occupies; dyadically it is the items of the right argument at those positions.

§

Key(Box<Verb>)

J u/.: the key dyadically (u over each group of items sharing a key), the oblique monadically (u over each anti-diagonal).

§

Cut(Box<Verb>, i64)

J u;.n: cut — u over the intervals a fret marks out.

§

PowerV(Box<Verb>, Box<Verb>)

J u^:v: v’s value at the arguments is the number of applications.

§

PowerUntil(Box<Verb>, Box<Verb>)

APL f⍣g: apply f until new g old holds.

§

AlongAxis(Box<Verb>, usize)

APL f[k]: f along axis k. The axis is brought to the front, f applies to the leading axis, and a result of the argument’s own rank has the axis put back where it was.

§

Explicit(Arc<ExplicitDef>)

An explicit definition: a body of sentences run with the arguments bound to names. J’s 3 : '…', 4 : '…' and {{ … }}, APL’s {…} and -defined functions.

§

SelfRef

J $:, APL : the definition lexically containing the reference, found at run time as the innermost one then running.

§

Named(String)

A verb named earlier in the program, looked up when it is applied so that a definition can call itself by its own name.

§

WithObverse(Box<Verb>, Box<Verb>)

J u :. v: u, with v declared to be its obverse. The declaration is what obverse answers with; applying the verb applies u.

§

Agenda(Vec<Verb>, Box<Verb>)

J m@.v: agenda — v’s value at the arguments picks which of the gerund’s verbs to apply.

§

Adverse(Box<Verb>, Box<Verb>)

J u :: v: adverse — apply u, and if the language refuses it, apply v to the same arguments instead. A gap in libjay is not an error the program may handle, and goes straight through.

§

Beside(Box<Verb>, Box<Verb>)

APL f∘g (beside): monad f (g y), dyad x f (g y). g prepares the right argument and the left one arrives untouched, which is what separates it from (this crate’s Verb::Compose).

Implementations§

Source§

impl Verb

Source

pub fn ranks(&self) -> [i64; 3]

[monadic, dyadic-left, dyadic-right] ranks governing cell iteration.

Source

pub fn name(&self) -> String

Name for diagnostics, e.g. +/"1.

Source

pub fn uses_tolerance(&self) -> bool

True when the verb’s meaning depends on the comparison tolerance — the comparisons, the searches that use them, and the two roundings. u!.n is only the tolerance conjunction for these; on anything else J’s !. specifies a fill instead, which is a separate feature.

Source

pub fn is_pure(&self) -> bool

True when applying this verb does nothing beyond producing its result. Output (echo, ⎕←) is the only effect a verb can have, and only a pure verb may have its cells run out of order on several threads. Deliberately conservative: a new effect must be added here.

Source

pub fn monad(&self, y: &Array, ctx: &mut Ctx<'_>, span: Span) -> Result<Array>

Full monadic application including rank/frame machinery.

Source

pub fn dyad( &self, x: &Array, y: &Array, ctx: &mut Ctx<'_>, span: Span, ) -> Result<Array>

Full dyadic application including rank/frame/agreement machinery.

Trait Implementations§

Source§

impl Clone for Verb

Source§

fn clone(&self) -> Verb

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Verb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Verb

§

impl !UnwindSafe for Verb

§

impl Freeze for Verb

§

impl Send for Verb

§

impl Sync for Verb

§

impl Unpin for Verb

§

impl UnsafeUnpin for Verb

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,