The APL Orchard

apl.chat ― Learn, teach, ask, code, golf, & discuss usage. See ...
May 22, 2021 15:36
noice
May 22, 2021 15:36
      {=/⍵:1⋄∨/0=⍵:0⋄>/⍵:0⋄+/(1,⊃⍵)×(∇⍵-1),∇0 ¯1+⍵}⍤1⊢↑⍳2⍴7
1 1 1 1  1  1   1
0 1 3 7 15 31  63
0 0 1 6 25 90 301
0 0 0 1 10 65 350
0 0 0 0  1 15 140
0 0 0 0  0  1  21
0 0 0 0  0  0   1
May 22, 2021 15:06
I see, thanks
May 22, 2021 14:56
But {+/⊃⍵}⍤0⊢⍳2⍴7 works fine
May 22, 2021 14:55
{+/⍵}⍤0⊢⍳2⍴7 doesn't seem to work
May 22, 2021 14:54
Does rank work over something like ⍳2⍴7 which I think is an array of ragged arrays?
May 22, 2021 14:51
This is probably hackier than necessary, but I think it works {=/⍵:1⋄∨/0=⍵:0⋄>/⍵:0⋄+/(1,(⊃⍵))×(∇¯1+⍵),∇0 ¯1+⍵} with ⍵≡2⍴k n for S(n, k)
May 22, 2021 14:45
Maybe I shouldn't do ⍺ and ⍵ if I want to make a triangle of S(n, k)
May 22, 2021 14:43
Hm, I'm writing a dfn for Stirling numbers of the second kind, which, after the base cases, is +/1 ⍺×((⍺-1)∇(⍵-1)),⍺∇⍵-1
May 22, 2021 14:41
Assuming both ⍺ and ⍵ are numeric scalars
May 22, 2021 14:40
Quick question how to do something like (⍺-1)∇⍵-1 in a dfn but something like ∇ (over) ¯1+⍺ ⍵ maybe
May 18, 2021 18:29
Oh yeah that makes a lot of sense, thanks!
May 18, 2021 18:13
Oh thanks
May 18, 2021 18:01
Crossposting my question from the Discord server: How does this algorithm work? I'm having trouble parsing the train codegolf.stackexchange.com/a/158379/80214 The code: {0∊≢¨⍵:≢∊⍵⋄⌊/(≢.↑+∘∇↓¨)∘⍵¨1↓,⍳2 2} and the train: (≢.↑+∘∇↓¨)
May 17, 2021 16:29
@xpqz Node 3 isn't connected to anything else yet
May 17, 2021 16:10
Found it! An essay on partitions code.jsoftware.com/wiki/Essays/…
May 17, 2021 15:57
inner_p=: 3 : 0
   if. y<.0 do.
     0
   elseif. 0 < y { memo do.
     y { memo
   else.
     y { memo =: memo y}~ -/+/inner_p"0 y+(2%~]*1-3*])(],:-)1+i.y
   end.
   )

partition=: 3 : 0
   memo=:1,y$0
   inner_p y
   )
May 17, 2021 15:57
Got it!
May 17, 2021 15:50
Oh it's < not <.
May 17, 2021 15:44
inner_p=: 3 : 0
   if. y<.0 do.
     0
   elseif. 0 <. y { memo do.
     y { memo
   else.
     z =. -/+/"1 inner_p"0 y+(2%~]*1-3*])(],:-)>:i.y
     memo =: z y} memo
     z
   end.
   )

partition=: 3 : 0
   memo=:1,y$0
   inner_p y
   )
May 17, 2021 15:43
Alright so the following J code doesn't work
May 17, 2021 15:21
Yeah, I figured. I put some golfs in my code like ⍵≤0:⍵=0 but that's not as readable I suppose
May 17, 2021 15:17
@rak1507 You can shorten ⍵-(2÷⍨⊢×1-⍨3×⊢) to ⍵+(2÷⍨⊢×1-3×⊢)
May 17, 2021 15:16
And I'm not sure how J does recursion either
May 17, 2021 15:16
Not sure how to do p[⍵]←... in J
May 17, 2021 15:16
I've seen complaints about modified assignments to arrays and how they're handled (there is a massive bug, if I remember the complaints correctly), but at least Dyalog APL appears to have them
May 17, 2021 15:15
The longer I work on this J translation, the nicer I think Dyalog APL is XD
May 17, 2021 14:34
@rak1507 Ooh that's very nice, and it might work better with my attempted J translation
May 17, 2021 14:04
Trying to convert it to J and I have no idea where the editor is XD
May 17, 2021 14:03
Let me try to write it in APL-like syntax
May 17, 2021 14:02
@rak1507 Yeah, that's where I got the inspiration too
May 17, 2021 14:02
@rak1507 Oh that's interesting. Let me take a look
May 17, 2021 13:40
First and most importantly, the purpose of this chatroom is to educate, first about the APL languages and descendants, and then about the historical context. But seeing as the main purpose is to educate, and not to squabble, please refrain from arguing so heatedly in this channel. The trouble is not the matter of the discussion, but the overtaking of the channel such that it is awkward to change the subject onto lighter matters of education as I have wanted to do now for an hour. I do not ask that you do not argue, merely that you both do so with awareness of the forum in which you are doin
May 17, 2021 12:13
Oh no I mean the number-theoretic partition function
May 17, 2021 12:10
      partition 100000
DOMAIN ERROR
partition[8] ⊢m,←-/+⌿p⍤0⊢z
                   ∧
⍝ Found another limit
May 17, 2021 12:07
      partition 6353
¯1.508503541E82
      partition 6352
3.466844567E81
May 17, 2021 12:07
I do seem to have a bug
May 17, 2021 12:04
Thinking of writing in k←⌈6÷⍨1+0.5*⍨1+24×⍵ and using ⍳k at end of z instead of the entirety of ⍳⍵ which adds a lot of extra lookups
May 17, 2021 12:00
partition←{
    ⍵≤0:⍵=0
    m←⍬
    p←{
        ⍵≤0:⍵=0
        ⍵≤≢m:m[⍵]
        z←⍵+{2÷⍨⍵-3×⍵×⍵}⍤0⊢↑(⊢,-)⊂⍳⍵
        ⊢m,←-/+⌿p⍤0⊢z
    }
    r←p⍤0⊢⍳⍵
    m[⍵]
}
May 17, 2021 12:00
Wrote the partition function in APL again, this time with memoization
May 14, 2021 15:38
I thought I missed a release
May 14, 2021 15:38
... Oh that'll do it
May 14, 2021 15:37
Mostly rhetorical, just means I get to change versions
May 14, 2021 15:36
How is it that I downloaded the Dyalog IDE all of 7 days ago and it gave me 18.0
May 14, 2021 10:56
It premieres at 4 am for me
May 13, 2021 22:06
This requires a great deal more thought than I am currently able to give it
May 13, 2021 22:04
What I'm not sure about is whether the best syntax to keep is Haskell's currying from the function on the left to the right (or from right to left?) until it's taken enough arguments, or to keep to APL's on one argument on the left, one argument on the right.
May 13, 2021 22:02
Am I off in my understanding that operators are functions that take other functions as parameters? Because Haskell does that just fine, if so