« first day (1221 days earlier)      last day (1441 days later) » 

5:31 PM
@dzaima Whoops sorry, I also had to go! Thanks a bunch for that final explanation the 'why' of the operator all makes sense!!
@dzaima Even better! The 'why not' of it! I feel silly now, it seems so painfully obvious in retrospect, now that you point that out!
 
@dzaima To be fair, , kind of does that (output rank > input ranks) for scalars - 1,1 but i consider that an anomaly and a couple times considered removing it from my impl
 
The one thing left is just the 'how'... Of the three solutions so far for row-wise addition to a matrix, I still think yours is the most elegant. That is, your 'blank_starter←0 n⍴⍬' over my blank_starter←⍬ and then appending to a vector + post-processing with 'm n ⍴ vector'. And also moreso than the ⍪ ⍪[0.5] ⍪ ⍪ ⍪ ⍪ ... inconsistent mess of mine.
However, I'm creating the matrix (from scratch) in a recursive function. So by the time you're in it, the blank-starter should be made. However, ideally, nothing outside should concern itself with the shape of the array being produced within the recursive function. Which is why, although generally elegant, the ⍴ 0 n solution is still not ideal.
It requires whatever came before to know something about the shape of the matrix that the recursive function is about to create... Wondering if there's any way to not need to leak out the information about the matrix anywhere except where it's created
 
@AviF.S. Can the function be called in a way that results in it returning 0 rows? If so, some place needs to make a 0×n matrix either way
 
In other words, starter←0 n⍴⍬ ends up not being much better, in this particular usage case, than m n ⍴ result. It just means pre-processing rather than post-processing...
@dzaima Sorry? Am confused...
@dzaima Hmmm, super interesting! Didn't realize that. Writing an implementation really forces you to learn the language inside & out!
 
@AviF.S. i guess as the alternative m n⍴res also handles the case when you end up with 0 rows added ((r1⍪[0.5]r2) ⍪ r3 can't), so it doesn't really matter
 
5:47 PM
@dzaima Ah, I see what you mean! No, I'm not worried about mutant matrices!
 
@AviF.S. yep. It's why i still attribute writing my impl as the biggest source of my APL knowledge
 
And I'm still far more inclined to use yours over mine. Would just be nice if there was some way of not needing information outside of the recursive creator!
Does that count as encapsulation? Can I call it that?
@dzaima Makes sense! Definitely on my impossibly long, imaginary bucket list. Hopefully one day!
 
RGS
@AviF.S. A basic one is fairly simple as you can see in my blog (the site is down atm) XD
 
Also general chat-room question: When one has a general question about something, addressed to no-one in particular, at some point when no one is active: Is it reasonable to an @all/@everyone type thing? And is there even such a feature on SE?
 
RGS
@AviF.S. sometimes I write "@all" / see someone writing it, but it doesn't really ping anyone...
It is just an obvious cue that you want someone to answer
 
5:52 PM
@RGS Oh no! If you can still find the link, does that mean you can still access the HTML to send?
@RGS Haha, yeah! I more meant if there was a functional way to do it, lol :p
 
RGS
@AviF.S. I know the URL by heart, but you can also cheat and read the "source file" directly from GH
 
Also, people have a magical way of appearing out of nowhere whenever someone says something. Just Murphy's Law, or are you guys somehow getting notifications even when not pinged?
@RGS Ah, great point!
 
@AviF.S. i'd just post it without any fanciness. If applicable, a leading CMQ (chat mini question) or CMP (chat mini poll) is also good
 
@dzaima Whoopsies! I'm very lost...
 
@AviF.S. I always have a tab of this room open, and switching to it (usually ctrl+2 in chrome) is my 14th most common keystroke :p
 
5:56 PM
Without any fanciness? CMQ? CMP?
@dzaima Haha, too funny! So you're just constantly checking? No way to get nots unless pinged?
 
@AviF.S. i'd just post the message without addressing anyone. the descriptions of CMQ and CMP are in the parenthesis.. (you can search for them to see what they're used for)
 
@dzaima Alright! And I did see the parentheticals, lol. Just still didn't know what they meant or how to create them in SE. Google is a good idea though!
 
@AviF.S. or just the search function in the room
 
@dzaima 'Fraid I'm lost again...
Command+F?
 
@AviF.S. search box on the top-right of page (on the web version)
 
6:01 PM
Darn, the things I miss!! Thanks :)
 
@AviF.S. i wouldn't want that personally. Chromium (or maybe i was using vivaldi back then? idk) used to show a circle whenever there was any new message (especially useful pinned tabs, which these chat rooms are for me) but that doesn't happen now. Maybe worth making a userscript for that?
 
@dzaima No no, probably don't want it either, you're right. Just intrigued by how spot on people are about answering even when the room is empty. Also happened with @dzaima yesterday. And am sure Adám's also super speed. I suppose they all just do the same, then
 
I know that FireFox shows a count of "unread" messages in parens in the tab, and if there are any pings to you, it shows a * - so if there are e.g., 3 messages that I "haven't seen" any of them are prefixed @JeffZeitlin, I'll see (3*) The APL Orchard in the tab
 
RGS
@JeffZeitlin +← 1
 
@dzaima yeah, seems it's a Vivaldi feature to show a new message count bubble on tabs with unread messages
@JeffZeitlin that is an SE feature afaik so it should happen everywhere, but it's not that useful when the tab is pinned in chromium, which hides the title
 
6:08 PM
@dzaima - Can't speak to that; yeah, I'm pretty sure that's SE, but I can't speak to the pinned-tabs question as I just don't do that.
 
@AviF.S. i assume you're doing something like {…∇…} 0 n⍴0 or m n⍴{…∇…}⍬?
@AviF.S. (also, in dzaima/APL another alternative would be ⍬n⍴result, with an equivalent ¯1 n⍴result in Extended)
 
@dzaima Super neat, always wondered why that wasn't a feature in Dyalog!! At least it's elsewhere :)
But again, post/pre-processing is not what I'm hoping for. Would be nice if the array info was self-contained!
@dzaima I'm saying I'd rather not do start←⍬ ⋄ m n ⍴ {…∇…} nor start←0 n⍴⍬ ⋄ {…∇…} nor even start←⍬ ⋄ 0 n ⍴ {…∇…} if it were possible. Nothing about the info re: matrix should leak outside {…∇…}. Should be the best of both worlds: start←⍬ ⋄ {…∇…} with some way to create the matrix within the recursive {…∇…}, from nothing.
 
6:23 PM
@AviF.S. i was sure i had posted an "i have no clue how people live without ⍬n⍴" message here but it appears there's not. closest is this
 
RGS
@AviF.S. I haven't followed this conversation 100% but there is something I really don't understand
if you want to create a matrix with a varying number of rows, there is something we have to agree on: regardless of the number of rows you end up with, they always have the same number of columns, correct...? that is why it is a matrix
 
@dzaima Haha, I don't know how I live without it either!
@RGS No worries! Don't expect anyone to. Will read question...
 
RGS
so there is something that allows to determine, in some intermediate recursive call, the number of columns of the row that you want to add at this intermediate recursive call...
 
@RGS Correct, they will all have the same number of columns...
 
RGS
so it seems reasonable that in the base case you can still understand how many columns you should have in your 0-row matrix, so that you can create an "empty" matrix with 0 n⍴0
 
6:26 PM
@RGS Also correct!
@RGS Hmm... trying to process
 
@AviF.S. ah, you mutate start. My reasoning for why some _ n⍴ should be somewhere is that there's no explicit thing showing that at the end you'd have ≥1 row, so the code must give a sensible result for 0 rows too (namely, the correct column count), and APL makes you enforce that, which is good
 
Let me look back at my code!
Agh, wifi gone again...
I thought my base case is weird, but that does make sense!
Or not...
 
RGS
It is like dzaima said, you can't make a recursive function without a base case and the base case must really be the simplest, most basic, most fundamental solution to the simplest version possible of the problem your function solves
 
@RGS You're absolutely right! How silly! Let me just replicate my workspace from before, should've saved it... And then test it out and confirm. But that all makes perfect sense!
 
RGS
glad I could help shed some light on this matter :P let me know if it really clicked and worked
 
6:31 PM
@RGS Agreed! 'Course there's a base case!
@RGS @dzaima Thanks a bunch guys for all your help!! Super duper helpful and it will definitely work! Just nice to see it in action so will tell you when that happens!
 
RGS
good luck!
 
6:44 PM
Ah, all right! Helper functions are back up and running! It's a mess, though! I'm thinking about how to reformat the function so that your suggestion works...
Right now it's:
{...
EndIf: Base
mat⍪←...}
So it's not actually appending to the base case, if you see what I mean. The base case just tells it when to terminate the procedure of adding to something outside itself.
Will work on reformatting, but that's probably why it didn't suggest itself earlier. It's not natural given the way the function is formed. Working...
I don't think it's possible... Back to square 1? I left out some detail, it's of the form:
```
{...
EndIf: Base
mat⍪← (f head) dyadic (g tail)
(∇ head),(∇ tail)}
```
It's a gross oversimplification (the length of each row does remain constant in actuality), but there's two recursive calls despite only adding one line to the matrix.
So I can't change it to something of the form:
{...
base: 0 n ⍴ ⍬
next ← ...
∇ next ⍪← ...

}
Which was my original thought (since there's more than one additional recursive call per call). I don't know how else to say that ⍤. (Though, as far as I understand the term, head/tail means it's still primitive recursive since bounded, right?)
@all Oh well. Just making a helper function! Does anyone know how to have a function call another function whilst letting it access its variables? Global variables are a reasonable second choice, but having a little more control over scope would be nice!
 
7:07 PM
@AviF.S. dfns are lexically scoped, so it should be impossible. Defining the function in a scope with the variables is the only option afaik
 
@dzaima Sorry, what is afaik?
Oh as far as I know!
 
@AviF.S. as far as i know
 
Sorry, misread your response so the context seemed weird!
As for the second part: 'Defining the function in a scope with the variables is the only option afaik'
You mean that the variables have to be defined in the same defn?
I'm asking b/c in order to fix my recursive bit without making the whole thing a mess, it'd be nice if it could access information from outside which will remain constant throughout its execution. Otherwise, I'll have to make a helper pass it an '⍺' with the constant info, and then every recursive call will have to pass along the '⍺' as well. And I'll have to parse & rename the info encoded within the '⍺' every time. Which seems needlessly obfuscated!
 
@AviF.S. things like this
 
Looking rn, thanks...
Ah, super neat!!! I can't ever thank you enough for all of this you keep doing! Let me see if I can apply that to mine :)
 
7:14 PM
it's the same behavior you've been using everywhere (how else could your dfns access mat from outside?), just naming the function instead of calling immediately
@dzaima well it is sort of possible, but it doesn't i definitely wouldn't suggest using that
 
@dzaima Wow, haha! Agreed. Will stick with the other for now ⍤
What I have now, thanks to you and RGS, is really elegant; there's just one tiny problem which hopefully won't require obfuscating everything:
I have:
function ← {
__len ← ...
__mat ← 0 len ⍴ ⍬
__recurse ← {
____...
__}
__recurse ⍵
}
Spaces aren't rendering in SE chat for some reason, so I used '__' for indent instead...
Anyway, the inside recurse can access the outside function's variables perfectly, but it can't modify them. So it ends up doing nothing and mat remains
 
7:36 PM
@AviF.S. if you click ctrl+k your whole message will be a code block, preserving everything (and obviously disabling markdown)
 
Ah, thanks a bunch!
function ← {
    len ← ...
    mat ← 0 len ⍴ ⍬
    recurse ← {
        ...
    }
    recurse ⍵
}
 
@AviF.S. if you do modified assignments (so mat⍪←… or even mat⊢←…) it'll modify the variable where it was defined
 
That's odd...
It's definitely what I'm doing...
Oh, I see, it never exits the inner recurse function
My goodness, this never ends!
So sorry all...
Right now, my base case is of the form:
`base: ⍬`
`..........`
With everything else that matters below it. That was the closest I got to EndIf:in a dfn.
 
(also to note is that dfns will return on the first non-assignment line, so {… ⋄ recurse ⍵ ⋄ mat} won't return mat but the result of recurse ⍵ and never execute anything further)
 
Oh, is that the issue?!
Goodness almighty, you're right!
I did the Ctrl-Enter through the function to see where it stopped and I could have sworn that it never left the inner function!
 
7:43 PM
:D (i was just completely guessing there; what i usually go for is prepending _← to the problematic lines)
 
Thanks a million, it's all solved
So now it ends with:
function ← {
    len ← ...
    mat ← 0 len ⍴ ⍬
    recurse ← {
        ...
    }
    _←recurse ⍵
   mat
}
 
an alternative could be doing mat ⊣ recurse ⍵, up to the use-case/line length/personal preference
 
My goodness! That's super elegant! Thanks a million :) That's exactly why I posted the format, to ask if there was a cleaner way to end it!
One last stylistic question is whether it's cleaner to never name the inner function at all. The outer one has a descriptive name which describes what the whole thing does anyway...
function ← {
    len ← ...
    mat ← 0 len ⍴ ⍬
    {
        ...
    } ⍵
    mat
}
Somehow, I'm not liking that anywhere near as much... Thoughts?
 
@AviF.S. i personally wouldn't name it, but Adám would
 
@dzaima Good point, forgot to check his style guide!
But you like the second example I just posted then?
@dzaima Haha, so glad to see that :D
 
7:53 PM
@AviF.S. i don't necessarily like using multiline dfns inline, but it's rare i see any advantage of naming them either. Of course, personal preference, and very much can depend on the situation.
 
The inner function's not exactly long, but its 7 lines. I generally agree with you that it seems unnecessary to always name, but here it looks really weird to have a hanging ⍵ after 7 lines of code. And one wonders what the inside is doing; even though 'recurse' isn't that helpful anyway, I find it preferable in this case!
@dzaima 'Course! Makes perfect sense :)
Thanks again a million for all your help. Recursive functions which need access to constant info from outside come up all the time in my coding across languages. Maybe I just misuse/abuse recursion. (I often want to know attributes of the original argument, despite the recursive function having mutilated it.)
 
@AviF.S. i'd probably name it then (plus, it's recursive, which, even still using , technically is called multiple times)
 
Anyway, so I'm super happy with this pattern and I'm positive it'll come up again and again. So all this help will pay serious dividends. Definitely, not a one time case. At least not the way I tend to code...
 
@AviF.S. reading variables from outside is fine imo, but mutating it is a bit strange, though often it's not avoidable without making everything more horrible (i'll always try to though)
 
@dzaima True, though I'm WITHOUT A DOUBT using ∇ over recurse anyway!
Much easier to read IMO
@dzaima I mean, for instance, here I want to know the length of the original argument
Despite, recursing over the head & tail, which modifies the length...
 
8:00 PM
@AviF.S. yeah, agreed. (it may be useful if you want to recurse from an inner dfn in the recursive function though, but that's not the case here)
 
@dzaima 'Xactly; good point! Well thanks again a bunch, serious lifesaver not just for functionality, but also made for seriously beautiful & readable code!
 
 
2 hours later…
10:02 PM
@all How to insert an arbitrary number of elems in a vector? Not so hard to write my own function but shocked that there shouldn't be a primitive/train to do so. @ is very picky about not changing the length of the original vector, for some reason...
As an aside: Does anyone know why @ doesn't like to change the length?
Was unable to find anything of reasonable length under !aplcart insert and related. There were some monstrosities at the bottom, though, but I didn't check them b/c I'd rather write it than copy it, if it's that bad!
 
@AviF.S. Firefox gives me a blue blob on my pinned tab when there's a new message, even if not pinging me.
 
@AviF.S. - For it to be a primitive, I think it would have to be triadic, somehow, and that's not APLish. I'm not sure I see how I would do this as a function unless there's some way to write a function that has multiple returns.
 
@Adám Yes, I've noticed a tiny asterisk now in Chrome!
@JeffZeitlin But that's how operators like @ & ⍤ work, no?
With format like:
'*'@(2∘|) 1 2 3 4 5
or
10 (×@2 4) 1 2 3 4 5
I'm just requesting:
 
@AviF.S. - Don't confuse operands and derived functions with arguments and values-returned.
 
'**'@(4) '123-5'
@JeffZeitlin Didn't mean to comment on how it works. Merely that it works...
If you can do ('*'@4) '123-5', then can't you do ('***'@4) '123-5'?
 
10:19 PM
@AviF.S. - I don't think so - but I think you can do ((⊂'***')@4) '123-5'. That doesn't get you what you want, though; I'm assuming you don't want to change the depth.
 
That was really silly of me! It's not a bad fix at all
Because you can just add in front, or maybe even somehow atop it on
But still... a little convoluted
 
@AviF.S. elementsBefore(↑,toBeInserted,↓)mainData
 
@JeffZeitlin You're right that my examples were terrible. Those are all simply operands, which is nothing new
@JeffZeitlin I more meant things like ('*'@4) '123-5', the mechanics of which I don't really understand!
@Adám Wow, this is a great point! Cleaner than my solution, certainly! Thanks :)
 
AHA!
 
Any insight on why @ doesn't work that way already?
 
10:23 PM
I guess I should add X(Is{⍺⍺(↑⍪⍺⍪↓)⍵})Y to APLcart.
 
again. (by some reason linux stopped recognising wifi ._.)
 
@AviF.S. It can't really, as it is defined in terms of applying a function on the collection of elements at certain positions.
 
Adám's answer is probably the right answer, but for the example you gave, I did manage to come up with ,/,¨((⊂'***')@4)'123-5'
 
@Adám Super sorry, I guess it is in there :( Feel like an idiot
 
@AviF.S. No, it just means I didn't add the right keywords.
 
10:26 PM
That was one of those I referred to as a monstrosity, and therefore didn't check because it looked like it'd be even longer than something I came up
with
 
@dzaima X∘⍪⍢(Js∘↑)Y ?
 
No, there are like 30 results when I type in insert and that one's like 5th from the bottom
 
@AviF.S. It is so long because I wanted to wrap it in a nameable operator, instead of simply being an expression.
 
@Adám that's insert only at one place, this is APL, we may want to insert in multiple
 
But I'm still not used to the notation on APLCart, so expressions that look like that just scare me away :(
I only checked the 'simple' ones
@dzaima @Adám Haha, I'm too busy feeling bad to have noticed that. You're totally right! As it happens, I do want to insert in multiple places
Haven't checked yet, but imagine @JeffZeitlin's answer ,/,¨((⊂'***')@4)'123-5' does just that!
Because it's still uses the @ operator
 
10:29 PM
@dzaima @AviF.S. The "correct" way is to use expand and then @ .
 
I think it will, if you change the 4 to a vector
 
@Adám that required doing "complex stuff"™ to be able to relate the indexes in the expanded version to the original ones
 
Right.
 
It sure does! Though @JeffZeitlin, not sure why it's not simply ∊((⊂'***')@4)'123-5'. What is the other stuff doing?
@Adám Hmm, interesting... Do you mind elaborating, please?!
 
@AviF.S. That's not a general solution because it'll flatten everything.
 
10:31 PM
@AviF.S. - I might just be overlooking something; ∊ wasn't a primitive in early APLs, and I did manage to remember that ¨ was "do it to each..."
And @Adám is right; my solution doesn't generalize to vectors with arbitrary depth.
 
@Adám Also, I must admit I find it amusing that it's 11:30 PM in the UK, yet you're here presumably because three days off for Shavuot/Shabbos has left you starved!!... or guilty?
@Adám Ah thanks, noobish me!
 
Slightly cleaner version of Jeff's code: ⊃,/(⊂'***')@4⊢'123-5'
@AviF.S. Waiting for live images from Crew Dragon.
 
@JeffZeitlin Haha, no, he was critiquing my bit, not yours. He was defending you!
 
(that's the problem with any insert primitive - there are multiple ways one might want to insert - positions in input or result, an "amount" array (with length equal to input's length), multiple elements at each or just a single one, etc; anyways gtg)
 
@Adám Ah! No wonder you're back online at such hours, haha!!
 
10:35 PM
@AviF.S. '***'@4 5 6⊢1 1 1 0 0 0 1\1 1 1 0 1/'123-5'
 
@dzaima That is a good point... but aren't there multiple possibilities for the implementation of most anything, hence design differences between the APL dialects, including yours? One simply has to decide how it'll behave, and something sure seems better than nothing!
@Adám Thanks a bunch, far cleaner than mine!! (I so far just had something primitive like 4{(1↑⍺↑⍵),'|||',⍺↓⍵}'123-45')
@Adám Ah, and thanks a mill for the explanation, as well! Always super helpful!
Probably would be nice if they were easier to find on APLcart, though you've so many goodies, it's inevitable that some things will be harder!
 
@AviF.S. Turns out I was missing plural "s"s.
 
@Adám Hold on, I thought that was an explanation of the prior code! Now I see: you're saying that's how one was originally meant to write such things?
With expand/replicate?
Also, @dzaima gave it a shot, but am still unsure why it's not the default behavior for @ to be able to insert multiple?
 
As I see it, the main conceptual problem with arbitrary possibly-length-changing "insert" and/or "replace" functions is that they are, necessarily, triadic - and there's no good way in APL to express triadic functions.
 
@JeffZeitlin @ is also triadic.
 
10:44 PM
@Adám - How so?
 
@JeffZeitlin 1@2⊢3
 
@JeffZeitlin Sorry, I forgot to give you credit as well for giving that question a shot, both you & dzaima
@Adám Phew! Not so crazy then...
But I don't really understand the meaning of ⊢ here. Especially because ⊣ gives the same result...
 
@Adám - I would not have expressed it that way; I would have said that @ is a dyadic operator that returns a monadic function.
 
@JeffZeitlin Haha, you sound like a functional programmer :p
 
@AviF.S. It separates 2 and 3 so they don't strand. It is monadic, so equivalent to .
 
10:47 PM
Well, I like to think that I'm a programmer, and I also like to think I'm functional, but I'm not sure that taking the two together makes me a functional programmer :)
 
@JeffZeitlin Haha, very true. Sorry, your response just flooded my head with currying/Haskell/lambda calculus/all other such things :p
@Adám Thanks a bunch, totally forgot about the monadic meaning. Now I finally see how it can be useful!
@Adám But then I guess I still don't have your answer to the behavior of @
@all Weird case: Nested vectors in turmoil still?
⊃,/(⊂⊂'***')@4⊢'123-5'
returns
 
@AviF.S. That's the same as (⊂'***')@4⊢'123-5'
 
┌─┬─┬─┬───┬─┐
│1│2│3│***│5│
└─┴─┴─┴───┴─┘
@Adám Darn, you got me again!
Was thinking it should return:
 
"Flattening" that requires another ,/ (or maybe ⊃)
 
┌───┬───┬─┐
│123│***│5│
└───┴───┴─┘
 
10:53 PM
@AviF.S. There simple has been no proposal that has been accepted.
 
@Adám No proposal for a new primitive or no proposal for an extension of@?
 
Neither.
 
@JeffZeitlin 'Course! I was just expecting what I sent after your response. Agreed that flattening takes another one!
Uh oh, wow... 90% of this page is taken up by green/aka me ⍤ ⍥ ⍤
@Adám Whoops! Missed your response. I see! Any sense of which it would most likely be? And if it's a likely addition eventually? Aka, how often does it come up/bother you in your workflow?
@all What fraction of the time that you use @ do you use it to change individual elements/wish it could do more?
 
@Adám - Just a random comment... In working out that code for @AviF.S., I found ]box on to be quite useful...
 
@AviF.S. Uh, it does work on arbitrary number of elements!
 
11:04 PM
@Adám Sorry, I fixed my language!
Was badly stated!
 
@JeffZeitlin Yup, that's why I put it on my tips page.
 
@JeffZeitlin Ah yes! Super helpful :)
]box -trains=tree, is often nice for visualizing trains, too!
 
@AviF.S. I still don't understand what you mean.
 
and there's of course the other parameters like -style=max or something that make it behave more like ]DISPLAY rather than display...
@Adám Ah, how often you have a case where you wish it could do what I said earlier, to put I rather selfishly but simply
And what proportion of the time that you use @, it's works as is vs. proportion that you wish it could do [insert what I said earlier, here]
 
@AviF.S. Almost never. I suspect that if you're inserting, then you're not taking a good array approach, and/or you're dealing with a tricky problem that doesn't lend itself to that.
 
11:08 PM
@Adám Oh no! Okay, good point! I feel caught out. It's one of my attempts at the mobile problem...
So yeah, maybe not great for arrays. Still working on morphing it to work better in this domain.
 
@AviF.S. Well, there's a note on that problem for a reason.
 
But I suppose the fact that I've never needed/asked this before implies that it is pretty uncommon!
@Adám 'Course! Agreed!
Whoops, have to go, sorry! Might be back in an hourish. Thanks a bunch to @Adam & @JeffZeitlin, some @dzaima too :)
 

« first day (1221 days earlier)      last day (1441 days later) »