| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hello, The dyadic iota can be used to find the position of an element in an array. This seems to work well if the array contains numbers or letter. But what if the array contains a word in each element? The iota doesn't seem to be able to tell me the index of the word in the array. Am I missing something? Also, how can I figure out all the positions of a repeated element in the array? Thank you. -pete |
|
#2
| |||
| |||
| "Peter Keller" <psilord@merlin.cs.wisc.edu> wrote in message news:48e82165$0$9895$80265adb@spool.cs.wisc.edu... > Hello, > > The dyadic iota can be used to find the position of an element in an > array. > > This seems to work well if the array contains numbers or letter. But > what > if the array contains a word in each element? The iota doesn't seem > to be able to tell me the index of the word in the array. > > Am I missing something? > > Also, how can I figure out all the positions of a repeated element in > the > array? In Dyalog 8.2.2 : a) 'cat' 'dog' {iota} {enclose} 'dog' 2 nb. {enclose} is needed, otherwise the interpreter reads it as "d o g" and 'cat' 'dog' 'bird' 'mouse' {iota} 'mouse' 'bird' 4 3 nb. no {enclose} is needed here if not there it gives "outside" the array, i.e. 1+{rho} 'cat' 'dog' {iota} {enclose} 'mouse' 3 b) iota gives you only the first occurence in an array 'cat' 'dog' 'dog {iota} {enclose} 'dog' 2 a user defined function is needed to get them all as well as with normal searching for strings in plain text 'cat' 'dog' 'dog' {member} {enclose} 'dog' 0 1 1 you 'll find the positions by shape, enumerate and reduce: 0 1 1 / {iota}{rho} 'cat' 'dog' 'dog' 2 3 in general: (array {member} value) / {iota}{rho} array this is what you'll get with {equal} 'cat' 'dog' 'dog' = {enclose} 'dog' 0 0 0 1 1 1 1 1 1 a strong desire and a long breath is indispensible, but it definitely pays off ... ^/jk |
|
#3
| |||
| |||
| "Jan Karman" <aqxqy@planet.nl (remove the q's)> wrote in message news:48e873fa$0$27217$ba620dc5@text.nova.planet.nl ... > > "Peter Keller" <psilord@merlin.cs.wisc.edu> wrote in message > news:48e82165$0$9895$80265adb@spool.cs.wisc.edu... >> Hello, >> >> The dyadic iota can be used to find the position of an element in an >> array. >> >> This seems to work well if the array contains numbers or letter. But >> what >> if the array contains a word in each element? The iota doesn't seem >> to be able to tell me the index of the word in the array. >> >> Am I missing something? >> >> Also, how can I figure out all the positions of a repeated element in >> the >> array? > > In Dyalog 8.2.2 : > a) > 'cat' 'dog' {iota} {enclose} 'dog' > 2 [...] > > b) > iota gives you only the first occurence in an array > 'cat' 'dog' 'dog {iota} {enclose} 'dog' > 2 > a user defined function is needed to get them all > as well as with normal searching for strings in plain text > [...] Peter, actually it's being called "idiom" and "utility functions" which are "user defined" |
|
#4
| |||
| |||
| Thanks much! That is exactly what I needed. -pete |
|
#5
| |||
| |||
| "Peter Keller" <psilord@merlin.cs.wisc.edu> wrote in message news:48e8e821$0$9895$80265adb@spool.cs.wisc.edu... > Thanks much! That is exactly what I needed. > > -pete A useful LOOKUP utility is: Z {gets} (R,L~R) {iota} L e.g. for updating files a (from e.g. 10 ? 10{rho} 100) 87 45 11 98 25 86 45 3 24 69 86 46 LOOKUP a 6 11 |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.