From J Wiki
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

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.

Information.png Conjunction Def (:) has several different uses, requiring several pages to document it

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
   mp =: [: : (+/ . *)   NB. This'll fix it
   mp mtx
|domain error: mp
|       mp mtx