« first day (1412 days earlier)      last day (284 days later) » 

9:21 AM
@Adám as you showed me, I can fetch a value from a namespace by string by using myns⍎'mystring' -- but how do I set a value for a new key by string?
I naively tried myns⍎'mystring' ← 42.
@xpqz 'mystring'{⍎'myns.',⍺,'←',⍕⍵}42 maybe good enough?
@xpqz Or a doofy operator called "_Gets" {⍎(⍕⍺⍺),'.',⍺,'←',⍕⍵}
@RikedyP Works! But... it sure won't win any beauty contests :)
@xpqz 'name'(myns _Gets)32 have lipstick'd the pig
@RikedyP {⍎'⍺⍺.',⍺,'←⍵'⊣⍺⍺} probably works better
@dzaima thanks yes much better
@dzaima I didn't realise the ⍺⍺ in quotes would work like that
9:33 AM
@RikedyP i had to test that too, but there's no reason it shouldn't
@dzaima Perfick!
I'll from now on pretend that ⎕ns is a dict, even though the Gods of Dyalog seem to advise against.
'hello'(ns _Gets)'world'
How about Gets←{⍎⍺,'←⍵'} called as 'ns.hello'Gets'world'?
@xpqz Right, that's why I'm working on a better way, my current proposal being ns ⎕NS⊂'mystring' 42 (the enclose is so you can set multiple values at once).
9:50 AM
@Adám any reason you couldn't just allow not needing the and deciding on whether element 1 is a string? seems like an awfully stupid thing to need it for the most often case
(more alternatives: ns ⎕NS ('key1' 'key2') (val1 val2); ns ⎕NS 'key1' val1 'key2' val2; ns ⎕NS ['key1' val1 ⋄ 'key2' val2])
(original suggestion & first alternative break if the key is a character not a charvec, but those are stupid)
@dzaima Two reasons: 1) There's the option of using the current namespace's value rather than supplying a new value; ns ⎕NS 'key1' 'key2' is thus equivalent to ns ⎕NS('key1' key1)('key2' key2) and 2) Backwards compatibility as ns ⎕NS 'key1' 'key2' already has the latter meaning from the first point.
@dzaima My proposal also allows ns ⎕NS ['key1' ⋄ 'key2'] (val1 ⋄ val2)
@Adám i assume that removes the potential space padding from the key matrix? ugh.
@dzaima Names cannot have spaces, namespace members must have valid APL names. It is traditional to use matrices to list APL names, e.g. this is the normal result from ⎕NL 2 and also valid argument to ⎕EX, ⎕CY, ⎕NS etc.
@Adám ah, then allowing it acceptable i guess. But also extends my "ugh" to ⎕NL 2, ⎕EX, ⎕CY, ⎕NS, etc
10:06 AM
It is quite normal for databases to pad all strings in a CHAR column to the same length using spaces.
@Adám spaces? you sure the "normal" thing isn't null bytes?
@dzaima The utility of your first proposal can be achieved very cheaply in my using ns⎕NS↓⍉↑keys values or ns⎕NS(↑keys)values. I really don't like the lack of structure in your second one. Your third one would be a possible consistent extension, but doing ns⎕NS↓⍉matrix isn't bad either.
@Adám i wasn't proposing those as "better" or "irreplaceable", but rather as equivalents that also allow for a saner single-item case
@Adám that's talking about how that's bad, so doesn't particularly help your case. But i guess the normal thing is spaces, huh.
My bet is that null chars weren't invented (or that space was the null char) when this became practice. It gives interesting issues in sorting APL charmats too.
@dzaima (the backwards-compatibility problem remains an unsolvable issue though. i'd prefer adding a separate better quad than a worse, more overloaded one, but meh)
10:15 AM
@dzaima Yes, that is a possibility, but I though that since we already have one to copy name-values from one namespace to another, why not just use that to set name-values from one namespace to another too?
Especially since the existing one is called simply "NameSpace", not "NameSpaceCopy".
Also, ⎕NS (re- or co-interpreted as "Name(space) Set") is such a great parallel to ⎕WS which does the same for OO objects. And then since ⎕WG is the value getter, it becomes natural to add ⎕NG for "Name Get" or "Name(space) Get".
@dzaima ah, that's not allowed anyways
@dzaima What do you mean?
@Adám 'X'⎕NS'a' 'b' isn't equivalent to 'X'⎕NS,¨'a' 'b'
@dzaima Right, exactly, a common annoyance with all the above-mentioned quads, and maybe most frequently with ⎕R/⎕S too.
"s"≡,'s' would be a relief, though if we do that, we should maybe consider adding escapes and stuff too. Maybe. I'm not 100% about that.
@Adám all because single character vectors are impossible to use
@Adám it's the obvious solution, but you kind of have to decide on all the non-obvious stuff before it's implementable
10:24 AM
Right. There's also a request for multi-line strings, preferably without having to double or escape anything. Lots of design work here.
(For instance: Should those give flat or nested vectors? What about leading and trailing whitespace?)
Finally did todays AOC, was a tough one!
@rak1507 ah, i was waiting to see this :) it was relatively easy in k because of its well-designed dicts, but i ran out of patience trying to solve it in apl
10:39 AM
Yeah, I couldn't be bothered figuring out how namespaces work so I decided to take the unoptimised and slow method
@rak1507 in case you don't know about & in regex replacements: bags←{⊃'(\w+ \w+)'⎕S'\1'⊢⍵}¨text could be bags←⊃¨'\w+ \w+'⎕S'&'¨text
Yeah I didn't, thanks
One for APLcart? @Adám
11:05 AM
@rak1507 it's much faster if you store contained as pairs of vectors instead of vectors of pairs
Ah that's sensible
I'll refactor it later
@ngn same here
@Razetime you're solving in k? or do you mean only the part about giving up on apl?
the giving up on apl part
11:08 AM
ah :)
My friend is apparently 'stuck' in the dyalog interpreter, ctrl c and ctrl d don't work... any ideas
@rak1507 OS?
@rak1507 is it using a lot of CPU?
Try Ctrl+Break
11:12 AM
@Adám doesn't seem to work for exiting an infinite loop from commandline
it's not using a lot of the cpu
Using RIDE?
@rak1507 Try kill -3 processid from the command line.
Apparently they did ⎕OFF or something and that worked
"-3"? so polite :)
@Adám well that's the obvious solution. Question is, is there a nicer one. I can't find any way to sanely stop an infinite loop launched from shell :|
11:17 AM
@rak1507 Wat? APL was "stuck" but still had a 6-space prompt and responded to input? Define "struck" then.
@rak1507 i refactored part1 but i gotta go now. i'll try to do part2 later (unless you've already done it):
b←⊃¨'\w+ \w+'⎕s'&'¨a
c←{×≢d←'(\d+) (\w+ \w+)'⎕s'\1,⊂''\2'''⊢⍵:⌽↓⍉↑⍎¨d⋄0}¨a
1-⍨≢{∪⍵,⊃,/{b[⍸(⊂⍵)∘∊¨⊃¨c]}¨⍵}⍣≡⊂'shiny gold'
@Adám no idea
@rak1507 What is?
@ngn Ok cool I'll analyse that later when I'm not in class
What is what?
@rak1507 What is your suggestion for APLcart?
11:19 AM
Oh right, & in regex
@rak1507 Ah, so all the Dyalog-specific features of the transformation pattern? I'm not sure how they'd fit into the format. They are well-documented in the ⎕R documentation, though that page could do with a TOC.
Fair enough, I should probably read the docs more
12:18 PM
So {(⍳⍺)∘.,⍳⍵} generates a grid of coordinates
how do I generate all possible paths?
@Razetime {⍳⍺⍵}?
12:51 PM
@Adám I have {,⍳⍺⍵}, now I need cartesian power of n for that
1:18 PM
@Razetime You mean all combos of n coordinates? Like ∘.(,⍥⊆)⍣n⍨{,⍳⍺⍵} ?
1:49 PM
@rak1507 Super nice.
Thanks, do you have a link to your one?
@rak1507 afaict, bags⍳⊂⍵ must be a scalar, so isn't ⊃contained⌷⍨ the same as contained⊃⍨ ?
@rak1507 About:
text←⊃⎕NGET 'Day 7.txt' 1
bags←⊃¨'\w+ \w+'⎕S'&'¨text
Oh yeah, always forget about dyadic ⊃
If it is known that every line of text has exactly one match for the regex, I think the following would do:
text←⊃⎕NGET 'Day 7.txt'
bags←'\w+ \w+'⎕S'&'⊢text
No, they have more than one
1:56 PM
So you only want the first match for each line?
text←⎕NGET 'Day 7.txt'
bags←'\w+ \w+'⎕S'&'⍠'ML'1⊢text ⍝ ML: Match Limit
@rak1507 I don't have a working APL solution for this yet -- I did this in python first today. Will give it a go now, although having peeked at yours it feels a bit cheaty.
I did part 1 in python first, but it didn't translate very well as I used dicts and stuff
The APL ended up being nicer anyway imo
2:02 PM
@rak1507 Isn't there only one match of '(\d+|no) (\w+ \w+|other) bag' per line?
A lot cleaner than other solutions I've seen
@Adám no there are multiple
@rak1507 bags[⍸f⊂⊂⍵]bags/⍨f⊂⊂⍵ ?
If f is always called with a doubly enclosed argument, you could move that double enclosing into f.
2:06 PM
Do you know f as it is even speeds things up over ngns? The timing seemed to vary, I know ∊∘something speeds it up, but does ∊¨∘something?
And then…
One thing I wished Dyalog's ⎕S would do is to just return any (capture)(groups) as a vector, like python does for re.findall(r'(\d+)(\w+)', string). I find myself having to do:
2:07 PM
which isn't APL-concise.
What you can do is make it into a string and then use ⍎
{bags[⍸f⊂⊂⍵]}¨⍵(bags/⍨f)¨⍵ I think.
But that's a bit grim
If you know how many capture groups there are
@xpqz @rak1507 Yes, this should obviously be 1↓⍵.Matches. The problem is the overhead of constructing that every time. I do have a solution that I've proposed to Richard Smith (who handles ⎕R/⎕S) that avoids the overhead until needed, but nobody seems to have complained about this. If you (two) do, then maybe he'll take me up on it.
@Adám this could be added as "cartesian power" in aplCart
2:11 PM
@Razetime But it is simply a combination of "cartesian" and "power" and "indices".
@xpqz Why the final ⊃,/? Also, did you get that from APLcart?
github.com/rak1507/Advent-Of-Code-2020-APL/blob/main/… ok, used some of your suggestions (I used ^ in the regex to ensure one match)
That's from notes I took last time I raised this in this chat room.
@Adám Without the final ⊃,/ every item is enclosed one too many levels.
if you ¨ over a set of vectors
If you don't ¨ then it's not needed.
But you don't have a ¨ there.
      '(\d)(\w\w)'⎕S{⍵.(1↓Lengths↑¨Offsets↓¨⊂Block)}'1bc2ef' '3hi4kl'
@xpqz Btw, if you find yourself doing this repeatedly, you could define Groups←{⍵.(1↓Lengths↑¨Offsets↓¨⊂Block)} and then use ⎕S Groups
2:30 PM
Hello Adam
@Snapdragon-X Hi there. Interested in APL?
@Adám Whats APL?
Also, am deleting my comment from Meta SE.
@Snapdragon-X Oh, you're Queenie Goldstein?
2:35 PM
@Adám Ohh, it's called APL. I have come across 100s of posts on code golf which write seemingly complex code with just a few bytes/characters. Thanks!
@Snapdragon-X As a math and pħysics ∊nthusiast, APL might well be to your likings, actually.
Yeah I am pretty much interested
Want a 15 min intro?
@Adám Just a wild thought, can it be implemented on Neural Networks...because that's what am currently learning
sure, an intro would be nice
You mean, can it be used to implement NNs? Yes.
OK, so the first thing to take in is to discard the notion that APL is a programming language (despite the initialism).
2:39 PM
Rather, it was created as an alternative to traditional mathematical notation (TMN).
So a lot of things in APL are identical to TMN, or are generalisations and/or harmonisations of parts of TMN.
Cool...One question, how do you write the symbols ?
For the immediate need, check out this.
Like this : A27FÀDûˆ}¯û»
2:41 PM
there's also the tryapl expansion tool
So APL uses proper × and ÷ for multiply and divide. * and / mean something else.
@Razetime Huh?
Btw, feel free to experiment right here in chat; just begin code with a diamond: ⋄ 3×4
@Adám 12
@Adám the new feature which converts ascii symbols to an APL symbol
@Razetime That's part of the in-browser lb.
2:44 PM
yeah, the tryapl website
@Razetime Even the bookmarklet one.
oh, didn't know that
⋄ 3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3*3
@Snapdragon-X DOMAIN ERROR
2:46 PM
* is Power!
@Adám did you copy paste the diamond sign and X...or using Alt+****
@Snapdragon-X I have a keyboard layout installed, but that in-browser language bar I linked to will make it easy to type them too.
Now take TMN's ∏ and ∑ notations. They are simply reductions using × and + respectively. APL generalises these into / which allows you to "insert" any two-argument ("dyadic") function between elements of a list ("vector"):
⋄ +/(3,1,4,1,5)
@Adám 14
@Snapdragon-X If you have the bookmarklet active, then typing letter <> and pressing Tab will create ⋄ while xx (lowercase XX) and Tab will make ×.
bookmarklet...is like a MAthJAx renderer? I mean where's the link to it
2:51 PM
No, these are Unicode symbols. Just go here and drag the "APL" link to your bookmarks bar. Then come back to this page and click the bookmark (it won't navigate away).
⋄ +/(3,1,4,1, +/(3,1,4,1,5))
@Snapdragon-X 23
This is quite cool
I'll lookup these information and do my homework!
Will get back here @Adám ! Thanks and @Razetime
For sure. See you around. Just ping me!
2:53 PM
@Snapdragon-X good luck
Thank you, might create a room to compile all the info!
do my homework! by homework I meant looking up these...not school work lol
@Snapdragon-X Feel free to post ideas and findings here. Maybe others will be inspired or have constructive feedback. You may want to check out the APL Wiki learning resources.
Sure, I will...currently my queue is full i.stack.imgur.com/aaMlB.png
3:12 PM
@Adám I did not know about this NN workshop & YouTube videos by RGS. Great ! Will watch them.
@brgal Also this and these.
@Adám Thanks. Mike Powell papers are more than great ! He is preparing a CNN paper too.
@Adám Šinkarovs, A., Bernecky, R., & Scholz, S-B. (2019). Convolutional neural networks in APL. In J. Gibbons (Ed.), Proceedings of the 6th ACM SIGPLAN International Workshop on Libraries, Languages and Compilers for Array Programming (pp. 69-79). Association for Computing Machinery. doi.org/10.1145/3315454.3329960
@brgal Ooh, that looks really interesting. (Though, the identifier names there seem to be invalid.)
3:28 PM
@Adám This was a 2019 paper by different authors. However Powell is preparing also a CNN paper. "Convolutional Networks", M. Powell, unpublished. It is mentioned in aplwiki.com/images/f/fa/4_The_Handwritten_Digits_Model.pdf
Someone should make an APL Wiki page "Neural network" that has all these links, kind of like Conway's Game of Life.
Yeah, I was just about to say ^
@Marshall Will you or shall I initiate a stub page?
@Adám You.
3:50 PM
@Adám @Marshall I will help listing APL links, papers...
just wrote an answer for
Q: Numbers on a Chain

absintheSome positive integers can be shown to have a property called Chain divisibility. For a number to be chain-divisible by n, it must fulfil three requirements: Each digit divides the number formed by the n  digits that follow it. For example, the number 7143 is chain-divisible by 2 because 7...

is this working alright
and are there any golfs I missed?
@Razetime many :)
@ngn lol
@Razetime ('\d'⎕R'|')num -> '\d'⎕R'|'⊢num
4:05 PM
@Razetime {⍵/⍨(⊢≡∪)¨⍵} -> t/⍨(⊢≡∪)¨t← -> t/⍨t≡¨∪¨t←
@Razetime (≠⊆⊢) is used 3 times, you can put it in a variable to save a few bytes
@ngn ↑ added that in
@Razetime 10÷⍨⊢/⍵ -> ⊢/⍵÷10
@Razetime {×≢⍵:⊃⍵⋄'no answer'}…⊃(…),⊂'no answer'
⍎⊃,/,/ -> ⍎∊
4:21 PM
@dzaima gonna save this one
4:34 PM
@Razetime 183
@Adám woah
@Adám wrong answer?
@ngn How so?
or maybe either you or razetime changed the order of the tests
@Adám compare to the output from this
@Adám sorry, it's not you. this seems to be the first version that produces a different output.
p/⍳≢p -> ⍸p
'0'/⍨+/p -> p/'0'
4:53 PM
@ngn gives a domain error on the last two tests
version on tio too old?
@ngn p/'0' -> p/⍕0
@ngn extended hates this program, maybe I'll try this on tryAPL
@Adám how do i use tradfns in tryAPL
@Razetime Not currently possible - on the wish list for next year I think (but who knows)
5:06 PM
5:19 PM
this explanation took a while
@ngn I don't see this using any 18.0 features.
@RikedyP @Razetime Really‽
@Adám Oh yeah I forgot about that lol
death to tradfns!
@ngn I'd say so too if dfns weren't so broken.
@Adám well, fix them :)
5:29 PM
@Adám What's broken about dfns?
@ngn Can't. The curse of a user base with existing code.
@voidhawk {0⋄1} returning 0; ⍺← not respecting the semantics of ; not having a proper if (or cond), only guards; :: captures the scope at its own location and ignores later variable bindings, etc
@voidhawk … ⊢{a←1 ⋄ }0 giving a value error; can't trace into a one-liner dfn; →0 in the session quits instead of resuming execution; plus←+ ⋄ a plus← and plus←+ ⋄ 1 plus a←2 overwriting plus; :: failing to catch ⎕SIGNAL etc.
I see
@Adám oh nice
5:38 PM
@rak1507 My day 7 for comparison if you want a laugh
@voidhawk @ngn Oh, and I recently came upon another one: {a←2⍴⍨s←⌊⎕WA÷3 ⋄ a←s⍴2 ⋄ a←s⍴2} fails with a WS FULL on the last statement!
I really need to get more comfortable with ⎕R/⎕S rather than using ⊆ for all my parsing
@voidhawk Except for performance. PCRE is slow.
@Adám That's true
Though for some simple cases we actually detect that the task can be done faster in APL, and substitute APL code for your regex, under the covers…
5:44 PM
@Adám why is that? c programmers don't free memory properly?
@ngn For the sake of :: (even if entirely absent from the dfn) a new stack frame is created for each assignment!
This came up because I suggested allowing :CtrlStructs in dfns. The answer was that this would WS FULL:
    :For i :in ⍳3
in BQN, will I have to GC environments?

Ill have to keep variables in the process dictionary along with a unique reference to it. do I also have to keep environments anywhere besides the current stack? (do i need to refer to environments when theyre not being executed?)
figured out how to simulate mutable, pass by reference in erlang
5:53 PM
@cannadayr yeah. DFND/case 15 can keep the environment around for as long as an object
@cannadayr Yes to all those. A function (or modifier) has a reference to its environment and can be stored anywhere.
ty ty
this is my current schema

-record(h,{h}). % env heap
-record(e,{t,f,p}). % env. tag-frame-parent
-record(x,{x}). % variable heap
-record(y,{t,i,v}). % variable, tag, indices (list of integer pairs [a,i] that index into environment), value
where 'h' and 'x' are stored in the process dictionary
i think this is on right track.
@cannadayr So each variable knows what environment it's in but not vice-versa? Or is there more data in an environment that I'm not seeing?
i could be naming them wrong. in this schema 'f' will be a list of variable references.
that will point to a unique variable reference in the process
the process i was going to keep which indices its been inserted at in the environment, so I dont need to map over every variable in every environment (altho that might not be that expensive)
That makes sense then. I'd say "slots" instead of "frame".
6:02 PM
the reasoning is when I update a variable, I need to create a new variable, give it a unique reference, then go thru every reference in every environment that points to the old reference and update it
<zakkor12> hi guys!
@cannadayr Is there a reason a variable actually needs to be its own entity? Probably relatedly, I don't understand what the indices field is doing.
<zakkor12> I'm having a hard time trying to figure out the proper way to iterate through each "box" in this matrix. I can only get the first row or last row, but not each element in it: i.postimg.cc/bv0WTDV6/image.png
zakkor12: If you mean you want to reduce over all the elements ("iterate" is a little ambiguous), you should turn it into a vector first with Ravel (,).
Or ⍤0
6:06 PM
@Marshall why I separated environments and variables?
<phantomics> To iterate across each item in the array one-by-one as a vector, you can do { ... }¨,A
<zakkor12> thanks so much guys, that's what I needed :D
@Marshall are variables "contained" in an environment?
re variables: all i need is a list of tuples that contain a unique reference and a value.
i put them in the top level of the process dictionary because i wasn't sure their lifetimes
@cannadayr The way I'd describe it, the runtime doesn't really have a concept of a "variable". There's an instruction to get the value from a certain slot, and an instruction to store the value, and one to make a reference to a slot to store something there later.
@Marshall which function is this? "reference to a slot to store something there later"
@cannadayr LOCM.
6:13 PM
what i was thinking was to use the slots to store either undefined (when the env is initialized) or a variable reference. the variables would be stored separately (either in the same environment or at the top-level of the process dictionary)
it might be possible to store a tuple of {reference, value} in each slot instead
might duplicate a little but likely wont be that bad
the reason i need a reference and some entity to connect it to is to enable pass-by-reference semantics
@cannadayr I think it should store undefined or a value reference instead.
@Marshall and that value reference - can I store it within the environment where its set? or can it be referenced from other environments?
@cannadayr The same value can be referenced multiple times, but that's why you would store a value reference instead of just a value. It's the environment that should be passed by reference to allow it to be mutated.
this might make more sense. still using bad variable names

1> bqn_heap:hset(Xt,{0,0}).
[#e{t = #Ref<0.1455890296.4137680897.52750>,
f = [#Ref<0.1455890296.4137680897.52742>,undefined,
p = undefined}]
ive got a reference "#Ref<0.1455890296.4137680897.52742" which will map to a value
i was originally thinking that the values it maps to would be in the process dictionary as a separate entity from the environments
    something like
    12> get(x).
[#y{t = #Ref<0.1455890296.4137680897.52742>,i = [],
    v = [1,2,3]}]
but if i can store the {reference,value} tuple list in the environment that would simplify things
@cannadayr Values are immutable, so I don't think that's necessary. Of course a block function or modifier will have a reference to its environment, but that reference never changes.
6:21 PM
Hey folks, I am very new to APL, and still have tons of tutorials etc. open. I've managed to do Advent of Code 2015-01 in Dyalog, but have TODO notes on what I feel is probably possible but am missing the operators / idioms for. Help for any of these would be greatly appreciated!

⍝ TODO: somehow use '()' and - instead of two separate strings?

⍝ TODO: can I flip the ⍳ so that I don't need to parenthetize and the ¯1 can go to the left?
(These are working correctly, I'm just wondering about more idiomatic way to write them)
@MartinJaniczek 1 - '()'∘.=⍵ (or the reverse idk); 2 - (…)⍳¯1¯1⍳⍨…
Btw, if you post multiple messages in a row, they'll merge visually, but markdown will be allowed.
@cannadayr If I'm understanding the way you're using references here, you can just store the value in the environment directly (and the implementation will use pointers if the same value gets stored in multiple places).
I did both parts like this (⊃⌽l),¯1⍳⍨l←+\3-2×'()'⍳input but I don't think it's ideal
1 1 0 0 0 0
0 0 1 1 1 1
I feel like I'm failing at this multiline stuff :D
that's great ^ though
6:23 PM
@MartinJaniczek Ctrl+K to do multi-line blocks. (It inserts 4 spaces before each line.)
@MartinJaniczek multiline messages have no markdown, except ctrl+k-ing. Separate messages definitely don't keep markdown
Understood. So, what I was trying to do with =/ etc. is done with ∘.=
@MartinJaniczek You can do +/-⌿'()'∘.='(())))'
i dream of a chat with a mono font and no formatting at all
Of course you do
6:26 PM
@MartinJaniczek A more mathematical approach: +/¯1*')('⍳'(())))' (assuming ⎕IO←1).
@ngn i definitely very much like clear visual separation of code and text
<moon-child> @ngn IRC is this way ;)
@ngn That's okay, lots of people don't dream in syntax color.
@Adám The first one (+/-⌿) is basically what I wanted to express the first time around
@MartinJaniczek Another approach: +/2-') ('⍳'(())))' (again assuming ⎕IO←1)
6:29 PM
@dzaima Thanks @Adám and thanks @dzaima for the flip operator!
im not sure that will translate to erlang. it doesn't have pointers, and you can't update a variable after definition (except in the process dictionary).

so if i declare a variable
a ← 1‿2‿3

then update it later
a ↩ 4‿5‿6

i have to do either:

1. create a new value 4‿5‿6 with a new reference. and update all references pointing to 1‿2‿3 to this new reference
2. update the value at the reference to 1‿2‿3, in which case it is no longer immutable
its very prolog-y
references dont have any data associated w/ them, theyre kindve a unique value that you can compare for equality.
@cannadayr The variable is a slot in the environment, so you should change it by modifying the environment, not anything else. The actual value 4‿5‿6 is completely distinct from 1‿2‿3 in BQN as in Erlang.
You don't want to change all references to 1‿2‿3, just the specific reference a.
@MartinJaniczek You're welcome. Btw, do you know about APLcart?
@Marshall lemme mull on this more after my meeting
6:34 PM
@dzaima a∘.='()' is implemented as ⍉'()'∘.=a as of 18.0.
From my Outer Product talk commentary, "while version 17.1 uses the same strategy for comparison as the other operations, 18.0 swaps sides and reverses the comparison to compute a transposed result."
@Adám Haha admittedly I was searching for flip in there
@MartinJaniczek Yeah, I just added that keyword now.
7:27 PM
so i can store variables as values in a slot. for example:

[[1,2,3], undefined ]

however, if I want to make a reference to [1,2,3] (like in LOCM), i would need some way of consistently indexing it.
so maybe i do something like

[{ref1, [1,2,3]}, undefined]
if its going to have the same slot index in the same environment i could return an environment reference and integer
that might be better
easier to match on, fewer references (theyre cheap but not zero), less of the heap to search thru
7:52 PM
@cannadayr LOCM should store a reference to the environment, and the slot number. That's the way I do it in JS. It avoids having to put any extra structure into the environment.
im much less confused about this this week..

[a,i] = id would become {r,i} where r is the reference.
'set' will change a variable in the slot
'get' will return the environment tag and slot index.
'ge' will return {r,i}
8:39 PM
^ likely wrong ill have to go thru stuff again when i have time
@cannadayr ge just returns the environment reference: [ge(e,num()),num()] is the environment and slot. Otherwise all good, I think.
2 hours later…
10:55 PM
I opened up apl for the first time in a while and I'm knocking off some rust
Need help with anything?
⋄ 'rust'(,⍣¯1)'rusty'
@Adám y
10:58 PM
I'm confused about why (1.5×⍺)/(10 0 0 0 0) is different from ×/(10 1.5 1.5 1.5 1.5) (ngn/apl)
(1.5×⍺)/(10 0 0 0 0) gives 10 15 15 15 15
What is ?
oops, I mean {1.5×⍺}/(10 0 0 0 0)
Try inserting the function between the elements.
{1.5×⍺}/10 0 0 0 0 is 10{1.5×⍺}0{1.5×⍺}0{1.5×⍺}0{1.5×⍺}0
Haha, ,⍣¯1, that's great, didn't know you can do that
Since all functions ignore their right argument, this is simply 10{1.5×⍺}dummy or 1.5×10
11:02 PM
arg, I was thinking (10×1.5)×1.5
but is there any whay to change this
@rak1507 ⍣¯1 is a pathway to many abilities some consider to be unnatural.
It seems like magic
I used it a moment ago to take the inverse of the triangular number function
Indeed it is:
      f←(3×*∘5)+(*∘4)+(4×*∘3)+(*∘2)+(5∘×)+9⍨ ⍝ f←3x⁵+x⁴+4x³+x²+9
      f⍣¯1⊢43657767 ⍝ f(x)=43657767, for which x?
@all find the first 5 elements of a series given a function and an initial value
like `10 f {1.5×⍵}` -> `10 15 22.5 33.75 50.625`
@Wezl What are you trying to do?
@Wezl ⋄ ⎕IO←0 ⋄ 10×1.5*⍳5
11:06 PM
@Adám 10 15 22.5 33.75 50.625
solve a math problem "Write the next three terms if the sequence is geometric
10, 15, "
@Wezl (btw, use two messages; they'll be visually joined, and markdown will work.)
It's easy enough by hand but boring
@Adám I guess I forgot the two ways to do everything in APL
(but I'm supposed to be learning about recursive definitions A(n) = A(n-1) ...)
@Wezl How about ⋄ More←{⍵,⍵[1]×(÷/⌽⍵)*1+⍳⍺} ⋄ 3 More 10 15
@Adám 10 15 22.5 33.75 50.625
11:11 PM
@Wezl I don't see how a recursive solution is a good fit for this problem.
@user14783281 Hi Amana. If you want to chat here, send me an email: adam@ with the same domain as www.dyalog.com
@user10529431 Hi Saif. Interested in APL?
@Adám ſ: I agree. Presumably I'll be learning other approaches soon

« first day (1412 days earlier)      last day (284 days later) »