From J Wiki
Jump to navigation Jump to search

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

m"n Constant Verb Conjunction

Creates a verb having rank n, that produces the result m for each n-cell of its argument(s).

Information.png For other uses of (") see:

The verb (m"n) has both dyadic and monadic forms. But they all return the constant result m

   always100 =: 100"_
   always100 5 6 7      NB. The argument(s) don't matter with n=_
   3 always100 i. 5 5

Note: In place of the operand (noun) n, you can use any verb v. This is equivalent to setting n equal to the list of ranks of v. See Copy Rank (m"v).

Common Uses

1. Construct an array of the same shape as z, but having 1 for every atom in z

   ]z=: i.2 3
0 1 2
3 4 5
   1"0 z
1 1 1
1 1 1
   z=: 2 3 $ 'abcdef'
   1"0 z
1 1 1
1 1 1

2. Make a "constant" verb out of a given noun, which always returns the noun whatever the value of its y-argument (and optional x-argument)

Such a verb can simplify the creation of a tacit phrase which needs the value of a given noun at some point in the calculation.

   zero=: 0"_
   zero 98 99
   'abc' zero 98 99

3. The standard library verb bind uses Rank (") to attach a constant argument to some other verb, e.g. smoutput .

bind is a

  • Standard Library word(s) residing in the 'z'-locale
  • Defined in the factory script stdlib.ijs which is located in  ~system/main/stdlib.ijs
  • View the definition(s) in a JQt session by entering:  open '~system/main/stdlib.ijs'

The resulting verb ignores its y-argument, and is conventionally called with an empty argument, e.g. ''

This example shows a GUI handler which has yet to be implemented, meanwhile displaying a message in the J session.

   fm_cancel_button=: smoutput bind '>>> Cancel is not implemented'
smoutput@('>>> Cancel is not implemented'"_)

>>> Cancel is not implemented

Related Primitives

Infinity (_:), Constant Functions (0:), (1:), (_1:), (2:), (_2:), ... , (9:), (_9:).

More Information

1. m can be a cyclic gerund as described here. Since gerunds are nouns, cyclic gerunds are an exception to the usage described on this page.

2. See Rank for details on the interpretation of n.

3. The Constant Functions 0: ... 9:, _1: ... _9: and _:, are equivalent to the (")-created verbs: 0"_ ... 9"_, _1"_ ... _9"_ and _"_