# Vocabulary/commaco

>>
<< ` `
Down to: Dyad ` `
Back to: Vocabulary
Thru to: Dictionary

`,: y`Itemize

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

Creates an array whose rank is 1 more than the rank of `y`, and whose single Item|item is `y` .

The shape of ` ,:y ` is always `(1 , $y)`.

- if
`y`is an atom,`,: y`is a 1-atom list - if
`y`is a list,`,: y`is a 1-row table - if
`y`is a table,`,: y`is a 1-plane brick - etc.

y=: 'alpha' NB. list ==> one-row table alpha ,: y alpha $ ,: y 1 5 $ ,: i. 3 4 NB. table => one-layer brick 1 3 4

### Common uses

1. When building a 2-matrix row-by-row, ensures that it begins as a 2-matrix

z=: 'alpha' ]z=: z , 'bravo' alphabravo NB. --not the result we wanted. z=: ,:'alpha' ]z=: z , 'bravo' alpha bravo ]z=: z , 'charlie' alpha bravo charlie

2. To create an array whose items are copies of `y`

]y =: 2 3 $ 'abcdef' NB. A 2x3 table abc def ]z =: 2 2$ ,: y NB. z is a 2x2 array of 2x3 tables. Note ,: abc def abc def abc def abc def $z NB. 2x2 array of 2x3 tables 2 2 2 3

`x ,: y`Laminate

Rank Infinity *-- operates on x and y as a whole, after adjusting the smaller operand --*
WHY IS THIS IMPORTANT?

Creates a two-item array (with rank at least 2)
whose first item comes from `x` and whose second item comes from `y` .

x=: 'alpha' y=: 'bravo' ] z=: x ,: y NB. x is item 0, y is item 1 alpha bravo $z 2 5 #z 2

### Common uses

'alpha' , 'bravo' ,: 'charlie' alpha bravo charlie

**Note:** in J's right-to-left execution order, the first 2 strings to be combined are `'bravo'` and `'charlie'` -- which need `(,:)`. For additional rows you must use `(,)`.

### Related Primitives

Append (`x , y`),
Append Items (`x ,. y`),
Raze (`; y`)

### Details

`x ,: y` loosely follows the detailed description of `; y`, except that atomic arguments are handled differently.

1. If `x` and `y` are both atoms, they are converted to lists so that they become the rows of a 1-column table

1 ,: 2 1 2

2. If only one of `x` and `y` is an atom, it is **replicated** to the shape of the other before the two are joined

6 ,: 1 2 3 NB. 6 is replicated before joining 6 6 6 1 2 3

Note that a scalar argument laminated to an empty one will disappear

0 ,: '' NB. 0 is 'replicated' to become an empty list $ 0 ,: '' 2 0

The replication of an atom to the shape of the other occurs **after** the type and precision of the result are decided.
This means that the atom counts as a "non-empty argument" for that decision, even though it will not contribute atoms to the final result.

3!:0 (0 ,: '') NB. Boolean atom has its say 1 3!:0 ((0$0) ,: '') NB. Boolean empty has lower priority 2

3. After atoms are extended or replicated, they are brought to the same rank by adding leading axes of length 1,
and to the same shape by adding fill, which can be specified by ` !.f`

(i. 2 3) ,: (i. 3 2) 0 1 2 3 4 5 0 0 0 0 1 0 2 3 0 4 5 0 (i. 2 3) ,:!.99 (i. 4) 0 1 2 99 3 4 5 99 0 1 2 3 99 99 99 99

### Oddities

1. The J Dictionary says that the fill atom can be empty, but the J7 engine does not support this.

### Use These Combinations

Combinations using `x ,: y` that have exceptionally good performance include:

**What it does****Type;**

**Precisions;**

Ranks**Syntax****Variants;**

**Restrictions****Benefits;**

**Bug Warnings**Composite item the `x`arrays are the same precision and not boxed, extended integer, or rational`name =: i} x0,x1,...,xm,:xn``=.`in place of`=:`

If there are 2

`x's`,`i`may be Boolean or integer, but if more than 2`x's`,`i`must be integeravoids catenation and lamination Composite item in place `b`is Boolean;`x`and`name`are the same precision and not boxed, extended integer, or rational`name =. b} x,:name`

`name =. b} name,: x``=:`in place of`=.`

Must be same

`name`either sideavoids making a new copy of `name`