bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exercise 2019/02


From: Kacper Gutowski
Subject: Re: exercise 2019/02
Date: Wed, 15 Apr 2020 01:22:19 +0200

On Tue, Apr 14, 2020 at 05:40:26PM +0200, Otto Diesenbacher-Reinmüller wrote:
2 making the grade
(...)
Any hint?

I think all those ranges are mostly a distraction, because it's nowhere said you need to handle out-of-range arguments in any graceful way. I would start with ⍵>table[;2] which is a binary vector for scalar ⍵, and then go from that.

My solution would be {table[⎕IO++/⍵∘.>table[;2];3]}.
Few years ago I would try to use ¨ too (I'm still relatively new to APL myself), but it kinda feels like writing C in APL and outer product is really more natural here when you think about it.

Alternatively you could use dyadic ⍳ to find the first 0 in said vector, which then leads to something like {table[(⍵∘.>table[;2])⍳⍤1⊢0;3]}.

-k



reply via email to

[Prev in Thread] Current Thread [Next in Thread]