4 ms·
< grades upwards: for each element, the element of the returned array is its position if the array is sorted. x: 10?A:"abcdefghijklmnopqrstuvwxyz" x
by icen 7y ago
< grades upwards: for each element, the element of the returned array is its position if the array is sorted.
x: 10?A:"abcdefghijklmnopqrstuvwxyz"
x
"ysyselacwl"
+`x`y`z!(x;<x;<<x)
x y z
--- - -
"y" 6 8
"s" 7 5
"y" 4 9
"s" 5 6
"e" 9 2
"l" 1 3
"a" 3 0
"c" 8 1
"w" 0 7
"l" 2 4
So <x gives a sort index, <<x tells you how far each element is from the minimum in that sort index
- uryga 7y agoyeah, i figured it out eventually. since you seem knowledgeable about K, would you mind taking a look at my second comment in this thread (about inverting permutations) and seeing if it makes sense? thanks!
- i_don_t_know 7y agoI still don’t understand what the numbers in column y mean. I understand column z and that’s also what grade up is returning in John Earnest’s oK: x:“baced“ <x 1 0 2 4 3 <<x 1 0 2 4 3 That is, for example, when sorting, the item at position 1 in the original string (“a”) moves to position 0 (the beginning of the sorted string). So in the end you get “abcde”. What does column y mean? If I sort the original with it, I get “wllaysysce”. Has this changed between versions of K?
- i_don_t_know 7y agoNevermind. I've figured it out with the help of the reference manual at http://www.nsl.com/k/k2/k295/kreflite.pdf http://www.nsl.com/k/k2/k295/kreflite.pdf. I knew it was a permutation but I applied it incorrectly.