## 0: y (Constant Function)

0: y  ignores its argument, y (which can therefore have any shape or type), always returning the value 0.

0:  is equivalent to (0"_). Using Rank in this way makes a verb out of a noun (viz. a string or numeric constant).

0:  has sister-primitives _: (=infinity), 1:, 2:, 3:, ... 9: and _1:, _2:, _3:, ... _9:, returning the corresponding integers.

```   YY=: ;:'The quick brown fix is ignored by the lazy dog'
0: YY
0
\$\$ 0: YY
0```

Old J code makes more use of 0: (1: 2: etc.) than up-to-date code. You'll often find in these examples that 0 works just as well. This is because at some stage the syntax of J was altered to treat the train: (NOUN VERB VERB) as meaning (NOUN"_ VERB VERB).

### Common uses

This family of primitive verbs is more useful than it first appears, especially when defining a verb tacitly. Tacit definitions don't like embedded variables and constants. They behave best when built from verbs, adverbs and prepositions. Trains of primitives form hooks and forks: they receive data from arguments x and y in a complex way. Use 0: like a verb, knowing that it will mop up unwanted values presented as arguments and reliably return a scalar 0.

Example: pad the ends of a numeric vector with zeros.

```   pad=: 0: , ] , 0:
0 0 1 2 3 4 5 6 7 8 0```

Note: 0 will work in place of the first 0: here, but not the second. This is because the train of verbs applied to argument y:

`   (a b c d e) y`

is equivalent to the explicit expression:

`   (a y) b ((c y) d (e y))`

from which you can see that 0: (standing in for a and e here) is called with an unwanted argument y which must be lost.

Example: avoid an accidental vector constant, when what you want is to parameterize an adverb or a conjunction:

```   0 1} i.6      NB. Try to amend 1{i.6 to zero
|rank error
|       0 1}i.6
0 1:} i.6
0 0 2 3 4 5```

Example: Pascal's Triangle.

```   bc =:  < 0&(, + ,~) 1:     NB. binary coeff
bc 6
1 0  0  0 0 0
1 1  0  0 0 0
1 2  1  0 0 0
1 3  3  1 0 0
1 4  6  4 1 0
1 5 10 10 5 1```

This example won't work if 1 is used in place of 1:.

## x 0: y (Constant Function)

x 0: y ignores its arguments, x and y (which can therefore have any shape or type), always returning the value 0.

```   XX=: ;:'The quick brown fox is ignored by the lazy dog'
YY=: i. 5 3
XX 0: YY
0
\$\$ XX 0: YY
0```

### Common uses

See above: 0: y

Vocabulary/zeroco (last edited 2011-03-17 14:39:07 by IanClark)