Vocabulary/curlyrtdot
>> << Down to: Dyad Back to: Vocabulary Thru to: Dictionary
}. y Behead
Rank Infinity -- operates on x and y as a whole, by items of y -- WHY IS THIS IMPORTANT?
Drop the leading item from y
}. 'abc' bc
Related Primitives
Head ({. y), Tail ({: y), Curtail (}: y)
More Information
1. }.y is equivalent to 1 }. y .
Details
0. A video lab has been created for J901 on both the JHS and jqt platforms in the add-ons category of the labs section of J. It includes two videos covering some of these topics as well as interactive opportunities to explore the Head Monadic Verb. The videos can be viewed all at once Behead monadic verb complete video or one at a time Behead monadic verb Part 1 and Behead monadic verb Part 2
1. The rank of }.y is the same as the rank of y unless y is an atom, in which case }.y is an empty list (with the same type as y).
2. If y has no items, }.y is the same as y.
x }. y Drop
Rank 1 _ -- operates on lists of x and the entirety of y -- WHY IS THIS IMPORTANT?
Drop the leading x items of y
if x is negative, the trailing x items are dropped
2 }. 'abcde' cde _2 }. 'abcde' abc
Common uses
1. Remove data from a list
datatosend =: sentlength }. datatosend NB. remove sent data from the send queue 21 }. 'This is sentence 1. This is sentence 2.' This is sentence 2.
2. (With Take {.) Chop out an interval from a list
C/f MID$ in BASIC, substr() in other languages
az=: 'abcdefghijklmnopqrstuvwxyz' 3 {. 5 }. az fgh
Subarray ];.0 is a better way to do this.
3. (With Take {.) Split a list into head and beheaded list
split NB. defined in stdlib as... {. ,&< }. lst=: 'abcde' 2 split lst +--+---+ |ab|cde| +--+---+ 'hd lst'=: split lst hd ; lst +-+----+ |a|bcde| +-+----+
split 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'
Related Primitives
Take (x {. y)
More Information
1. If x is a list, each atom of x specifies a drop operation along the corresponding axis of y
]a =: _4 ]\ 'abcdefghijkl' abcd efgh ijkl _1 1 }. a NB. Drop the last row, and the first column bcd fgh
Details
1. When x is a list, axes of y beyond the length of x are taken in full.
2. If y is an array, x must not be longer than the rank of y
2 3 {. i. 4 |length error
4. If y is an atom, it has leading axes of length 1 added to bring its rank up to the same as the length of x, and then the drop operations are applied.
5. If x is empty then x }. y is the same as y. This is the only way that the result of x }. y can be an atom.
6. In accordance with the description above, values in x that are larger than the length of the corresponding axis cause all atoms to be dropped, leaving an empty array
Infinity (_ or __) are valid values in x for this purpose
$ _ }. i. 4 5 0 5