« first day (1357 days earlier)      last day (1313 days later) » 

1:12 AM
I have been reading about vintage computer and calculator lately, and I attribute this "clicking" on me to APL language. For example: youtube.com/watch?v=_DTpQ4Kk2wA
To some people it might dumb to programme on a command line via a teletype writer, but it appears to me as a very pure form of computing, which is beautiful in itself.
 
@TessellatingHeckler How did you get it? I just got two versions of 12's
 
@Bubbler not sure how to answer that without giving it away; I wrote it out and got a 13 with echo"0] and then used a trick from "Tips for programming in J" from StackExchange to get 12, and then looked at it thinking "11 is impossible" and then saw a way to make it 11
 
In J, a composition takes the rank of it's second operand (or something like that)
 
Oh damn, how did I forget that
 
 
3 hours later…
4:29 AM
{⍵/⍨((1=≢∘∪){+/,⍵}⌺2 2)¨⍵}{3 3⍴⍵}¨↓pmat 9
Is this function correct for getting all 3x3 sturdy squares?
26
Q: Print all 3 by 3 sturdy squares

Calvin's HobbiesA sturdy square (akin to a magic square) is an arrangement of the integers 1 to \$N^2\$ on an \$N\$ by \$N\$ grid such that every 2 by 2 subgrid has the same sum. For example, for \$N = 3\$ one sturdy square is 1 5 3 9 8 7 4 2 6 because the four 2 by 2 subgrids 1 5 9 8 5 3 8 7 9 8 4 2 8 7 2 6 al...

 
4:46 AM
p←'(()(()))' ⋄ ⌈/+\('('∘=-=∘')')p ⍝ 3 as expected
f←⌈/+\('('∘=-=∘')') ⋄ f p ⍝ Domain error?
Why is f not substitutable with its matching expression?
 
I have a probably stupid question. If I have an array, and I want to "extend" it along a new axis, what is the most concise way of doing it? Let's say I have a rank-2 array of the following form: 3 3 ⍴ ⍳9 and I want to make a rank-3 version by creating N "layers" of the same array on top of eachother.
The best I can think of is to do ((N,(⍴A)) ⍴ A. And if I want to extend along a different axis, apply the appropriate ⍉ operation afterwards.
 
@eyepatch You have a 3-train ('('∘=-=∘')'), then monadic application of +\ then ⌈/. But your f treats ⌈/ and +\ as part of an outer 3-train, so f p evaluates to (⌈/p) +\ (...)p
To make both ⌈/ and +\ into atops, you can write f←⌈/(+\'('∘=-=∘')')
@EliasMårtenson One way would be N⌿↑,⊂A I think
 
5:02 AM
Interesting. Obviously the atop solution is best here, but is there a way that I could switch back into monadic application?
 
@eyepatch No way in a pure train.
 
I would have to wrap the 3 train in a dfn or something?
 
You could add a wrapper dfn for a chain of monadic application, such as {⌈/+\⍵}'('∘=-=∘')'
 
Huh. Ok.
 
@Bubbler thanks. I'll try that.
@Bubbler hmm, that didn't work. it returns a rank-1 array with each element duplicated N times (if I set N=2, then I get an array with content 0 0 1 1 2 2 ...etc)
 
5:11 AM
@EliasMårtenson Which implementation of APL are you using?
It works in Dyalog APL at ⎕ML←1
 
5:31 AM
@Bubbler I'm testing in GNU APL
 
@EliasMårtenson Then maybe you could try N⌿⊃1⍴⊂A?
 
That worked. Thanks!
I also discovered a bug in KAP where ⌿ doesn't do the right thing.
 
Actually it can be simplified to ⊃N⍴⊂A (GNU) / ↑N⍴⊂A (Dyalog)
 
5:59 AM
@Bubbler thanks a lot
It seems to correctly. Thanks.
 
@EliasMårtenson N/[⌈ax],[ax]A where ax is fractional.
 
@Adám Oh wow.
 
6:15 AM
APLcart has (⍋⍋ax,⍳≢⍴A)⍉A⍴⍨N,⍴A which is very clever but more verbose, and slower.
 
When a task can be done cleanly with axis notation, I guess that should be on APLcart
instead of clever but obscure ones
 
Yup (and making it so now, but I suspect I got this from some idiom list.
 
6:34 AM
@Razetime Did you check the count of the result?
 
6:52 AM
@Razetime No, your is applied to matrices.
 
@Adám My machine is not strong enough to handle it
 
@Razetime Are you sure? How much RAM do you have?
 
Not about the RAM
It's fan stopped working
 
Oh. I have a 39-byter (using pmat) that can run on my machine, but not on TIO.
 
@Adám Just need to check if all sums are equal
 
7:01 AM
@Razetime Yes, but the sums are returned as a 2-by-2 matrix.
 
oh.
so then do it
{⍵/⍨((1=≢∘∪)∊{+/,⍵}⌺2 2)¨⍵}{3 3⍴⍵}¨↓pmat 9
 
Yeah, but it takes a very long time to run (I'm running something similar now) because of nested arrays. My flat version (the 39-byter) has acceptable runtime.
 
oh, like the other entries in the question
I just wanted to use window cause it sounded perfect for the task
 
Hm, one processor is getting hammered here. I should split this into 4 CPU threads…
Meh, the nested version isn't much shorter, since we have to split pmat's result anyway.
@Razetime Indeed. ≢r← s⌿⍨1=≢∘∪⍤1⍪+/,⍤⊢⌺1 2 2⊢s←3 3⍴⍤1pmat 9 runs in about 5.5 seconds by me.
 
@Adám 5 seconds, nice
is there any constraint for time defined?
 
7:12 AM
What? Where?
 
in the question
nope its not restricted
 
While most code golfs don't have time limits, having a solution that works fast always helps (especially when the task is nontrivial)
 
Now I really want to get that down to 2 seconds by using all 4 processor cores.
OK, I got it down to 3 seconds.
 
how do we verify it?
 
It has the right count.
This was s⌿⍨∊{1=≢∘∪⍤1⍪+/,⍤⊢⌺1 2 2⊢⍵}IÏ {⍵⊂[0]⍨(≢⍵)⍴1↑⍨4÷⍨≢⍵}s←3 3⍴⍤1pmat 9 using from isolate.dws (a polyfill for ∥¨).
 
7:24 AM
Don't remember seeing in extended
 
It isn't.
 
what does it do?
 
It is exactly like ¨ but runs each in a parallel CPU thread.
is a monadic operator just like &, but for CPU threads instead of "green" threads.
@Razetime GIF?
 
@Adám if you have one, sure
 
Working on it.
 
7:37 AM
nice!
 
Ven
8:06 AM
Hi, I'm looking for the snippet to (re)print trains without the extraneous parentheses. I'm tried a few keywords through the search and APLCart but no dice so far.
(my code is 1∘↓(+/⌽(⌽⍳7)∘~))
I guess 1∘↓+/⌽(⌽⍳7)∘~ is a first step...
 
8:27 AM
@Ven It is a setting of ]box but it isn't 100% reliable: ]box on -trains=def
It fails to keep a parenthesis to separate to adjacent arrays, e.g. (,∘1)(1∘,)
 
Ven
mh, doesn't seem to be allowed* on TIO or TryAPL.
 
@Ven Did you forget to separate the train from its argument?
 
Ven
I had no argument, the error comes from ]box
 
Is there a way to persist the settings of ]box and ]rows when saving a workspace as a .dws file?
 
@Ven Try APL doesn't allow you to change ]box settings, and TIO doesn't have ]box by default.
@xpqz It is a session setting, not a workspace setting.
 
Ven
8:44 AM
@Adám Ah, I always forget about SALT, thanks. I'm unsure about that 1×⎕io though...
@Adám Could you re-pin a link to APLCart, please? Though it's also very easy to google.
 
@Adám Does that save settings to a separate config file?
 
@Ven If you use DuckDuckGo, you can use the !aplcart bang.
 
@Adám That's convenient
 
@xpqz Yes, but you can probably deconstruct the entry to figure out how to save to your default/current file.
 
Ven
8:46 AM
Well, typing aplcart + click or !aplcart are about the same :). But good to know.
 
So ⌽⍳7 is "optimized" to an arithmetic using ⎕IO instead of costly reversing the array?
 
Ven
it's funny
 
RGS
9:06 AM
Shouldn't this add rows of the left matrix to the rows of the right matrix?tio.run/##SyzI0U2pTMzJT///…
 
@RGS What is your expected result?
 
@RGS Yeah but you need frame conformance (2≠5 and neither = 1)
 
RGS
@Bubbler something with shape s.t. ∧/ shape ∊ 2 4 5 gives 1
 
@RGS Worse than I thought - why does a 1-row matrix not extend but a vector does? hmmmm....tio.run/##SyzI0U2pTMzJT///…
 
RGS
(and s.t. ^/ 2 4 5 € shape also gives 1)
 
9:24 AM
room topic changed to The APL Orchard: Learn, teach, ask, code, golf, & discuss. See aplwiki.com/wiki/APL_Orchard for access and info, aplcart.info for simple questions. [apl] [array-manipulation] [j] [k] [tips]
@Ven How is that ↗
 
Ven
@Adám Perfect!
 
Maybe simple how-to questions?
 
@Bubbler Done.
 
RGS
9:53 AM
@RikedyP ah I get it, I expected it to do some kind of "cross-product" and add all rows of the left with all rows of the right
 
@RGS It works like scalar extension (but apparently not like singleton extension)
@RGS You can do that with multiple uses of rank ⍤j⍤k
 
 
1 hour later…
11:10 AM
{∧/(⍳⍵)∊(⍋⊃¨⊂)∪+/¨⊃,/(⊢,,¨)(∪⊢∨⍳)⍵} I made a delicate primes finding function
but I get a WS FULL error on very big numbers
 
Try to keep things flat for optimal CPU and memory usage.
 
11:37 AM
ok got it
 
 
1 hour later…
12:54 PM
how do I group equal runs of elements?
 
{⍵⊂⍨1,2≠/⍵}
Might be something cleverer
but idk
 
1:08 PM
If you know the runs are globally unique, you can use Unique Mask instead of 1,2≠/.
 
Now that is what I call something cleverer!
 
1:53 PM
As we're on the topic of partitioning, is there a better way than Xs {↓(⍺÷⍨≢⍵) ⍺⍴⍵} Y to group Y into vectors of length Xs?
 
I'm not quite sure what that does, can you give an example?
 
2 {↓(⍺÷⍨≢⍵) ⍺⍴⍵} ⍳6
┌→──────────────────┐
│ ┌→──┐ ┌→──┐ ┌→──┐ │
│ │0 1│ │2 3│ │4 5│ │
│ └~──┘ └~──┘ └~──┘ │
└∊──────────────────┘
3 {↓(⍺÷⍨≢⍵) ⍺⍴⍵} ⍳6
┌→────────────────┐
│ ┌→────┐ ┌→────┐ │
│ │0 1 2│ │3 4 5│ │
│ └~────┘ └~────┘ │
└∊────────────────┘
 
{⍵⊂⍨(≢⍵)⍴⍺↑1} maybe?
I don't know
Your one errors if it doesn't go exactly
Is that what you want?
 
I like yours better.
 
2:08 PM
Golfed: ⊢⊂⍨≢⍤⊢⍴⊣↑≢
 
Can you do this with stencil? I had a go but I clearly have a limited understanding of how it works.
 
@xpqz It has difficulty at the edges.
 
@rak1507 that is pretty clever
 
ngn
Jul 26 at 14:37, by ngn
@RGS -1 byte: ⍉|∘⍳∘≢⊢⌸⊢. btw, in k9 this whole thing is a primitive: ^ (the new "cut"), e.g. 2^"abcdef" -> ("ab";"cd";"ef")
(the apl train above returns a matrix, so it needs a split: ↓)
 
I think it also has a slightly different behaviour for non-clean divides -- it pads the last group, rather than leaving it shorter.
 
ngn
2:25 PM
yes
@xpqz there's no obvious way to design this primitve for non-clean divides. k9 just drops the last group. if you leave it shorter, or try to distribute the imbalance as evenly as possible in the result, like pre-k9 k did with its 0N 2#x there's danger of getting a length error when you do something like reduction on the result
 
@ngn My proposal is ¯1 for truncation, ¯2 for requiring exact divides, ¯3 for recycling.
 
ngn
@Adám that looks like something j would do :)
 
There's a precedent: (type,shape)⎕MAP allows up to one ¯1 in size for auto-sizing that dimension, and it truncates.
 
ngn
can't decide which is better, so to avoid responsibility, let's just put all the options in, and assign them hard-to-remember numeric constants :P
@Adám but just -1, right?
that's just a workaround for apl's lack of nulls, not j-bloat
 
Yeah, J's Cut operator does this in the extreme, so we decided on a specific subset for ― and got it pretty wrong, I think.
@ngn Yes.
@ngn We do have a null, though.
 
ngn
2:38 PM
@Adám quad null? that's not quite what i mean by null..
you don't even use it as filler in arrays where the prototype is a namespace
 
It is a null, and could be used for such. I know of at least one case where we use it as filler in arrays where the prototype is a namespace.
 
ngn
what is 2↑# ?
 
A 'NONCE' whatever that is :)
 
ngn
an error, no filler is used
 
# is not a namespace, but an instance of the Root class, so it would create additional instances of the Root class ― if that was allowed.
 
2:41 PM
APL errors are terse. But not quite as terse as k's ...
 
      i←⎕NEW⊂'Timer'
      2↑i
 #.[Timer]  #.[Timer]
      =/2↑i
0
 
ngn
@Adám "# is not a namespace" - really??
 
@ngn Yes, really: ⋄{⎕NC⊂,'⍵'}# 9.2 is instance, 9.1 is namespace.
@Moonchild Hey, where's the bot?
 
ngn
in any case, it would be better if you had a numeric null for ⎕map's left arg
 
@ngn How about '⌈' for round-up '⌊' for round-down, and '⊢' for require-exact?
 
ngn
2:43 PM
@Adám so, if i look in your documentation, i won't find instances of # being described as a namespace?
@Adám chars?
 
@ngn I'll be the first to claim out docs have issues.
@ngn Yup, or even functions if the array model supports it.
 
ngn
@Adám a char is not a number, just like a namespace is not a number
 
Lookming back through my notes, it seems we discussed the general matrix case of this a while back.
Non-overlapping sub-matrices.
This was one solution proposed:
 ⎕IO←1 ⋄ 2 2 {⊂[2×⍳≢⍴⍵]⍵⍴⍨∊⍺,¨⍨⍺÷⍨⍴⍵} 4 4 ⍴ ⍳16
┌→────────────────┐
↓ ┌→──┐   ┌→──┐   │
│ ↓1 2│   ↓3 4│   │
│ │5 6│   │7 8│   │
│ └~──┘   └~──┘   │
│ ┌→────┐ ┌→────┐ │
│ ↓ 9 10│ ↓11 12│ │
│ │13 14│ │15 16│ │
│ └~────┘ └~────┘ │
└∊────────────────┘
 
3:27 PM
@ngn So? Who cares about data types for small control arrays?
 
ngn
@Adám the implementation becomes more complex, as you need additional type checks
it's also bad taste to mix types like that
 
I would think you'd need additional checks even for special values, and taste is subjective.
 
ngn
@Adám yes, but on top of that you'd have to check for char/namespace too
 
Namespace?
 
ngn
ah, pardon.. "instance" :)
 
3:29 PM
What? Where? Nobody suggested using # as a special value here.
 
ngn
@Adám you suggested ⎕null at some point, if i understood correctly
 
⎕NULL is not an object (namespace/class instance) at all.
And, no I didn't suggest using it for . I was just commenting that we do have a null value.
 
ngn
@Adám =/⎕dr¨#⎕null whatever it is, you'd have to test for its type
 
@ngn Uh, =/⎕dr¨#('abc' 'def') so that doesn't say anything.
 
ngn
@Adám fair. what's the official way to get the type of something?
 
3:36 PM
@ngn ⎕NC but it requires a bit of fiddling because it takes a name, not a value.
 
ngn
it returns 2. so []null is a number?
 
      {⎕NC⊂,'⍵'}¨#⎕NULL('abc' 'def')⎕SE.Dyalog 42
9.2 2.1 2.1 9.1 2.1
@ngn No 2 means variable. 2.1 specifically means a normal array (not a ref).
 
ngn
i always forget these..
so how do i get the type of something then?
i thought []dr was the closest
 
Where type means what? number/character/nested/namespace/class/…?
 
ngn
@Adám yes
and it's ok to have multiple number types for 1-byte, 2-byte, 4-byte..
 
3:40 PM
It isn't really a thing though, as there are many types of namespaces, and many types of nested arrays too.
 
ngn
anyway
 
I'd say the type primitive applied to an array gives the right image, and if that doesn't work, then it is a namespace or class, in which case its type is itself, so {0::⍵ ⋄ ⊃0⍴⊂⍵}
 
ngn
why am i even telling you this. keep adding bloat and be happy.
 
What would you say is the type of 1'a'?
 
ngn
@Adám in k we call it a generic list
in apl: array of pointers, i guess?
mixed array?
 
3:44 PM
@ngn Bloat doesn't make me happy. Getting a salary doesn't really either, but it is unfortunately a necessary evil. I don't add bloat on purpose, but I do speak for increased utility to increase the chance that my salary remains.
@ngn Right, it isn't at all clear what type means, so asking what the type is isn't well-defined either.
I still think that we should make monadic be like old monadic (i.e. type) and I wouldn't mind extending that to return self if a normal type couldn't be gotten (as in my dfn above).
This would make the type of # be # and of a class be that class, while the type of an instance would be a new clean instance of the same class.
 
@Adám imo there are two types of types that matter - effective/visible type (so whether argument is namespace, number, char, array, etc), and internal type (array of 8/16/32-bit ints/64/128-bit floats/references, reference, simple (probably also split into simple scalar number & char))
 
ngn
4:00 PM
@Adám here's how i see things: you're getting a salary because (a.) your friends from management believe you're doing something useful and (b.) because customer lock-in guarantees stable profits. there's no conflict between customer needs (useful functionality) and good engineering (lack of bloat).
 
4:22 PM
@ngn True, but there is a conflict between customer lock-in and removing bloat. And catering to additional customer needs with a lock-in product based on sub-optimal engineering leads to bloat.
 
ngn
@Adám yes! that conflict's name is backwards compatibility
 
Correct. But it is also the case that backwards compatibility is a core locked-in customer need. Call it a bad self-perpetuating cycle, if you want ― it still pays my salary.
@dzaima "number, char, array, etc" ― what is "array"?
 
@Adám "array" is a thing with depth > 0
 
ngn
@Adám well, with the risk of repeating myself: there are solutions to this. afaik you don't have access to the complete source code of your customers, but you have a very small number of important customers. you can easily talk to them. you can give them a tool that patches old sources (like python's 2to3). if the key customers agree to change their sources, you can fix old mistakes, and the rest of the customers will follow.
 
@ngn I guess we could ask the few big ones. That might be a viable plan for migration to APL'.
 
4:32 PM
@ngn why do that when you could not? I certainly would much prefer for updates to take precisely 0 effort, certainly much more than "removal of bloat" when the "bloat" might contain things i use
 
ngn
@Adám and not only that, if adam manages to broker such a deal among all stakeholders, he might get a promotion :)
 
@dzaima (both types should also have function, monadic operator and dyadic operator, forgot about those (maybe it could make sense for fn/op to be the same "internal type", but i don't know))
 
ngn
@dzaima depends on what your horizon is. if you're looking forward to a couple of months, sure, it's easier to ignore mistakes. but in the long term they cost you more.
how many times have we bumped into that ⍳,n bug.. and how much would it have cost to patch a codebase or two, and fix it once and for all
 
@ngn and then another couple code-bases when production goes down due to it being relied-on behavior in edge-case error-checking. They certainly would much prefer it to not have changed
 
ngn
@dzaima if you're afraid of bears don't go in the woods. if you're afraid of making and fixing bugs, don't write code.
 
4:47 PM
@ngn there's a difference between going in the woods by my house where i know everything and a random place somewhere on the world explicitly called dangerous
 
ngn
@dzaima if you know the bug well, you can certainly write a patching tool for it
and if the patching tool fails.. well, you didn't know the bug well in the first place
 
@ngn at least for i can't imagine any solution other than replacing it with a call to a function that does what it did before working at all
and then, making (,1) + 1 2 3 error would mean replacing each and every scalar function with a wrapper
 
@dzaima Which would break in ⍣¯1 contexts, not to mention considerable slow-downs.
And replacing the + in +/ would give a different result too! That'd need another wrapper.
@ngn Dyalog did fix ⍳⍬ and it was a bit of a disaster.
 
ngn
@Adám so they'll never try fixing anything again :)
@dzaima if customers have test suites, that can be really useful here
maybe i'm too optimistic about automatic patching
 
@ngn though i obviously don't know, i wouldn't be surprised if enough things would still not get caught by it
@ngn APL is a pretty damn bad language for static analysis of data
 
4:58 PM
@dzaima data code?
 
ngn
@dzaima @Adám yep
 
@Adám code can be reasonably well parsed at compile-time and simple transformations can be automated if you're brave enough, but most of the problems are about specific shape/rank inputs, which you just can't know anything about most of the time
 
@ngn Not so, we later fixed the implied before control words, and gave a tool to track down such cases. That went so-so.
@ngn It would maybe be more feasible if Dyalog APL code was always stored in a consistent text file format. Remember that code can be source text files, workspaces, component files, external workspaces,…
 
@dzaima (remove "shape/rank"; Just "specific inputs" is good enough)
 
ngn
@Adám there was a certain guy at a certain company (no names for privacy) who was writing a tool for static type/rank/shape checking of tradfns's args and results, with declarations in the comments. what happened with that effort?
 
5:07 PM
Dunno.
 
5:20 PM
Does Dyalog implement monadic equals? I.e. is =4 valid?
 
ngn
@EliasMårtenson Try it online!
 
Thanks. So it doesn't. It seems like such an obvious character to give a function. I mean ≡ has a monadic version.
 
@ngn Bad test, since it fails for (TIO is on 17.1).
@EliasMårtenson Sure, but what function?
 
Is there a monadic ≠?
@Adám I was thinking of using it to force evaluation of a lazy value
 
@EliasMårtenson Interesting. That might be a good idea if we add lazy values…
 
ngn
5:24 PM
@EliasMårtenson yes
 
Right now, the only way to do it in KAP is to use ←, because assignment forces evaluation, which is why you'll see in my code the use of foo←foo to ensure that the variable doesn't hold a lazy value.
 
ngn
@Adám dennis of tio shows no signs of coming back. what are we gonna do..
 
@EliasMårtenson Monadic was taken verbatim from A Dictionary of APL. It might make sense to take monadic = too.
@ngn I really want to set up a similar service for APL. I was in talks with a 3rd part that could contribute a secure container.
 
ngn
@Adám will it support other languages?
 
@ngn I wasn't planning on it.
@ngn I'm sure the community would be happy to take over maintenance if Dennis would give over the reins. If he stays incommunicado, someone will probably create a mirror site. All the code is online. Dyalog could probably cover the costs too, but we don't have the manpower.
 
5:34 PM
@Adám Interesting link you gave me. The discussion of the parser in this document describes the first implementation I guess? It's fascinating to see that apparently it not only evaluated from right-to-left, but it also parsed the code from right-to-left?
That's somewhat bizarre to me.
 
@EliasMårtenson No, it is a very late document, after the mainstream APL implementors broke with Iverson.
 
@Adám I see.
@Adám A right-to-left parser sounds so strange. I'm curious why he did it like that? Perhaps it alowed the implementation to evaluate while parsing, thus not having to keep a parse tree in memory?
 
5:55 PM
@EliasMårtenson parsing in the direction of execution indeed means you can do the two at the same time, with the only temporary structure being a simple stack of evaluated but unused things
 
 
1 hour later…
ngn
6:57 PM
@Marshall did you try this? i hit a wall with bdf2psf and i don't understand what it's complaining about
 
@ngn No, sorry.
 
ngn
7:38 PM
i tried psftools. it's great - easy to build and use. so, if someone gives me a set of same-shape boolean matrices, i can easily make a psf font out of them.
 
8:22 PM
Doesn't Dyalog have a way to support language changes with ⎕ML? That they could use for breaking changes, opt-in to new improved APL' by setting ⎕ML to the year/month of release.
 
@TessellatingHeckler I don't know if ⎕ML would be the right "thing", but yes, I'm also envisioning using the same interpreter (or at least a very shared code base) for a "fixed up" APL ― APL'.
 
@Adám but you already have 'extended', lol. I'm beginning to wonder if array languages are as fractured as lisp yet. Does ~everyone who meets APL leave saying "I could do that better" and it never gravitationally captures enough people to solidify into a large and popular thing?
 
ngn
9:06 PM
@Marshall i've just discovered that what i'm looking for has been in front of me all along: apt-get install psf-unifont && setfont /usr/share/consolefonts/Unifont-APL8x16.psf.gz
 
 
1 hour later…
10:23 PM
<jcowan> Does anyone know of use cases for arrays whose shape includes a zero? They have no elements, but they are valid.
 
jcowan: They're used constantly. If your program works with a list of something but in a particular case there aren't any, then it should use an empty list.
 
jcowan: They are often used as initial value to which more is then appended.
38 messages moved to The Nineteenth Byte (Try to keep it on topic here. General code golf chat belongs in TNB.)
 
sorry; something a bit more on-topic: when I search APLCart for "/" it brings up a lot of things which have a / in the category in the TSV but aren't about reduce/compress.
 
@TessellatingHeckler APLcart's focus is not to document the language, but to answer "how-to" questions. Just type it in your interpreter and press F1 or enter ]help /
 
<moon-child> they certainly come up, generally. In j IIRC a boxed empty array (a:) gets used a lot in indexing
 
10:34 PM
@Adám I was trying to find the how-to mask and filter in a train without an intermediate variable, searching "filter", "reduce", "compress" then "/"
 
moon-child: But that's only because a: is used as a special value (well, an extra enclosure is).
 
I was looking for 5(>⊢⍤/⊢)⍳10 or similar by searching "/"
 
@TessellatingHeckler Ah, good one. How to force / etc. to be functions (not operators) in tacit.
Will add.
 
Does APL have tuple like other language?
 
@elliptic00 Nope, just arrays.
 
10:46 PM
I assume there is no record either?
How to you handle Object like person which has name, age, address, phone # etc?
 
@elliptic00 That's right. Some dialects like Dyalog have namespaces, but generally the idea is to use arrays for everything.
@elliptic00 I think the typical way would be to decide on an order for those properties and put them in an array in that order. You would have to reference them by index instead of by name. If there are many of these objects, you can instead have one array for each property, which lists the values it has for each object.
 
<jcowan> Empty vectors are one thing, since they are sequences. But empty matrices and larger ranks strike me as a kind of useless generalization.
 
jcowan: The preference should be for generalization instead of restriction in a case like this where the general version is simpler to describe. And if there's a property relating to elements from more than one sequence (say, number of item i that person j owns), then the natural way to store it is in an array with one axis for each sequence. If one sequence is empty, the entire array will be as well.
 
@elliptic00 Is there any practical difference between them? I.e. any reason to have both?
 
@Adám I understand the difference between tuples and lists/arrays in a statically-typed language (tuples have a type for each element but lists have only one type for all of them), but I don't know why they should be different in a dynamically-typed one. Python's use of lists and tuples always confuses me.
 
ngn
10:56 PM
@Marshall in python the difference is mutability
 
Right, that's what I mean. In a completely dynamic language like APL, where all* arrays are immutable, there would be no difference.
 
ngn
@Adám except dyalog namespaces :P
 
*
 
What is a←1 2 3 4 5 6 ⋄ a[4]←7 if it's not mutation?
 
ngn
@rak1507 copying(if refcount>1) or reuse(if refcount=1)
 
10:58 PM
interesting
 
@rak1507 ^^ because b←a ⋄ a[4]←7 doesn't change b.
 
ngn
but if they are dyalog namespaces.. :P *
 
@rak1507 It is a reassignment of a with a new value related to the old one. The difference is that a[4]←a won't result in an array that contains itself.
 
TIL
 
@elliptic00 Marshall mentioned namespaces, but Dyalog APL has proper OO (inspired by C# and Visual Basic) so you can do all that. You can even have objects with keyed properties. (Doesn't mean you should.)
 
ngn
11:02 PM
"proper" and "OO" in the same sentence - hm. "Visual Basic" and "inspired" in the same sentence - wow!
 
@ngn The "Doesn't mean you should" goes on both sentences.
 
<moon-child> fair enough. I think if you can imagine that a sequence just happens to be zero-length, you can imagine the same for any other axis. But I haven't ever had call to use them
 
moon-child: Let's say you have some sort of query on a 7-column table, and there are no matches. Would it not be strange to get an empty list back, rather than a 0-row 7-column table?
Let's say you then want to extract column 3 from the search result. That'd fail on an empty list, but work on the 0-row table.
 
v ← 2 3 ⍴ ⍳ 10
1 2 3
4 5 6
v[1][1]
how to access the first element of v?
v[1][1] does not work
 
@dzaima or @Marshall

reading implementation/vm:
"When the block is evaluated, its frame is initialized using any arguments passed to it, the next instruction's index is pushed onto the return stack, and execution moves to the first instruction in the block."

the "next instructions index" refers to the index of the next list of block parameters (a,b,c,d), correct?

also, (i think) this means that the return stack is initialized before the frame is evaluated, and is passed to the next frame evaluation
 
11:12 PM
v[1;1]
 
Or ⊃v
 
wow.. APL uses Visual Basic array style..LOL
 
Or in a convoluted way: v[1;][1]
 
is Visual Basic v[1;1] style?
anyone idea how to write v to a file using Dyalog APL?
 
Visual Basic uses parens for indexing, v(1)
 
11:16 PM
@elliptic00 What exactly do you expect in the file?
 
1 2 3
4 5 6
keep it like a 2 dim vector
 
(↓⍕v)⎕NPUT'path/file.ext'
 
@Adám got 500'd. Should reconnect automatically now when it gets timed out
 
what is the symbol inside (..)?
it is hard to see it..
 
@elliptic00 converts the numeric matrix into a character matrix, and splits it into a list of lists (which then become lines in the file).
 
11:21 PM
I got Invalid file encoding type
 
Oh, stupid me. Sorry. It should be (⊂↓⍕v)⎕NPUT'path/file.ext'
@elliptic00 Because ⎕NPUT can take multiple parameters as left argument, and only the first is the actual content, so if you don't want to specify any more parameters, you've got to enclose to make the content a single element.
 
what we need Enclose?
It works.. Thanks..
 
@elliptic00 Do you know about APLcart?
 
I do try to search on APLcart, aplcart.info but I have hard time to find the simple example which write some data to a file,
This example should be in APLcart
I have searched the function for long time... and see some example on Dyalog Website, but I did not understand it....
 
@elliptic00 What did you search for?
 
11:28 PM
write to file.. write file... etc.
 
@elliptic00 OK, then you should find ⎕NPUT in that list. Only the example doesn't show how to write multiple lines from a vector of text vectors.
 
'write vector to file' ..
 
I'll amend the example.
 
Yep, I know NPUT, but it is hard to guess what the format...when writing data to file i APL... I'm pretty new to APL...
 
Would this have helped?
 
11:31 PM
it make sense to write 2 dim or 3 dim vector to file..in APL.. because APL is array based lang
 
But files are 1-dimensional. (Or at most ragged 2-dimensional if you look at them as collections of lines.)
I do agree that writing a character matrix to a file could work. I'll suggest that.
 
11:52 PM
I did look at the example in APLcart, but I have no idea how to write vector when I was looking the example...
 

« first day (1357 days earlier)      last day (1313 days later) »