Vocabulary/coco

From J Wiki
Jump to: navigation, search

>> <<   Back to: Vocabulary Thru to: Dictionary


u :: v u :: n Adverse Conjunction

Rank Infinity -- operates on [x and] y as a whole -- WHY IS THIS IMPORTANT?



Provides an alternative verb v to be run if the verb u fails
If the right operand of :: is a noun n, it is equivalent to the constant verb (n"_) which ignores its arguments and produces the result n.

   (+/ % #) :: 'bad data'   i.8       NB. average the integers 0 to 7 inclusive
3.5

   (+/ % #) :: 'bad data'   'string'  NB. cannot add characters this way.
bad data

Whitespace must separate verbA from ::

Otherwise J thinks the :: inflects verbA:: .

   verbA:: verbB
|spelling error
|   verbA:: verbB
|   ^

   verbA :: verbB
verbA ::verbB

   (+/ % #):: ('bad data'"_)   i.8
|spelling error
|   (+/ % #):: ('bad data'"_)   i.8
|          ^

Common uses

1. Adverse can simplify opening a file or database for append access

   Open :: Create filename

2. Default ;:y to y in the case that noun y causes an error with (;:).

Used e.g. in: erase (~system/main/stdlib.ijs) and coinsert (~system/main/colib.ijs).-~

erase and coinsert are

  • Standard Library word(s) residing in the 'z'-locale.
  • Defined in the factory script stdlib.ijs.
  • View definition(s) by entering in the J session:  open'stdlib'

   ;: '''alpha'
|open quote
|   'alpha
|   ^
|       ;:'''alpha'

   (;: :: ]) '''alpha'
'alpha

3. Close existing form (no longer needed), or continue (without error) if no existing form is present

wd :: 0: 'psel fm; pclose'

wd (the standard GUI interface) is a cover verb for the Foreign (11!:0) in J6.02