« first day (1177 days earlier)      last day (1467 days later) » 

12:06 AM
didn't expect this to perform worse
 
ngn
@dzaima in a tall matrix has better locality than in a wide matrix
 
@ngn but i'd expect it to be way more vectorizable, and it should still be very predictable
 
ngn
@dzaima well, true
@dzaima 1=⍵:⍪0 -> 0=⍵:1 0⍴0 if you want to support n=0. this doesn't affect performance
 
@dzaima i'm guessing its because of the complicated ,/
 
@dzaima is this just "if something on your left has ≤ your ⎕NC you can resolve, ⎕NC ∊⍳3"?
 
12:21 AM
not an improvement, but still a nice idea
@AntonDyudin i don't think it's that simple
 
ngn
@dzaima i would expect it to be better without rotate
 
okay not precisely ⎕NC but like, a mapping of 1 for scalars 2 for functions 3 for operators (and I guess for ⎕NC that's 2 3 4 respectively)
 
@ngn memory moving due to should only be around O(n^3) where n=9, would it really make that much of a difference?
@AntonDyudin i really have no clue from what that 4 comes from, but it's possible that's related
 
@ngn @dzaima Mine is at around 3ms
 
ngn
@Bubbler you should time the two together
 
12:39 AM
wat i just removed logic and it still works. ¯\_(ツ)_/¯
(i've removed that r← like 3 times and it keeps coming back :|)
 
ngn
@dzaima what.. how is that so much faster than your previous attempt?!
so, this returns a vector of vectors, but it's faster even if you mix at the end
 
@ngn concatenation is hard. Also this is a thing for some reason
why, i don't know, that's what i meant by "removed logic"
it performs horribly in dzaima/APL, even though i do have special code for double ,/
 
ngn
at this point my own solution has been beaten :(
 
i never expected that apl would be able to achieve anything near this performance for generating permutations
 
ngn
12:54 AM
@dzaima (⊃,/)¨ -> ∊¨ not much improvement, but simpler
 
@ngn why does that speed up dzaima/APL 2x‽ it has to convert back to an array of Nums and convert that back to doubles :|
i may have one more idea
it's a little worse. but what can you expect
 
1:12 AM
@dzaima ah, it's checking specifically for DoubleArrs, whereas here there is a SingleItemArr
 
ngn
@dzaima no offence, but you ain't gonna get top performance with java
 
@ngn but ,/ just shouldn't be 2x faster than , it's special-cased for this exact usage!
currently rewriting for it to not use ArrayList<Double>, though that already shouldn't have worse performance than ArrayList<Value>
that really was the problem. Obviously, not Dyalog performance (as it rightfully should be in any sane APL code), but 10x better than before just by not being lazy by using an ArrayList<Double>
 
ngn
1:29 AM
ok, never mind
here's another rewrite of your solution: {{∊¨(⍳1+≢⍵)⌽¨⊂⍵,⊂(≢⊃⍵)⍴≢⍵}⍣⍵↓⍪⍬}
 
@ngn nice, no pointless recursion
 
2:12 AM
ah I see what you mean by "arbitrarily deep stack under the 4 at a time lookbehind"
 
2:58 AM
@Adám I think I've seen the dfns workspace contain patterns like
      {corec←{⍬≡⍵:⍵⋄1+(⊃⍵),ursion 1↓⍵}⋄ursion←{⍬≡⍵:⍵⋄2+(⊃⍵),corec 1↓⍵}⋄corec ⍵}⍳6
2 5 7 10 12 15
 
3:15 AM
@AntonDyudin corec-ursion lol.
 
4:09 AM
@Adám is ⍙CallRL "Call Runtime Library"? I tried to dig through Conga to find the wire format used to represent APL arrays for RPC, and I think I've bottomed out in system functions :P
 
 
5 hours later…
9:18 AM
I'm cracking on with the Dyalog student competition problems. Here's my Farey sequence (2015, problem 3): tio.run/##SyzI0U2pTMzJT///…
That's basically the recurrence from the referenced Wikipedia article.
Given that these problems supposedly are designed to show case APL's array-ness, I feel I must have missed something central here, even if my solution works as advertised.
Anyone want to offer up a proper solution, or golf mine to death?
 
I coded something a little while ago, but it's far from a proper solution
{f←,(0,⍳⍵)∘.,⍳⍵ ⋄ d←÷/¨f ⋄ k←(⍸d≤1)∩{⊃⍵}⌸d ⋄ f[k][⍋d[k]]}3
0 1 1 3 1 2 2 3 1 1

f←,(0,⍳⍵)∘.,⍳⍵ ⍝ all combinations concatenated together as a simple vector (store this as f[raction])
0 1 0 2 0 3 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3

d←÷/¨f ⍝ determine the actual value of the fraction for sorting (store this as d[ecimal])
0 0 0 1 0.5 0.3333333333 2 1 0.6666666667 3 1.5 1

k←(⍸d≤1)∩{⊃⍵}⌸d ⍝ find the first occurrence of each decimal value (simplest fraction) and see where these indices intersect the set of those decimals less than or equal to 1 (terminating value for the Fare
Formatting on that isn't ideal
 
I don't think everything on the competition is about array-oriented programming.
Some could be functional programming, some could be mathematics, some could be simply misc. problem solving.
 
@xpqz also, I did find this after writing mine some time ago: rosettacode.org/wiki/Farey_sequence#APL
 
9:48 AM
@JamesHeslip that's a nice approach.
 
@xpqz Thank you. Not the most efficient by any stretch of the imagination. I too was curious if there was a one-liner idiom type piece of code I was missing? @Adám?
 
I guess my recurrence avoids the sorting etc.
 
My approach would be: generate all fractions of num=0..n-1/denom=1..n, filter by "is it a proper reduced fraction?", then sort it by its value.
 
Code golf mini challenge for the orchard?
 
I'm in :)
 
10:00 AM
@xpqz Avoiding sort is one thing, but you're again using the Python reference impl, which isn't good (as you already saw before).
 
Yeah. Always hard to change ones stripes.. :/
 
Yet another way: Farey sequence = Stern-Brocot tree between 0/1 and 1/1, filtered by denom <= n.
 
@Bubbler So James' version is wah-hay faster than mine :/
To the extent that for n=1000 mine doesn't terminate.
Pythonesque or not, that does actually surprise me.
Why is mine infeasibly slow here, I wonder?
Even with Dyalog's tail call elimination, is it the case that recursion is rarely a good idea?
 
10:22 AM
I think it makes the interpreter parse the function over and over (which is slow), and the recursion depth (or iteration count) is O(n^2).
I can't find any other explanation for that
 
Yeah - James' version will be O(nlogn)
@JamesHeslip I offer yours as a 1-liner:
{f[k][⍋d[k←(⍸d≤1)∩{⊃⍵}⌸d←÷/¨f←,(0,⍳⍵)∘.,⍳⍵]]}
 
11:02 AM
@xpqz Ooh, that looks neat(er)
 
11:27 AM
{(⊂0 1),,⍳⍵ ⍵} is faster than {,(0,⍳⍵)∘.,⍳⍵} (for the small number of ⍵s I've tested), and gives fewer unnecessary fractions with 0 as a numerator to whittle down.
Same number of chars too
 
 
2 hours later…
1:20 PM
Any idea how I'd "turn off" all 1s in a bitmask after the first (l-r)? So to go from 0 1 0 1 1 0 to 0 1 0 0 0 0, for example.
 
1:32 PM
@xpqz <\?
 
1:51 PM
wow
I'd never thought of that. Obvious once you know how.
Thanks.
 
RGS
2:39 PM
@xpqz What is the (l-r) here?
 
@RGS left to right?
 
RGS
Ah, I thought l and r were integers.
 
@RGS I could be wrong, but that's how I interpreted it :D
 
RGS
@JamesHeslip but that does make sense in view of dzaima's answer and the fact that xpqz looked satisfied with it
 
Left to right, yes
 
RGS
2:46 PM
thanks
 
2:58 PM
Dyalog Webinar shortly if people aren't aware: dyalog.tv/Webinar/?v=AgYDvSF2FfU
 
3:41 PM
Carrying on with the student comp problems, I'm in equal measures horrified and intrigued by my stab at 2015, problem 4: tio.run/##SyzI0U2pTMzJT///…
Had to drop my comments, due to message length.
Bound to be a better way...
Progressive Dyadic Iota
 
@xpqz if your message is multiline (a single leading/trailing newline will make it one), you lose markdown, but are able to have much longer messages, including links
(newlines are enterable with shift+enter or just copy-pasting)
 
Ah ok, good to know.
 
RGS
4:03 PM
When using ⍣ with a function to its right, does it check the condition before applying the left function once?
 
@RGS it can't, the right operand of is given both the current (as ) and previous (as ) result, and on the first evaluation there is no previous result
(i've been annoyed by that many times. sadly it'd require hyperators to have an equivalent of be applied to )
 
hyperators?
 
@xpqz hyperators - something that can take operators as arguments
@dzaima faster by optimizing ,/ even more. 20x slower than Dyalog is acceptable
 
RGS
4:56 PM
@dzaima that's why my interpreter crashed, then xD
 
@RGS i assume by "crashed" you mean got stuck in an infinite loop?
 
RGS
(I'm on Windows) the interpreter didn't really crash (as in stop abruptly), but it also stopped working in a way that is worse to what has already happened to me. This time I couldn't do the Action -> Interrupt command
 
@RGS right, now i remember making that not work
 
RGS
:D
 
on RIDE linux i'm able to successfully interrupt ⊢⍣⊢0. maybe there's some other thing that's uninterruptable, but i'm having trouble coming up with anything simpler
(RIDE has a separate "weak interrupt" and "strong interrupt", no clue what's the difference, but the first almost never works, and the second almost always does)
 
RGS
5:08 PM
(Never used RIDE, not even sure what the R stands for)
 
@RGS remote? it can be accessed between different computers, and even the browser
.oO(one day i might connect my android app to it, but who knows…)
 
RGS
I don't understand
I mean, I understand the concept of being accessible by different computers.
But is it one giant thing everyone has access to? Or do I set up my RIDE that I will then be able to access from different computers..?
 
@RGS you usually set up your own RIDE server and connect to it with a RIDE client (the shortcut does both automatically, within one app). Nothing prevents you from connecting to other RIDE servers that you have access to though
 
RGS
Ah I see
And why would I care about having a RIDE?
 
@RGS it's the only GUI for Dyalog on Linux, i don't recall whether Dyalog is trying to make it the main IDE on Windows too
 
RGS
5:15 PM
ah ok, that makes sense
 
RGS
@dzaima thanks!
 
5:29 PM
updated my "profiler" - ⎕PFX is but storing the timing info, ⎕PFO evaluates its operand once, and times the functions application
 
6:00 PM
,/¨ is still the slowest thing in permutations in dzaima/APL, but (!⍵-1)⍴⍵-1 takes a lot of time even though it does almost nothing (it creates a SingleItemArr, which doesn't create multiple copies of the number):
https://tio.run/##zVNPS8MwFL/3Uzx3aQu1JmnTNoI7elU8eS1jaKFTsWMIIpQhKrrKDhM8eNzBgzfnTS9@lHyR@pqOOlTceuvjhSS/9ye/95J0wqNBmOR5GyghBOT9w2E/6nVb53RLZm@b8mpsyduhhZa7S9Ctjc9nHX12t3cADJm9oo8Jhi5HH5XBBAwwcKjtvm6sodM6NWU2Uwu9CLBktuB/c60sF6KlBTZ3BfeZF3DoRXEcJVoblOOeJicjOUn/1ZcVkLR@kkrHSGLYPTs5BSW46YRxnODcP@6HMfQSgMoUDg4UgEsMe1p27PsKSFo/SaXTgntxg98MIcBLx9kXHrUptl2QQhhCxBaCU9dtEvmfT2mhgrIkypjtE
yep, about what i expected. ¯\_(ツ)_/¯
 
RGS
6:57 PM
What is the general name for an n-dimensional matrix in APL?
is it just "array"?
I'm specifically talking about well-shaped things with no boxes
Like
4
10⍴0
5 5⍴0
4 5 2⍴0
4 5 76 2⍴0
 
@RGS i believe so
 
RGS
hm ok, thanks
 
@dzaima *it definitely is. Any other term would be pointless
 
This is pretty good: aplwiki.com/wiki/Array_model
An array with no boxes is just "simple array"
 
RGS
@voidhawk perfect
@voidhawk so an integer matrix would be a simple array, right?
 
7:00 PM
You got it
"simple"/"nested" is also used in Dyalog documentation, e.g. help.dyalog.com/17.1/#Language/Primitive%20Operators/At.htm
"If g is a simple scalar or vector, it selects major cells in Y. If nested, it specifies indices for Choose or Reach indexing."
 
RGS
Thank you very much.
 
Do we have standardized names for rank 3/4 arrays? Cube/hypercube?
 
RGS
@voidhawk cube works for 3 dimensions
(talking from a mathematical point of view, here)
but even thought hypercube is used often with 4D "cubes", I'm pretty sure the "hyper" prefix can be used to refer to anything that has 4 or more dimensions
e.g. a hyperplane, in a space of dimension n, is a space with dimension n-1
edited: so if n=10, a hyperplane has dim 9, but if n=2, a hyperplane is one-dimensional
 
@voidhawk - I seem to see 'cube' occasionally used for 3=⍴⍴X; but no consistent usage for 4≥⍴⍴X.
 
RGS
Now what I wrote about the "hyper" for 4 or more dimensions seems to contradict the fact that a hyperplane might be one-dimensional :P I think the main point is that the "hyper" is for a variable number of dimensions and, when prefixing "cube", it usually implies 4 or more
 
7:08 PM
no results for hypercube in Dyalog's docs, and one ±mention (besides here) in this room
 
RGS
(sry, I mistakingly edited one comment when I meant to write a new one)
 
Tesseract?
 
hm, aplcart mentions tesseract
 
@voidhawk - I think the most frequent appearance of that term that I've encountered is in the (erroneous) usage in Madeline L'Engle's A Wrinkle In Time.
 
@dzaima not quite sure what that's meant to do though
 
RGS
7:17 PM
@dzaima it creates a matrix where the columns represent the coordinates of a unit tesseract
i.e. a "cube" in 4Ds
the unit hypercube is characterized by having its vertices with coordinates being combinations of 0s and 1s
 
7:37 PM
0
Q: Abbreviating and expanding IP v6 addresses with APL

RGSRecently I solved a challenge on abbreviating and expanding IP v6 addresses. For that matter, I had to write two functions, AbbreviateIPv6 and ExpandIPv6. The first function ought to take a character vector of a v6 IP address and abbreviate it like this online tool. The second function ought to u...

 
@RGS What year is the IPv6 challenge in?
 
7:53 PM
@Feeds @RGS ⎕FIXing ReplaceFirst every time in AbbreviateIPv6 is probably not good for performance..
 
8:46 PM
"simple" array = 326≠⎕DR ? (I suppose ⊢≡(⍴⊢)⍴∊ may be more informative)
 
RGS
9:11 PM
@dzaima Probably, but I don't know how to ensure that ReplaceFirst exists when Abbreviate is called
@voidhawk 2019
@Adám how was your holiday?
 
@RGS Good, thank you.
 
RGS
@Adám good to know! The other day you shared a picture with the chat and for some reason I was really moved by it
 
:-)
 
RGS
Do you teach APL to your family?
 
Adám is lucky; even while there is a mandate for separation, he gets to see his family. I couldn't; my sister is several states away and somewhat on the front lines, and my mother is in very nearly the highest-risk group - and I am damn certain that I've been exposed, even if I've never caught it (or at least haven't developed symptoms since it was identified).
(Hell, I'm in a fairly high-risk group, at least on paper...)
 
9:20 PM
@RGS Yeah, I've taught a little bit. Just today, we were singing Echad Mi Yodea and I asked my 8yo how I'd compute how many terms are mentioned in the song in total. He correctly answered +/⍳13 :-D
 
RGS
These are difficult times for everyone, even for the ones we think are lucky... We must make the most of everything :)
@Adám Nice! :D
 
@Adám :)
 
RGS
@Adám I have to ask a stupid question. I can't really sing. Nor can my brother. Nor can anyone in my close family, tbh... Can all of you sing..? Or is it so natural for you that you don't really notice (or care?) that some people sing badly?
Or people just don't sing that bad?
 
@RGS - surprisingly, people who "can't sing" alone actually tend to do better together in groups, unless the reason they "can't sing" is that they are truly tone-deaf. It seems that hearing other people provides better feedback than just hearing oneself, and you more naturally fall toward proper harmony.
 
@RGS Music and song is very prominent in Judaism. This means that everyone is exposed to from birth, and so anyone who isn't completely tone-deaf pick up singing fairly quickly.
 
9:31 PM
And if there's at least one person who can sing, the feedback is still better, and the harmony comes together faster.
 
@JeffZeitlin Right, my children tend to go off tune on melodies they don't know so well, if they are singing alone.
 
RGS
@JeffZeitlin This does make sense, yes
 
One does not hear oneself the same way as other people; you're getting it not just through the ears, but through your own bone conduction. You sound different to yourself than you do to others; you can prove it by recording yourself on the highest-fidelity recording system you can find, and then listen to that recording - that's how others hear you.
 
@JeffZeitlin I can't stand hearing my voice the way others hear it. Ugh.
 
RGS
@JeffZeitlin That one I know, I did experiments of that sort already.
 
9:37 PM
@Adám - Most people react like that, largely because they're used to hearing themselves differently. Without the 'internal' effects, you just sound wrong to yourself - and yet anyone else will say "that sounds just like you".
 
RGS
As you explained, I hear myself differently from what other people hear me, so I sound totally different than my brother -- at least to me. Other people often mistake us for one another... So sometimes my brother is doing a call on speaker and sometimes I join in when he stops speaking, and we trick other people into thinking I'm still him hehehe :D
 
Of course, but it isn't just the difference. I find my "real" voice annoying to listen to.
 
RGS
@Adám I think your voice is "normal"; at least from what I got from the couple of webinar videos I watched or started watching
 
@RGS - My father and I did that inadvertently. I cannot tell you how many times I answered the phone, and the person on the other end immediately launched into the 'business' of the call... until I stopped them and said "let me get him for you"...
 
RGS
And I'm pretty sure everyone else will say the same :D
 
9:40 PM
@RGS - I certainly will.
 
I feel the same way when listening to my AoC solution videos :(
 
RGS
@voidhawk What is AoC?
 
Advent of Code, a problem-solving competition that runs every year during December. This past year I recorded videos of my solutions in APL
 
RGS
@voidhawk sounds interesting :D
 
@voidhawk - Is there an archive that one can work through?
 
9:55 PM
Sure is, 4 years' worth: adventofcode.com
 
@voidhawk - Five, not four. But it's a little annoying that you have to authenticate to get the puzzles...
 
@JeffZeitlin Yeah, they generate a bunch of different possible puzzle inputs (to discourage solution stealing I guess), so you need to auth to get one assigned to you
 
RGS
Gotta go now
 
@AntonDyudin It does work, but note that ⍺⍺ has no value in +{⎕NC'⍺⍺'}⍬ because the braces create a function, not an operator as APL assigns type based on whether ⍺⍺ occurs or not, and it didn't — only the "random" character vector '⍺⍺' appeared. Try +{⎕NC'⍺⍺' ⋄ ⍺⍺}⍬
 
Hahh, I suppose it appeared in a rather roundabout way indeed
 
RGS
10:07 PM
@Adám let me just tell you a little smth that I managed to do today that I'm very happy about. I was solving the problem about the minesweeper board, where you have to create a board with random mines and then assign the adjacency numbers... I managed to code solutions that work for arbitrary dimensions, not just 2D matrices! e.g. 100 MakeMines 2 3 4 5 6 will create a 5D board with 100 mines randomly placed and then the CountMines also works for those nD boards!
 
@RGS In APL, the obvious solution often works on arbitrary data, not just of the dimensions you intended it for. (Square brackets are a notable exception, but we have a proposal to mitigate that too.)
 
RGS
I don't mean to impress you, the changes were fairly inconsequential and it wasn't really hard. But as a mathematician I like general things and writing utility functions for nD minesweeper games was cool :D
@Adám You are right, the MakeMines solution "accidentally" worked for nD arrays; I only needed to make a small tweak when reshaping something in the other function to make it also work for nD arrays.
 
As they say, the only important numbers are 0, 1, and "many" :3
 
@RGS Dan Baronet wrote a 4D web tic tac toe in APL:
 
For those of us with high hopes that Miegakure will come out sometime this decade
 
RGS
10:13 PM
@Adám Isn't this connect-4?
 
@RGS IIRC the APL back-end handles connect-n in nD.
 
RGS
sure, but I meant the name of the game. It's written "Tic Tac Toe" all over the place. But it doesn't look like it. On the other hand, it also doesn't look like connect-4 because it is a very small board...
 
@AntonDyudin That sounds simplistic. I want 3D goggles (VR glasses) that show me a picture of 4D space projected onto 3D space just like my normal 2D screen shows a projected 3D world quite realistically, where I still get a real sense of 3D depth despite the picture being 2D. Similarly, it should be possible to project 4D onto 3D and still get a real sense of 4D, no?
 
You run into issues where your eyes fundamentally receive a 2d slice and cannot see behind things without walking around them, but it'd be improvement on margin certainly
 
@Adám getting sense of 3D in 2D requires knowledge of how 3D-to-2D projections work very well, and i'd guess your experience with 4D-to-3D projections is a couple dozen magnitudes less than with 3D-to-2D
 
10:19 PM
See: this attempted visualization of a 2d -> 2d function, not sure VR would buy you a ton tbh youtu.be/vfteiiTfE0c
 
RGS
@dzaima I had a calculus professor that said he could imagine 5D and 6D spaces fairly well.
 
no it's simple, you imagine an n-dimensional space and then set n to 6 ;)
(kind of how I approach higher-ranked arrays tbh)
 
@dzaima Still, if I'd spend enough time playing with "physical" objects in 4D space while seeing with 3D vision, should I not be able to gain almost (due to being only visual and touch based) the same ability as a child born with one eye in a 3D world?
 
@Adám possibly. (also i'm pretty sure there are already many 4D visualizers for VR available)
 
@RGS I don't mind dealing with those in my head, though I can't really visualise above 4D.
 
10:21 PM
ah, vr with effective touch I imagine would be more significant yes
 
ngn
@Adám but you are seeing a 3d projection :) newtonian&einsteinian physics is 4d=3space+1time
 
10:36 PM
OK, I solved the first AoC 2015 puzzle, but I'm not sure that the way I did it is really the 'best' APL. The puzzle fed me a WHOLE BLEEPING BUNCH of parentheses, and basically asked me how many more/less )s than (s there were. My solution was to stuff the parens into a variable parens, then (+/'('=parens)-(+/')'=parens)
 
@JeffZeitlin -/+/'()'∘.=parens
If you're performing the same operation on the same data, just with different left operands, keep ∘.f in mind
 
Oh, that solution is slick.
Hmmm... working through it step-by-step... it looks like +/-⌿'()'∘.=parens works, too.
 
Or +/1 ¯1['()'⍳parens]
(which happens to feed nicely into pt. 2)
 
10:52 PM
@Adám if you're still here, what's your opinion on allowing ,∘'X'⍢(5∘↑) for "insert 'x' after the 5th element"?
 
@voidhawk You don't even need ∘.f in that case: +/¯1*')'=parens
 
@Bubbler - Won't work in this case, because the way I had to load parens leaves me with a newline at the end of parens that'll throw things off by one.
 
@dzaima At first glance, I like it, but I can't quite grasp the further consequences.
 
@Bubbler True. Btw, weren't you working on solving all the AoC challenges and containerizing them?
 
The same issue meant that I had to modify @voidhawk 's solution using ⍳ to accommodate that newline (1 ¯1 0[...])
 
10:59 PM
@Adám yeah..
what would it do on higher rank inputs? e.g. ,∘'_'⍢(2 2∘↑)5 5⍴⎕A
@dzaima probably error. But ,∘'_'⍢(5 2∘↑)5 5⍴⎕A? ⍪∘'_'⍢(2 5∘↑)5 5⍴⎕A? implementing that gets annoying fast..
 
@JeffZeitlin Are you using ⎕NGET ?
 
@AntonDyudin Yeah, eventually it calls the Conga shared library. I should get Bjørn (Conga guy) in here to help you. Certainly, if you email support@dyalog.com, Vince or Andy will forward it.
 
@voidhawk - Yeah. I suppose I could have done a ¯1↓ after pulling it all in...
 
@JeffZeitlin Or maybe ⎕NGET'file'1 to get a vector of character vectors?
 
@voidhawk Right, though my interest moved on before I could finish a single year's problems XD
 
11:03 PM
@Adám - It's all one line. I'm not even sure how the newline got in there, because I don't see it showing nonprinting chars in Notepad++
 
@JeffZeitlin ⎕NGET normalises file content (including ensuring a trailing line break, best UX style). ⊃⊃⎕NGET'file'1 should give you the line.
 
@JeffZeitlin I ran into this with single-line char inputs - the newline doesn't appear in any editor but is inserted into the char vector anyway. As @Adám said, I usually just use ⊃⊃⎕NGET 'file.txt' 1
 
(At least I'm assuming it's a newline rather than a EOF char.)
 
Beat me to it ;_;
 
@Adám personally i hate trailing newlines
 
11:06 PM
@dzaima They are convenient when you paste more lines at the bottom. I guess the idea is that lines are LF-terminated.
 
@Adám yeah, it's a unix or posix standard or something also. doesn't make me hate them any less
 
ngn
@dzaima i have a reason to love them
 
OK, I'm looking at the documentation for ⎕NGET - does ⊃⊃⎕NGET 'file' 1 leave me with the 3-item vector, or does that just return the content as a vector of vectors without newlines?
 
⊃⎕NGET 'file' 1 is a vector of vectors (IIRC)
 
@ngn what'd that be?
 
ngn
11:10 PM
@dzaima when parsing i mmap the src file and replace the trailing '\n' with '\0' because that's a convenient terminator for the whole file (the src file is reasonably assumed not to contain '\0'-s). if i had to append a '\0', i'd have to worry about copying the file elsewhere in memory, because its size might be a multiple of the pagesize(minus header).
 
So ⊃⊃⎕NGET 'file' 1 will give you the first line, without the trailing newline
 
@JeffZeitlin The first ⊃ selects the "content" from the 3-item vector, and the second ⊃ picks the first element of the vector of lines
 
@ngn haha that was exactly my guess
 
ngn
:)
 
@Bubbler @voidhawk - OK, thanks. And in ⊃⎕NGET..., the content returned is a vector of lines of text, with no trailing newlines/eofs?
 
11:13 PM
If you have the 1 at the end, yes
 
@voidhawk - Right, and a 0 (or omitting) leaves me with the newlines added.
 
In that case it would be a simple char vector containing the entire file, including newlines
 
/me makes notes in his APL notebook
 
One tip for AoC: You'll like dfns.segs a lot when you process various input files.
 
(~∊⍨)⊆⊢ ?
Guess I should look at the implementation first...
 
11:23 PM
@voidhawk looks like the implementation
 
Yeah
 
For more complex ones, dfns.words can help.
 
⊢⊆⍨∘~∊⍨ ;-)
 
 
11:49 PM
does Dyalog ever allow negative numbers in function bracket axis specification? i kind of thought it did, but it doesn't seem to
 
@dzaima Yes: ⎕IO←0 ⋄ 1,[¯0.5]2
 
@Adám ah, i don't have these half-axis things. Any case of negative integers?
 
@dzaima Not any I can recall off-hand. I tend to avoid bracket-axis when possible.
 
specifically i'm reworking them because i want to allow 2 3↑[1 3]A
i guess this happens just because i thought it did. ¯\_(ツ)_/¯
 
@RGS You should have a Dyalog D icon in your Windows system tray. Click on it, then "Strong Interrupt".
 
11:55 PM
@dzaima ah no, it's ngn
i think it's nice notation though, apart from the ⎕IO troubles
 
@AntonDyudin All arrays with 326≠⎕DR are indeed simple, but there are plenty of simple arrays with 326=⎕DR too, e.g. 'a'1 and #.
 

« first day (1177 days earlier)      last day (1467 days later) »