« first day (769 days earlier)      last day (164 days later) » 

7:34 AM
Cool function by @JayFoad:
⎕← {'https://tio.run/##','\+' '='⎕R'@' ''base64 10↓¯8↓256|⊃⌽3(219⌶)¯128+256|128+(⎕UCS'apl-dyalog'),t,('UTF-8'⎕UCS⍵),t←255 255⊣'base64'⎕CY'dfns'} '⎕←⍳2 3'
 
#tio alias command )tio #tio do apl-dyalog ⎕←'https://tio.run/##','\+' '='⎕R'@' ''base64 10↓¯8↓256|⊃⌽3(219⌶)¯128+256|128+(⎕UCS'apl-dyalog'),t,('UTF-8'⎕UCS'%args%'),t←255 255⊣'base64'⎕CY'dfns'
 
@Adám Added alias for )tio
 
)tio ⎕←2+3
 
7:55 AM
#tio alias command f← #tio do apl-dyalog ⎕←'https://tio.run/##','\+' '='⎕R'@' ''base64 10↓¯8↓256|⊃⌽3(219⌶)¯128+256|128+∊{255,⍨'UTF-8'⎕UCS⍵}¨'apl-dyalog' '' '%args%' 'f←⍎⎕IO⊃¯3↑⎕SRC⎕THIS'⊣'base64'⎕CY'dfns'
 
@Adám Added alias for f←
 
f←{⍺+2×⍵}
 
 
1 hour later…
9:06 AM
hello
 
@ASCII-only Welcome. So at this point you know nothing of APL, right?
 
basically, yeah
 
@ASCII-only OK. You may want to visit this page so you can enter APL characters.
 
@ASCII-only First, and most importantly, forget that APL is a programming language. It is just traditional mathematical notation (TMN) which has been harmonised and generalised.
This makes it a good choice for communicating algorithms between humans, and coincidentally, it makes it possible to create an automated evaluator, i.e. use it as a programming language.
 
9:11 AM
right
 
@ASCII-only In this chat room lives a bot which looks for messages beginning with ⎕← and evaluates the rest of the line as APL. If you begin your lines with four spaces, it will look better and avoid strange markdown effects.
@ASCII-only So, as I said, TMN:
⎕←2+3
 
@Adám
5
 
APL even lets you use the proper arithmetic symbols instead of poor ASCII substitutes:
⎕←(2×3)÷4
 
@Adám
1.5
 
@Adám of course, every language should do that :P
 
9:13 AM
@ASCII-only They can't if they are ASCII-only ;-)
 
also... oh wait :O language bar has hover text
i never realized
 
@ASCII-only OK, let's look at the first bit of harmonisation/generalisation APL does to TMN. TMN suffers from wildly inconsistent syntaxes, e.g 2³, log₅ 4, sin ⍺, –4, 4!, |z|, f(x), etc. etc.
APL takes the most common one, -4 and generalises TMN so all single-argument ("monadic") functions are prefix without needing any parens. Two-argument ("dyadic") function application consistently gets an infix symbol. So the above are 2*3, 5⍟4, 1○⍺, !4, |z, f x in APL. There are no exceptions to this.
@ASCII-only Clear ^?
 
yeah
 
@ASCII-only As it follows naturally from TMN things like f(g(h(x)), which in APL of course is f g h x, all functions have long right scope (and thus short left scope). APL generalises this to even apply to arithmetic functions, so you don't have to worry about precedence. All functions have long right scope. No exceptions. E.g.:
 
right scope?
 
9:24 AM
⎕←2×3+1
 
@Adám
8
 
so basically everything's the same precedence, and it's RTL?
 
In TMN you'd have to remember that × goes before +, but in APL, you know that ×'s right argument is everything on its right as far as it can reach.
@ASCII-only Yes, but well-written APL often reads nicely from left to right.
APL avoids mixing up assignment and equality by using for assignment. It too (of course!) has long right scope, so you can do things like
⎕←a×1+a←3
 
@Adám
12
 
@Adám like in all sane languages with infix assignment :P
 
9:29 AM
@ASCII-only In fact, is just a stylised picture of the console, and stuffing a value into the console of course means printing. Hence ⎕← is print.
 
oh btw dinnertime for me basically right now :/
 
@ASCII-only OK, you've gotten the basic function application down. Ping me when you want more, or I'll remind you later.
 
:P definitely stylised
one thing though, (no offense) i think i would have understood the basics fine without this much explanation lol
 
@ASCII-only OK, I'll be more brief. Better start verbose than leaving people in the dust. And I can't exactly look at your facial expression to gather whether you're lost or bored :-)
 
9:55 AM
ok, i'm back
 
@Adám have you ever written a "static" tutorial in this style?
 
@ThomasLackner Yes.
@ASCII-only OK, I'm too.
@ASCII-only OK, next is APL's generalisation of higher-order functions. They are called operators in APL. E.g. TMN's ∑ and ∏ are just + and × reductions over a list, written in APL as f/ so +/ and ×/ but works with all dyadic functions.
Operators have long left scope. May seem inconsistent, but you'll quickly find it natural.
Operators are used for a wide variety of higher order concepts, from simple things like mapping with "each" over generalised linear algebra (e.g. dot/cross/matrix product is a specific case of the generalised f.g where f←+ and g←× giving +.×) to launching f(x) in a separate green thread with f& x
@ASCII-only Brief enough ^?
 
10:12 AM
sorry was walking the dog just now >_>
 
@ASCII-only NP, want more?
 
hmm. what does +.× even do O_o
also, how does the long left scope work with the long right scope of functions
 
@ASCII-only The operators are stronger than functions. The left "operand" of an operator must be either an array or a function. The operator will "grab" to the left until the beginning of the immediate array or function. E.g. in 1 x op y the operator op will have x as operand if x is a function but if x is an array, op will only the entire array (1 x) as left operand. Sounds complicated, but it is really quite simple in action.
 
@Adám would it be appropriate to discuss kparc.com/b/ here? Just don't want to clog the room up with that or speculation about kOS, Shakti, etc.
 
@chrispsn Surely on topic, but not many people here are qualified to discuss it…
@ASCII-only 2 3 4+.×1 2 0 is (2×1)+(3×2)+(4×0)
 
10:21 AM
@Adám so stronger = lower precedence right
 
@ASCII-only No, bind stronger. You'll see some examples very soon.
 
@ThomasLackner where'd you get to with your digestion of b? was there anything surprising in what you found? github.com/tlack/b-decoded/blob/master/b.c
 
@chrispsn huh. the readme certainly seems very.... interesting
 
@ASCII-only Just a quick word on APL arrays. They may have 0 or more dimensions, and every item of an array is itself an array. :-)
 
10:27 AM
so things like numbers = 0 dimensional?
 
@ASCII-only Yes. And there are no "strings", only 1-dimentional character arrays.
@chrispsn Whoa, so AW is going to make his own "C" compiler which both allows him a faster K build-cycle, and makes the K executable even smaller. I expect K to eventually be faster than not just hand crafted C, but also equivalent C.
@ASCII-only If that has sunk in, we can proceed with a very basic function, the index generator :
⎕←⍳4
 
@Adám
1 2 3 4
 
@Adám wouldn't equivalent C be slower than hand-crafted C????
 
@ASCII-only No, I mean that the exact C code that "runs" behind the covers when K code is executed would be slower than the exact B code that runs behind Kx.
 
10:35 AM
@Adám What surprises me is: 'b' is not new. It was uploaded to kparc in 2016. It shows some "raw, contemporary Whitney" in action - but few (@ThomasLackner notably excluded) have leapt upon it and analysed it in detail, in public, despite cries to make k itself open-source.
 
would hand-crafted c be slower than that though? (actually, wdym by hand-crafted)
 
It feels ripe for a programming conference talk.
 
@chrispsn i rediscovered my notes on that recently on an old server. i'd love to discuss more. "b" is certainly a panacea of currently-available alien whitney tech.
 
@ASCII-only Normally, it is theoretically possible to write C code that matches the speed of K (or APL), but it may require a lot more C code than what a C programmer normally would write — so much more that even a careful coder is likely to fail to match the speed. But if K is implemented in C, it may even be impossible to match its speed in C, and one would have to write assembler to match, which is of course impractical.
 
ah, of course
same story with other array-focused languages, e.g. Julia
 
10:38 AM
@ASCII-only k has some common operators like "in" and "except" short circuited to work faster on sorted vectors. that kinda thing can be done in C, but is a challenge to integrate due to C's clumsy type overloading.
 
@ThomasLackner was there anything that you found where you thought "man, that's so clever"?
 
@ThomasLackner is panacea the right word
 
@chrispsn the first time i came across the AW style of parsing i had to shower intensely, so deeply shook was i. B has a lot of those same threads. Did you ever come across Effibae's C vector library? it helped me understand B, for some reason.
@ASCII-only absolutely not
 
@ThomasLackner laughed out loud
I haven't heard of Effibae's lib, will check it out
actually do you have a link?
 
10:42 AM
@ThomasLackner wait what is the aw style of parsing
 
@chrispsn took me a minute to find it. effbiae.com/parserclub/t.h - see parent dir for more mysterious artifacts from smart(er) people
 
oh nice! another nsl-like rabbit hole
 
@ASCII-only take two weeks off of work and puzzle your way through this. raw.githubusercontent.com/KxSystems/kdb/master/s.k
@ASCII-only in fact, if you can figure out w0 and w1, you'll probably have to make significant life changes to cope with teh blistering reality that THAT is lex and yacc
 
@ASCII-only As an example of a dyadic operator which derives a dyadic function, we have where X(f⍣k)Y applies f to Y, k times, each time with X as left argument:
⎕←2(*⍣2)1 2 3 4
 
@Adám
4 16 256 65536
 
10:45 AM
That's 2*2*1 2 3 4
 
@ASCII-only i'll explain. most of the time when you lex or parse something you work with some abstract notation that involves symbols, states, all that. in those two definitions (w0 and w1 inside s.k, which is an SQL parser for K) he uses purely vector-oriented math operations to extract a surprising amount of structured info
@ASCII-only he uses a bunch of arrays to work as character -> state transition tables. it makes sense if you pick it apart. like i said, about 80 hours minimum
 
@ASCII-only If we remove the parens 2*⍣2 1 2 3 4 then won't grab the leftmost 2 because it only reaches left until the left of *, but on the right, it will catch all of 2 1 2 3 4 so the statement won't have an argument, and will therefore fail:
 
@ThomasLackner :/ i'd have to learn k first
 
@ASCII-only one of the great things about AW's style (and many people in the vector community) is that it starts with the simple, low level definitions at the top, and contextually adds layers of meaning, until the test cases at the bottom. after you get used to it, it makes it a lot easier to follow - its like a text
 
⎕←2*⍣2 1 2 3 4
 
10:48 AM
@Adám
SYNTAX ERROR
 
@ASCII-only take a sabbatical! its well worth it though. ripped my brain in two. still trying to find the other half
 
@ThomasLackner Hm, interesting view. Isn't it valuable to get a top-down understanding, and leave nitty-gritty details till later?
 
@Adám in a perfect world where everything understood forward references, i would agree! however, ...
@Adám i think this touches on the same areas as our smoking debate the other day about y is whatever in x is otherthing
 
@ASCII-only if you're a work-a-day coder both k and apl are pretty productive, though the learning curve is steep. if you are ok with getting deep with things, its a much more pure way to work.
 
10:52 AM
work-a-day?
 
@ASCII-only However, if we write 1 2 3 4 was ⍳4:
 
@ASCII-only like your boss tells you to do dreadful things and you have to do them or you become homeless. typical daily coder. as opposed to maybe a researcher, or someone doing education, or a manager..
 
⎕←2*⍣2⍳4
 
@Adám
4 16 256 65536
 
@ThomasLackner yeah i'm still in uni lol. but i don't mind learning a new language. that said, wasn't there a one-page spec for k
 
10:53 AM
@ASCII-only i wish i had studied vector languages at that point in my career. Adam is here to help! :)
@ASCII-only there are so many to choose from. i think this is the fashionable one for k6, the k that we were supposed to get, which has been replaced by k7. AW is extremely terse but precise - all punctuation and spacing in this document has meaning. kparc.com/k.txt
 
oh there it is
odometer?
 
@ASCII-only a way to generate permutations
 
Not permutations, it's just "counting"
 
@H.PWiz fair, I'm taking the description from here github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual.md
 
@ASCII-only oK.js is a javascript implementation of k5(ish) - it has some good docs. github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual.md
 
11:00 AM
I think it is wrong to say 0 0 is a permutation, unless "ranged permutations" has some other meaning
 
@ThomasLackner and then there's ngn/k :P
 
@Adám how do you feel about the ";" symbol to indicate a where clause?
 
@ThomasLackner Not a bad choice, but I dislike the differing syntaxes between dfns and trains.
Especially since trains and dfns both a special cases of "tacit functions". So if I can write
avg←sum÷num;
    sum←+⌿;
    num←≢
why can I not write
avg←{sum÷num};
    sum←+⌿;
    num←≢
And how exactly am I supposed to write multiple levels in the tacit way. Compare:
avg←{
    sum÷num
    ;   sum←plus⌿
    ;   ;   plus←+
    ;num←≢
}
with
avg←sum÷num;
    sum←plus⌿;;
    plus←+;
    num←≢
I find the latter completely incomprehensible.
So then you might say, oh, lets take the clearly superior dfn "where" syntax and use it for tacit functions too, but that won't work, as tacit functions don't have explicit encapsulation like {} so the interpreter cannot know to look ahead (unless we do something really funky, imho).
There are also some clarification questions. Which (or both) parts of a guard does the where clause qualify? Can I write this on a single line somehow?
Does this introduce a scope for tacit functions?
Maybe the ;;; can work with disregard to line breaks, and tacit functions could use parens to limit themselves when on a single line. (⍳;⎕IO←0) would be neat, and possibly better (faster, more versatile) than my proposed (⎕IO:0).⍳
@ThomasLackner Does ^, ^^, ^^^,… answer your question?
@ASCII-only Do you understand how 2*⍣2⍳4 works?
 
11:20 AM
:/ didn't see that
also i think i have to go now :/
 
@ASCII-only NP. I'm mostly here.
 
 
3 hours later…
2:07 PM
f←⊢,∘⍕10|⍎¨+.×9 7⍴⍨≢
 
 
2 hours later…
4:07 PM
@Adám I'd think that semicolons would be an alternate line separator to - just executing in reverse, so multiple semicolons would be pointless - avg←sum÷num; sum←(plus⌿; plus←+); num←≢
(or maybe (sum←plus⌿; plus←+)? of course, the parenthesis are mostly pointless anyway)
which brings up the question - how would variable scope work with that? I'd expect (a←b+1; b←5) to create a variable a but leave b undefined out of the expressions
also reminds me that at some point i wanted to try to add k's views to my apl
 
@dzaima No, executes sequentially, while ; is a declaration that potentially will be accessed multiple times. E.g.
foo←{
    (goo ⍺),(goo ⍵)
    ;   goo←{
            ⌽⍵
        }
}
The line tracer would need to visit ⌽⍵ twice.
 
how is that different from foo←{goo←{⌽⍵} ⋄ (goo ⍺),(goo ⍵)} (except variable scope)?
 
@dzaima In this case it isn't, but here it is:
foo←{
    moo←,⍨
    moo(goo ⍺),(goo ⍵)
    ;   goo←{
            moo ⍵
        }
    ;   ;   moo←⌽
}
 
4:22 PM
@Adám i said except variable scope :|
 
@dzaima You didn't
@dzaima And so you need multiple ;s to indicate which scope you refer to.
 
@Adám that's why I'm proposing just having parenthesis - multiple semicolons are very ugly & misusable
 
@dzaima Ah, I see, you'd use that universally, with the parens defining the scope.
foo←{
    moo←,⍨
    (moo(goo ⍺),(goo ⍵); goo←({
            moo ⍵
        }; moo←⌽))
}
 
outer parens are pointless there, but it's a good question what'd be the best way to space that
@Adám also it still works with the reversing idea - foo←{moo←,⍨ ⋄ (moo←⌽ ⋄ goo←{moo⍵}) ⋄ moo(goo⍺),(goo⍵)} (though with in expressions and variables not escaping their defining scope (which are also things i've wanted to add to my apl too))
heh this comes back up again
 
4:42 PM
@dzaima Heh, foo←{moo←,⍨ ⋄ goo←(moo:⌽).{moo⍵} ⋄ moo(goo⍺),(goo⍵)} should work in 18.0
 
What is moo:⌽?
 
@H.PWiz an inline namespace
 
@H.PWiz According to the plan, (name:value ⋄ name2:value2) will create an unnamed unscripted namespace in 18.0
I never thought of this usage. This allows giving even tacit functions a scope: avg←(sum:+⌿ ⋄ num:⍴,).(sum÷num)
Now we just need a backwards proper-order namespace . so we can go top-down, and that cannot be ; as that would clash with indexing.
 
aight imma try implementing some of this stuff, seems fun enough
 
@dzaima Which one?
 
4:52 PM
@Adám no idea ¯\_(ツ)_/¯
hmm‌​, 4 levels of nestedness
what should (f:+ ⋄ 3) do? error?
 
@dzaima My plan is for it to error. Each "statement" must be a name:value pair or blank.
 
@dzaima To get stranding working?
 
@Adám making multiple statements have the same representation as multiple expressions
@Adám your array notation of (1⋄2⋄3) though
 
5:08 PM
@dzaima Won't clash, as in that, there may be no unquoted :s, so (a:1 ⋄ b:2) is valid and (a←1 ⋄ b←2) is valid, but (a:1 ⋄ b←2) is not valid.
 
@Adám right, was just picking on that "blank". though, what should () be? what about (⋄)?
 
@dzaima () and (⋄) are both ⎕NS⍬
 
5:28 PM
while at this, i could also finally maybe implement maps with non-string keys - how should that be handled - have a separate type for that, have all maps be universal maps or have a quiet transition between the two when needed?
 
 
1 hour later…
6:54 PM
What is the best use for apl?
 
computation :)
 
like what purpose? I usually use high level languages and can't find much of a use for apl
there's no loops or anything
 
@EthanSlota you don't need (explicit) loops for 99% of code if you try hard enough
 
Also, there are :for/:while, etc.
 
6:58 PM
wait - there are loops?
 
@H.PWiz I'd consider those more for control flow than general computation
the idea of APL is that you don't explicitly write loops allowing the interpreter to do vectorizing magic easily
 
i look at tryapl.org 's "primer" for help
i dont see any loops
so
 
@EthanSlota tryAPL doesn't allow multiline code & tradfns
 
i'm sorry, what?
 
@EthanSlota here, a loop :)
if you really want an explicit for-each loop, here (though that is considered horrible APL)
 
7:04 PM
i still dont understand
:⌈
 
if you really really really want a loop, here you go‌​, but understand that there are much better ways to write that example program
 
god that looks horrible
yeah i guess BF doesn't do much better
 
@EthanSlota what are 95% of your for loop uses? I'd guess they're just for (int i = 0; i < someAm; i++) which is horrible boilerplate that APL gets rid of
 
for (i = 0; i <= 10; i++ ) {console.log('APL');};
 
7:08 PM
Might need 11 there
 
a while ago
 
or 11⍴⊂'APL' if you wanted an array of 10 char-arrays
 
i used something like ⍉(4⍳⍴) (+4/⍳4) or something like that
for an array with [1 2 3 4] [5 6 7 8]
(but organized)
 
@EthanSlota 2 4⍴⍳8?
 
⎕←4 2⍴⍳8
 
7:10 PM
@Sherlock9
1 2
3 4
5 6
7 8
 
Oops got it backwards
 
@Sherlock9 heh i get the dimensions backwards probably 70% of the time :D
 
(also I'm not sure I understand any of the above K conversation but it looks fascinating)
 
every time i see that APL box i think it's the unicode "missing char" thing
 
@EthanSlota everyone does until they get used to it :p
 
7:12 PM
(also I really ought to figure out how to use APL in production code some time but maybe that's in the manuals I keep forgetting to continue reading :/)
Also, how do you get the permutations of a vector in APL?
I'm not even sure how to approach this one
 
how would I get the average change in a group of data?
like 0:119, 2:114, 3:108.5 ...?
 
@EthanSlota could you clarify "average change"? does that mean absolute difference from average?
oh, you skipped 1: there, no idea then
 
oh yeah 2 is one and 3 is two
whoops
and change is |Δx|
 
@EthanSlota oh, so just |2-/119 114 108.5?
 
The average change would be the mean of the first differences then?
 
oh average, so (+/÷≢)|2-/119 114 108.5
 
just so you know i leave school in two minutes and can't talk at home
so bye
happy apling (?)
 
@H.PWiz Thanks
 
@EthanSlota APLer.
 
7:26 PM
What would the act of writing/reading/debugging/messing around with APL be called?
APLing or something else?
 
@Sherlock9 Good question. Doing it in J is called jotting.
 
Also on the subject of what I think is called b from earlier today. Is this a new compiler that could make it faster than K to C, or a new language for K to be interpreted into, making it potentially faster than C?
I am interested and confused
 
@Sherlock9 B is an alternative to C. I suppose it is intended for rewriting K in B, so that the K executable will be smaller and faster.
 
Interesting
What is K in relation to APL? I've heard of it but not investigated
 
@Sherlock9 K is inspired by APL, but does away with rank. It also has a very minimalistic set of primitives, but uses a larger set of data types together with heavily overloading the functions based on argument types.
 
7:39 PM
Sounds more complex
At least from this description
 
@Sherlock9 In many ways, it is much simpler than APL, but I do think it is less friendly than APL.
 
@Adám Ah "friendly" might have been the word I meant
 
@Sherlock9 Interestingly K people tend to write English in a specific style. Absolutely no formatting other than extra spaces, no uppercase letters, never any formatting.
 
what like this
this looks awful and hurts my heart dear god why
i want my commas back waaaaah
 
Oh this is where the grammar comes from
I shall have to take a look at this in the morning as it's 3 am
Thanks Adám
 
@Sherlock9 (almost) any time.
 
 
1 hour later…
9:23 PM
what do the asterisks at the line starts of ]runtime mean?
 
@dzaima That the result differed from the first expression's.
 
@Adám ohh interesting. comparing the different answers for the tnb question, and forgot that the 1st item of the mask must be 1
 
9:43 PM
so it seems my first solutions are about 50% away from the more traditional ones, but beyond that it's hard to tell much
https://tio.run/##1VTNSsNAEL7nKYaCoDSp2c2mSUHQFHyCHnqph9K44CE9@HfR3sSDNiKKL@DJWy8KUhChj7IvorubbFrs2h5skrrkZzIz33wzO5vpdfvn3ZMvviLEru8vAv5g8dhE7PaqLeU3KU9G3PzYsjaRyeKXyQhb2yx@D7bY8DPgd9vi2hb3r3baAyPCIhR3Vn4yovDlAn8mwWwzAXCKgRFKdvnBQ407timxAMC/xAsUSAHwYkC1owBCIwDOIoCImwAAFIAsZrD3ELt5FqDhR5oU/VFFYKkk0n3VVULxctBcNdRZBtJURMlyJk1VTeBWQNLg7@wiWywWvyLbCKRpVmUbB8dn/dOj6BCsHlSaECEIKlLAqRAqTZhpHCWQVKDKhyofqnyo8DHgz4uHSLLjNTyAV3P2JyMCl9xibwC7eyrlSrPCWVZIZWWRkrJKdypUO0VqfpqT5birzknXox
the ¯2-/ doesn't seem to do much to the speed
+\¯1↓0, seems to consistently be a bit better though, and it's the one that was linked as finnapl
 
@dzaima Interesting. I would have thought that ¯1↓ should be before +\ as that makes one less addition, and similarly for 0,. But both are O(1) so it doesn't matter much.
 
@Adám exactly why I added it to the mix of test-cases
it's just up to whatever the interpreter feels the most comfortable with i guess
 
@dzaima The interpreter or the programmer? I think it is good that they all perform the same, so one doesn't have to worry about precise formulation.
 
@Adám i guess both work, I was more referring to the fact that +\¯1↓0, is a bit faster
 
@dzaima Which I find strange. I would have expected 0,+\¯1↓ to be faster. I can ask Marshall tomorrow.
@dzaima Oh, hold on, I think I remember something about +\ being faster if the first element is 0.
 
9:57 PM
@Adám oh huh. it'd also make sense that 1↓0, together would somehow make it easier to do the modification inline better
 
@dzaima Yes, but that'd need a thunk (which we don't have yet). That's why I'd expect 0@1⊢¯1⌽ and ¯2-/ to be faster. Anyway, the ref-count of is more than 0, so it can't do in-place.
 
@Adám oh, very good point, that would definitely be a good thing to test for
 
@dzaima Ah, I got it. I know why d2 is fastest.
The ref-count of is above 0, so we need a copy for the +\ any way. 0, causes the any way necessary duplication with minimum overhead. ¯1↓ is "free" (only the header needs to be updated with the decremented shape). Now +\ can be in-place because the ref-count of ¯1↓0,⍵ is 0. Finally, ¯2-/ can be calculated using vector instructions and without actually duplicating the vector.
@dzaima ^ makes sense?
 
@Adám oh right, of course ¯1↓ would be fast
why would 0, have less copy overhead than +\ though?
 
@dzaima It doesn't, but if you do +\ first you have to create a copy, and 0, cannot be done in-place even though the ref-count is 0.
 
10:11 PM
@Adám ohhh
so it comes down to that 0, always needs a copy but +\ and ¯1↓ only need one when refcount isn't 0
 
@dzaima Exactly.
@dzaima ↓⍨← is even an idiom for negative numbers.
 
@Adám pretty sure I've only ever used it for negative numbers
 
@dzaima Yeah, most common. To speed up positive, the header would need to be moved or would need an offset value, neither of which we support.
 
oh huh - a←1e9⍴123 ⋄ a↑⍨←10 does indeed use a bunch of unneeded ram (of course, cleared away by ⎕WA)
 

« first day (769 days earlier)      last day (164 days later) »