Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Super cool repo! Not sure if you are looking for improvements but your APL can be improved to a 1-liner and it would be the idiomatic way to write the code.
Explanation
Step 1: Use
⍨
as W CombinatorWhenever you have the same argument to a two-argument (dyadic) function APL, you can use
⍨
(the W combinator, known asDUP
in Forth orjoin
in Haskell) to duplicate or copy your argument so you only need to spell it once. Sobecomes
Step 2: Remove unnecessary use of variable
a
Because
a
is only used once now (because of Step 1), you can know make it a 1-liner So:becomes:
Step 3: Use
⍨
as C CombinatorFinally, whenever you need to use parentheses on the left argument to a dyadic function (in this case
~
) and the right argument would not need them, you can use⍨
(the C combinator, known asSWAP
in Forth andflip
in Haskell) to flip the order the dydyic function is applied and then the parentheses are no longer needed. So:becomes:
More info on combinators can be found at: https://combinatorylogic.com/table.html
Once again, really cool project! 🔥