The APL Orchard

apl.chat ― Learn, teach, ask, code, golf, & discuss usage. See ...
Aug 4, 2021 22:20
@Marshall @dzaima note that this fails for all negatives case: mlochbaum.github.io/BQN/…
Aug 4, 2021 20:54
making scan quadratic seems to be definitely the wrong decision IMO
Aug 4, 2021 20:53
i dunno what that is important tho
Aug 4, 2021 20:53
yea, alternating sums and continued fractions
Aug 4, 2021 20:52
which is what I scan_left_wtf in my mini APL implementation
Aug 4, 2021 20:51
@Adám ideally the scan isnt the scanLeft implement with in O(n^2) with n different foldRights
Aug 4, 2021 20:14
yep
Aug 4, 2021 20:14
that corner case needs to be dealt with
Aug 4, 2021 20:14
oh right
Aug 4, 2021 20:14
which is absolutely gorgeous
Aug 4, 2021 20:14
because max subarray sum is just ⌈´(0⌈+)`
Aug 4, 2021 20:13
lol BQN might just have become my favorite array language
Aug 4, 2021 20:12
can't believe J didn't remedy this
Aug 4, 2021 20:12
@Adám this might be my least favorite thing about APL to date
Aug 4, 2021 20:09
: (
Aug 4, 2021 20:09
that is really really disappointing
Aug 4, 2021 20:09
wow
Aug 4, 2021 20:09
or maybe that is k
Aug 4, 2021 20:08
Yes, and I tried it in J (which I thought had the scan left and it gave the same wrong result)
Aug 4, 2021 20:08
Can some tell me what I am doing wrong / what the correction is?
Aug 4, 2021 20:07
However, in APL I get:
(0⌈+)\¯2 1 ¯3 4 ¯1 2 1 ¯5 4
¯2 0 0 0 0 1 2 1 2
Aug 4, 2021 20:07
I want a plus scan that also floors the intermediate result at 0, so the expected result (in C++) is this: godbolt.org/z/4fjGPoK4a
Aug 2, 2021 22:31
that is amazing
Aug 2, 2021 22:31
holy, i didn't realize ⊆ worked for integer "masks"
Aug 2, 2021 22:27
@Adám that case won't happen for my problem
Aug 2, 2021 22:25
Is that the simplest way? : (
I was hoping something like the PSI combinator (⍥) could be use here ... but it doesn't look like it
(⌈⍥⊃∘⌽)/↓,∘≢⌸1 2 2 6 6 6 6 7 10
Aug 2, 2021 22:21
Say I have a nested array:
↓,∘≢⌸1 2 2 6 6 6 6 7 10
┌───┬───┬───┬───┬────┐
│1 1 │ 2 2│ 6 4│ 7 1│ 10 1│
└───┴───┴───┴───┴────┘
How do I take the "maximum sub array" by only comparing the 2nd element. So the answer would be:
6 4
Jul 27, 2021 23:37
If anyone knows anyone using APLCloud.com, feel free to reply to this tweet: twitter.com/hawkinsw/status/1420145414062448640?s=20
Jul 24, 2021 19:09
ty!
Jul 24, 2021 18:55
Say I want a snippet of code that gives me a 26 element array for letter frequency, i.e.:
{+⌿⍵∘.=⎕C⎕A} 'bcd'
0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
However, if you pass this a one letter string, you get:
{+⌿⍵∘.=⎕C⎕A} 'a'
1
How do I avoid this?
Jul 23, 2021 03:49
Anyone have a shorter (or more idiomatic) way of determining whether a number is a power of two in APL? My solutions: github.com/codereport/LeetCode/blob/master/…
Jul 20, 2021 14:43
ty!!
Jul 20, 2021 14:42
<3
Jul 20, 2021 14:41
What is the solution using adic
Jul 20, 2021 14:31
Can anyone show me the comprehensive solution for this problem? https://leetcode.com/problems/excel-sheet-column-title/
I initially thought it was super easy: convertToTitle ← {⎕A[26(⊥⍣¯1)⍵]}
But this fails for the case of 701 because inverse decode yields 1 0 25 instead of 26 25.
Jun 27, 2021 04:39
{⌈/{+/∧\≠⌽⍵}¨,\⍵} is nice
Jun 27, 2021 04:39
ooh yea, that is awesome
Jun 27, 2021 04:34
> no it is not
Jun 27, 2021 04:34
yea i already confirmed that
Jun 27, 2021 04:24
right, the +\ can be a +/
Jun 27, 2021 04:08
no it is not
Jun 27, 2021 04:07
that is a good observation
Jun 27, 2021 04:07
oh yea
Jun 27, 2021 04:04
so while I am looking for shortest expression, mine also happens to be fastest
Jun 27, 2021 04:03
C is Razetimes
Jun 27, 2021 04:03
A is mine
B is hyper neutrino
Jun 27, 2021 04:03
a s → 4.6E¯6 | 0% ⎕⎕⎕⎕⎕
b s → 3.9E¯5 | +742% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
c s → 1.7E¯5 | +263% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Jun 27, 2021 04:00
But I feel it can definitely be shorter
Jun 27, 2021 04:00
My shortest solution is: {⌈/∊{+\∧\≠⌽⍵}¨,\⌽⍵}
Jun 27, 2021 02:51
also, you can ignore example 4, i dont really care about that corner case