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 u¨: 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.
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.
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
impl Verb
Sourcepub fn ranks(&self) -> [i64; 3]
pub fn ranks(&self) -> [i64; 3]
[monadic, dyadic-left, dyadic-right] ranks governing cell iteration.
Sourcepub fn uses_tolerance(&self) -> bool
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.
Sourcepub fn is_pure(&self) -> bool
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.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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