> Write a function that: • takes a 2-element character vector left argument where the first element represents the separator character between multiple key/value pairs and the second element represents the separator between the key and the value for each pair. • takes a character vector right argument representing a valid set of key/value pairs (delimited as specified by the left argument). • returns a 2-column matrix where the first column contains the character vector keys of the key/value pairs and the second column contains the character vector values.
Ah, this does the trick without Depth: {⊃(↑≠⊆¨⊢)/(⌽⍺),⊂⊂⍵}
@Richard Yeah it is really useful for making ⎕R be a simple text replacement without fancy regex. (Should have been the default, imo, but whatever).
Ooh, we can use ⌺ to auto-shape into two columns!
Wanna have a go, or shoud I should how?
Wow, looking at submissions from the Competition. Someone found a shorter way (only 3 characters!) to do ~⍤∊⍨ — I'm duly impressed. Any ideas? It is so short you could brute-force it.
And I guess nobody found the the 3-char equivalent of ~⍤∊⍨ so I'll give it away: 3=⍳
Why? Because we're looking up every char in the list of separators, of which there are just 2. If the position is 3, then it wasn't found. So thats a ~∊ with the lookup array on the left.
Unfortunately, it ends up being the same length, as we'll have to commute ⊆ since 3=⊢ isn't a single derived function but rather a 3-train (no pun intended): ⊢⌺(⍪2 2)⊢⊆⍨3=⍳
@RubenVerg Huh, splitting primitives on functionality differences doesn't interact very well with search. Like A2~Dy shows Replicate because the APL2 version is an operator. Maybe some primitives could be marked as encompassing others? So Conjugate->Identity, Replicate->Compress, fn Replicate <-> op Replicate.
Using this in a compound search seems slightly tricky; I guess a primitive just counts as every one it encompasses for ~ only. But I don't know if this works well for a~(b~c).