Vocabulary/cou
Jump to navigation
Jump to search
>> << Back to: Vocabulary Thru to: Dictionary
u : v Monad-Dyad Conjunction
Rank -- depends on the ranks of u and v -- WHY IS THIS IMPORTANT?
Derives a dual-valence verb, which executes
- verb u if called monadically
- verb v if called dyadically.
The ranks of the derived verb (u : v) are as you'd expect:
- the monadic rank is the monadic rank of u
- the dyadic rank is the dyadic rank of v.
Conjunction Def (:) has several different uses, requiring several pages to document it
- Vocabulary/cor – A swatch (roadmap) of the different usages of (:) you'll encounter
- Vocabulary/com – the complete formal details of Explicit Definition
- Vocabulary/coa – anatomy of a sample explicit definition
- Vocabulary/cou [THIS PAGE] – how to use (:) to combine monad and dyad valences from separate definitions
- Vocabulary/NounExplicitDefinition – defining a noun as an explicit entity.
Common uses
1. Define a single name with different monadic and dyadic forms
sort =: /:~ : /: NB. monadic, sort y; dyadic, sort x in the order given by y
2. Provide a default value for argument x to let you call a given dyad monadically (i.e. with just a y-argument)
NB. Return the date x days in the future (default 0) getdate =: (0&getdate) : (dyad define) NB. body of dyadic verb here )
3. Create a verb that can't be called with the wrong valence
Executes Cap ([:) in place of the bad valence to force domain error
mp =: +/ . * NB. define a name for matrix product mtx =: i. 2 2 NB. a matrix mp mtx NB. Oops, we called mp monadically, yielding an unexplainable result 2 mp =: [: : (+/ . *) NB. This'll fix it mp mtx |domain error: mp | mp mtx