Vocabulary/edot
>> << Down to: Dyad Back to: Vocabulary Thru to: Dictionary
e. y Raze In
Rank Infinity -- operates on x and y as a whole, by items of y -- WHY IS THIS IMPORTANT?
Returns a Boolean table comparing each box of y (a list of boxed atoms) against each atom in ;y (the Raze of y).
There is one row for each atom in y, and one column for each item in ;y
] y=: 'alpha' ; 'bravo' ; 'charlie' +-----+-----+-------+ |alpha|bravo|charlie| +-----+-----+-------+ ;y alphabravocharlie e.y 1 1 1 1 1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 0 0 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 0 1 1 0 1 1 0 0 1 1 1 1 1 1 1
Common Uses
1. To create an n-by-n identity matrix
e. i. 4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
More Information
1. e. y is identical to (;y)&e.@> y. If any of the items of y contain arrays of rank 2 or higher, the result is complicated.
2. e. y uses tolerant comparison. Use e.!.0 in place of e. for exact comparison.
3. Analysis: The following expression attaches captions to (e.y) which explain it:
2 2 $ '' ; (,' ',.~;y) ; (>y) ; (e.y) +-------+----------------------------------+ | |a l p h a b r a v o c h a r l i e | +-------+----------------------------------+ |alpha |1 1 1 1 1 0 0 1 0 0 0 1 1 0 1 0 0 | |bravo |1 0 0 0 1 1 1 1 1 1 0 0 1 1 0 0 0 | |charlie|1 1 0 1 1 0 1 1 0 0 1 1 1 1 1 1 1 | +-------+----------------------------------+
1 at the top-left denotes that the block <'alpha' contains 'a' -- and so forth.
x e. y Member (In)
Rank Infinity -- operates on x and y as a whole, by items of y -- WHY IS THIS IMPORTANT?
Returns 1 if item x is in array y, otherwise 0.
'a' e. 'alpha' NB. yes, the atom: 'a' is in the literal list 1 'd' e. 'alpha' NB. no, the atom: 'd' is NOT in 'alpha' 0 'a' e. 1 2 3 NB. 'a' is not in the numeric list (Note: no error signalled) 0
y is treated as a list of its items, and each cell of x that has the same rank as an item of y is checked to see if it matches an item of y. The result has one atom for each such cell of x.
Common Uses
1. Test if a given atom is in a given list
'b' e. 'abracadabra' 1 'x' e. 'abracadabra' 0
2. Test multiple atoms at once
'bz' e. 'abracadabra' 1 0
3. Test for the presence of certain characters in input strings
if=: 3 : 'if. y do. ''TRUE'' else. ''FALSE'' end.' NB. utility to test if.-conditions FILENAME=: '/Users/myusername/Desktop/myfile.txt' if +./ ('\/' e. FILENAME) do. NB. does FILENAME have a path?
The preferred form (see below) is '\/' +./@:e. FILENAME
4. The items can be boxes, in which case the contents must match... exactly
]y =. ;: 'There is a tide in the affairs of men' NB. A boxed list +-----+--+-+----+--+---+-------+--+---+ |There|is|a|tide|in|the|affairs|of|men| +-----+--+-+----+--+---+-------+--+---+ (<'the') e. y NB. contains 'the' 1 (<'a') e. y NB. What? Doesn't contain <'a' ?? 0 (<,'a') e. y NB. No, it contains <,'a' 1
5. The item to search for may be a list, if the search space is a table.
The entire list must match
] t=: >'alpha' ; 'bravo' ; 'charlie' alpha bravo charlie $t NB. It's 3x7, with spaces added for fill 3 7 'alpha' e. t NB. e. doesn't find 'alpha' because it's only part of t 0 'alpha ' e. t 1 'charlie' e. t NB. 'charlie' stretches across the whole width of t, so no need to pad it 1
More Information
1. x e. y is a member of the i.-family.
2. The internal rank of x e. y uses items whose rank is the rank of items of y.
3. If riy is the rank of an item of y, the shape of the result is (-riy)}.$x
4. If x and y are of different types, or if their items couldn't possibly match because of differing shapes, no error is signaled: each search simply fails to match.
5. x e. y is equivalent to (#y) ~: y i. x.
Use These Combinations
Combinations using x e. y that have exceptionally good performance include those shown in Searching and Matching Items: Fast List Operations (FLOs) and Searching and Matching Items: Precomputed searches, as well as the following:
What it does Type;
Precisions;
RanksSyntax Variants;
Restrictions
Benefits;
Bug Warnings
Operations on a flattened array x ({ ,) y
x ({. ,) y
x (}. ,) y
x (e. ,) y
f/@, y
(f is any verb)or @: & &: in place of @ Avoids copying the array to compute (,y)