« first day (2403 days earlier)      last day (246 days later) » 

4:58 AM
@user1344155 just adding you to the write list. One second
should be done
 
👍
 
 
10 hours later…
2:51 PM
@JamesHeslip Long time no see!
Welcome to APL Quest 2021-2! Today's quest is Index-Of Modified:
> Write a function that behaves like the APL index-of function R←X⍳Y except that it returns 0 instead of 1+≢X for elements of Y not found in X.
 
{m×(≢⍺)≥m←⍺⍳⍵}
(⍳×≢⍤⊣≥⍳)
 
Nice ones.
 
couldn't make the 1st tacit
 
We can do that together.
The first thing would be to eliminate the assignment, instead expressing the left end as a function in terms of m and
So we need to give it two arguments, and m, that is ⊣(...)⍳
We could start by writing the inner function as a dfn: {⍵×(≢⍺)≥⍵}
@Richard Want to try converting this to tacit?
 
yes
 
3:06 PM
Btw, there's another approach too. Here's a hint: We need a function (primitive!) that preserves all values 1…n but returns 0 for 1+n.
@user1202474 Hi Bill, if you want to participate here, please email access@apl.chat.
 
(⊢×≢∘⊣)≥⊢
 
Isn't this like {(⍵×≢⍵)≥⍵}?
We wanted {⍵×(≢⍺)≥⍵}
@Finn Welcome back!
 
corrected
 
@Richard Isn't this like {(⍵×≢⍺)≥⍵}?
 
@Adám ⍳|⍨1+≢⍤⊣
 
3:10 PM
Exactly!
It might be clearer to write {1+≢⍺}|⍳
 
@Adám yes, so tacit help told me (:
 
I think this is quite simple:
{⍵×(≢⍺)≥⍵}
 ⊢×(≢⊣)≥⊢
 ⊢× ≢⍤⊣≥⊢
 
yes, you were just a little to fast
 
Sorry about that.
So we could write ⊣(⊢×≢⍤⊣≥⊢)⍳ and now we can see how your two solutions are equivalent:
⊣(⊢×≢⍤⊣≥⊢)⍳
  ⍳×≢⍤⊣≥⍳
 
Not related question, just anoying, but the / of ≢ is always shifted one space apart from the ≡ in my browser.
@Adám nice!
 
3:18 PM
@Richard That's because you're using a Chromium browser, and Stack Exchange chat has an unsuitable font stack. You can fix it by injecting styling to alter the font, or by using a non-Chromium browser.
 
@Adám for another time then, dont want to polute the Quest
 
No worries. I should add a section on APL Wiki for how to fix this.
Add-on problem: What if the arguments were just vectors? Could we write a simpler solution?
 
@Adám the trick is that ⍳ is now the right argument so only has to be computed once.
 
Exactly.
 
@Adám something with 'APL' ∘.= 'DYALOG' ?
 
3:27 PM
No. I mean, you could, but that's very wasteful, and won't be short either.
Split the problem into two: We have which gives us the indices, but we need another function which tells us if we should make the index be 0, i.e. if the element was found at all.
 
based on the original solution or something different?
ok
 
It is related to the previous, but much simpler, almost just a primitive.
 
@Adám ∊⍨×⍳
 
Yup. Well done.
Notice how this strongly illustrates that and have contradicting order of arguments.
 
@Adám Is there a way to extend this solution to rank > 1?
 
3:31 PM
@Adám yes, which is especialy for ⍳ confusing, at least for me
 
@Finn No, unfortunately has a design flaw: it is equivalent to ∊∘,
@Richard Yes, because inherits its argument order from the common use in mathematics.
Maybe we should add a ϶ which doesn't ravel its argument…
 
Would removing the ravel break existing code?
 
Absolutely.
 
@Adám thanks
 
E.g. X/⍨~X∊∘.×⍨X←1↓⍳N for computing primes would break:
      X/⍨~X∊∘.×⍨X←1↓⍳15
2 3 5 7 11 13
      X/⍨~X(⊢∘≢≥⍳⍨)∘.×⍨X←1↓⍳15
2 3 4 5 6 7 8 9 10 11 12 13 14 15
Anyway, I think we've exhausted this one. See you next week for 2021-3: Multiplicity.
 
3:40 PM
thanks!
 
@Adám Thank you!
 
Thanks for participating!
 

« first day (2403 days earlier)      last day (246 days later) »