« first day (1812 days earlier)      last day (1139 days later) » 
00:00 - 23:0023:00 - 00:00

00:29
@Adám now i don't need your help, only i need help when:
@DavidHoelzer Hi there. Interested in APL?
- I can't find what is X?
@Fmbalbuena Press F1 and search for it on APLcart and APL Wiki
> I can't find what is X?
Ah, I see, can't find using F1/APLcart/APL Wiki. Fair enough.
I'm happy you've reached that stage.
00:35
@Adám how many stages there are?
- How to convert to tacit
@Fmbalbuena After following the rules at dfns.dyalog.com/n_tacit.htm and remembering to make the functions / and into ⊢⍤/ and ⊢⍤⌿
- Golf this program (except 2 byte programs)
Btw, I've not really taught you much about tacit APL. Have you tried learning it on your own?
@Adám maybe
@Fmbalbuena Hey, who says I can't golf 2-byte programs‽
00:39
A lot of 2 byte programs can't be golfed.
I've recently learned about the partition and key functions and they are pretty cool
@Fmbalbuena Given a matrix, return how many rows it has.
@lyxal Key is an operator, but yeah.
@Fmbalbuena Right. I was hoping you'd answer ⊃⍴ so I could golf it to
another task (2 bytes) just for fun
00:52
Given a Boolean matrix, count the 1s.
> matrix
what is matrix
A 2-dimensional array. You used one just before to get the row and column counts.
Try it online! I don't know how to shorten this to 1 byte or 2 bytes
00:57
2 bytes: ≢⍸
It'd be kind of fun to collect all the useful two-character APL functions. There are lots — and loads more in dzaima/APL.
@Adám long time apl user. :). Just passing through
@Adám that's beautifully elegant. I love it.
@DavidHoelzer Oh cool. Welcome! Not so many long time APL users here. Can we persuade you to stay (or come back)?
@Adám Explanation?
@Fmbalbuena gives a list of the indices of each 1. counts them.
OK, one last 2-bytes-as-a-goal task: Given a matrix, rotate it 180º
(I'll check for answers tomorrow, as I'm off to bed.)
01:19
What?
      {'⍵'}123
⍵
what?
 
2 hours later…
02:56
      tall←5 3⍴'T'
      wide←3 5⍴'W'
      long←1 5⍴'L'
      short←1 3⍴'S'
      short⍪tall
SSS
TTT
TTT
TTT
TTT
TTT
      short_tall←short⍪tall
      tall,short
LENGTH ERROR
      tall,short
          ∧
      tall,5 3⍴short
TTTSSS
TTTSSS
TTTSSS
TTTSSS
TTTSSS
      tall_short←tall,5 3⍴short
      2/long
LLLLLLLLLL
      2⌿long
LLLLL
LLLLL
       (2⌿long)⍪wide
LLLLL
LLLLL
WWWWW
WWWWW
WWWWW
       tall,(2⌿long)⍪wide
TTTLLLLL
TTTLLLLL
TTTWWWWW
TTTWWWWW
TTTWWWWW
       (tall,(2⌿long)⍪wide)⍪(short,long)
All tasks that need tall, long, wide, short solved (this)
 
4 hours later…
06:28
@Adám @Fmbalbuena ⊖⌽
Yup.
 
1 hour later…
07:41
Hi guys. What is the equivalent of i. in K5 ?
@M4X_ While you might want to ask in the k tree I figure you mean J's i. but monadic or dyadic? Monadic, I think is ! and dyadic is ?
Thanks, I didn't know of it. thank you so much @Adám!
 
3 hours later…
10:22
@Adám the last two explanations on constant in APL Cart are incorrect, I think (aplcart.info?q=constant%3A)
@xpqz Yes, fixed.
That was quick :o
Can you show an example where constant is useful?
@xpqz ⎕←1 0 1{-@(⍺⍨)⍵}⍳3
@Adám ¯1 2 ¯3
10:30
@xpqz ⎕←(≢÷2⍨)⎕A
@Adám 13
@xpqz ⎕←4 2⍨¨'Hello'
@Adám
┌───┬───┬───┬───┬───┐
│4 2│4 2│4 2│4 2│4 2│
└───┴───┴───┴───┴───┘
Yes, after a bit of pondering I can see it. I think the docs and/or APLCart could benefit from these. The examples on help.dyalog.com/latest/#Language/Primitive%20Operators/… feel a bit barren to me at least.
10:54
@xpqz I've logged issue 19614 suggesting this:
      (3 3⍴4↑1){-@(⍺⍨)⍵}3 3⍴⍳9  ⍝ the apparent alternative, -@{⍺} would fail while -@(⍸⍺)⊢ is inefficient and awkward
¯1  2  3
 4 ¯5  6
 7  8 ¯9
      (≢÷(+/⍳4)⍨)⎕A  ⍝ preserves reading order (cf. (+/⍳4)÷⍨≢) and avoids re-evaluating +/⍳4 (cf. ≢÷{+/⍳4})
2.6
      (⍳3)⍨¨'Hello'  ⍝ avoids re-evaluating ⍳3 and the awkward alternatives (⊂⍳3)⊣¨'Hello' or (⍳3)⊢¨∘⊂⍨'Hello'
┌─────┬─────┬─────┬─────┬─────┐
│1 2 3│1 2 3│1 2 3│1 2 3│1 2 3│
└─────┴─────┴─────┴─────┴─────┘
Ooh, even better if we use ?6 as things to avoid re-evaluation of.
That would be a huge improvement. That way I can deduce the 'why' from the docs.
@Adám isn't the alternative there really {⍳3}¨'Hello'? (which is shorter anyway)
oh, that will re-evaluate ⍳3
Hence my change to ?6
nvm, ignore me, I can't read atm obviously :P
 
2 hours later…
13:15
@Adám How to take the third argument (1 F 2 ⊢ 3)
@Fmbalbuena ⋄ F←{⍺⍺ ⍵⍵ ⍵} ⋄ 1 F 2 ⊢ 3
@Adám 1 2 3
thanks
with the ]plot user function, can i plot multiple graphs in the same plot?
13:34
it comes out like this. im on linux, but it shouldnt matter, right?
https://imgur.com/a/cLmcSxN
the line is dispreferred, how do i get rid of that?
and can i determine the axes' size?
oh nevermind, the line is because i plot the x values. it seems the behavior is slightly different on linux
@Slimey Hm, that does make more sense. On Windows, there seems to be a bug so x doesn't render (as you can see) but still contributes to the sizing. However, if you remove x it'll plot sin vs cos instead of two independent lines.
so, plotting multiple plots works now, but my last question still stands
If multiple means 3 or more. 2 won't work, afaict.
No, you can't set axis sizes. It'll always scale to exactly fit the smallest and largest x and y values.
oh yeah, that makes sense. i tried with 3 plots and it works without the x
13:48
]Plot is just a very simple tool. For complete control, use the full SharpPlot system.
yes, i love how quick and easy it is. just wanted to see where the limits are. on my windows pc i saw the sharpplot system (if that means ]chart), but i cant find it on linux. can i load it in from a prebuilt workspace, or do you know how i can get it on linux?
You should be able to load it with )load sharpplot (but be aware that this will remove everything you've defined, so consider using a separate Dyalog instance!) and that will print instructions too. See also lessons 44 and 45 here and the full online documentation at sharpplot.com
ok, i see, thank you very much. now i can truly drop python and geogebra for school and in general
:-)
@Adám why does )load have this weird behavior of replacing the workspace? It is counterintuitive. Is there a way around it?
14:05
@AlexB In normal circumstances, you shouldn't use )load (or workspaces) at all. I just abused it to make sure Slimey would see the instructions. )copy imports everything from a workspace without killing your stuff, but of course, name clashes could happen. I recommend doing (NameYouWantToImportAs←⎕NS⍬).⎕CY'WorkspaceName' and then you can refer to members of that workspace with NameYouWantToImportAs.MemberName
@adam few days ago we spoke about Compositions and using diagrams to show how it works
Yes?
I just viewed a video (from you!) which is even more clear at least for me
You presented a 3x3 table with al combinations using atop, beside and over
Maybe this table/diagram could be used in some of the documentation.
@Adám thanks! (I know that APL has a lot of legacy, but coming from a non-APL background, one does not see a command called "load" as destructive...)
I'll find and share the link
14:10
@AlexB Agreed. Think of it as a tape deck. If you load a new tape, you have to remove the old one.
Tape deck. Brings back memories.
@Adám yes, in this context it makes sense. I have to keep thinking IBM/360. At some point, if APL is to re-gain more popularity, a few things should be updated. Perhaps keeping two UIs in parallel — legacy and 21th century — could be a sensible approach...?
The problem is that the UI and the language are too tightly bound together to be separated. Hence why RIDE isn't actually an IDE.
Funny thing that a few days ago you wrote "cloud" and I corrected you saying "mainframe". Now it's the other way around. LOL
@Adám I am getting to appreciate it.
14:14
@phantomics still need an answer?
I have a partial answer so far. Only one piece of the puzzle missing.
Dyalog most probably uses something along the Euclidean algorithm GCD on Gaussian integers.
and, I presume, due to poor programming the condition that the complex number must be gaussian is not checked.
hence the infinite loop
i've studied this in more detail when implementing my own GCD for kamilalisp.
That's exactly right, but how does the interpreter convert complex non-integers to integers?
also, Dyalog almost certainly uses the lcm(p/q) and gcd(p/q) formula for "floats".
@Adám DOMAIN ERROR :)
No, that's the problem. It works.
14:17
must be a conincidence.
i could peek into the disassembly but i lost my ghidra workspace.
but i'm almost sure that i'm right
This is correct: ⎕← 1.3j2.6 ∨ 4.5j8.9
@Adám 0.1
How does it get that result?
i presume, that the interpreter first converts the numbers to a/b + c/d * i
⋄ GCD←{IGCD←{0=⍺|⍵:⍺ ⋄ (⍺|⍵)∇⍺} ⋄ m←IGCD/∊⍺ ⍵ ⋄ m×⍺ IGCD⍥(÷∘m)⍵} ⋄ 1.3j2.6 GCD 4.5j8.9
14:20
@Adám 0J2.220446049E¯16
gcd(a/b, c/d) = gcd(a, c) / lcm(b, d)
you can express any complex number with rational real and imaginary parts as (n + mi) / k where n, m and k are integer
plug the k's into the lcm, plug the gaussian integers into gcd, there's your answer.
KamilaLisp uses the following for gcd on gaussian integers:
1.3 + 2.6i = (13 + 26i)/10
4.5 + 8.9i = (45 + 89i)/10
lcm(10, 10) = 10
gcd(13 + 26i, 45 + 89i) = 1
Do you feel like writing a full APL model?
not really
but it's trivial in my opinion.
i'm about to eat dinner right now
Enjoy!
thanks :)
14:48
@Dean Hi there. Interested in APL?
14:58
@Adám flatten a layer like 4 2 3⍴1 0 converts to ´4 6⍴1 0´
I can't find in aplcart
@Fmbalbuena (you didn't find it because I had "plane" but not "layer" — I'll add that now)
⋄⍪4 2 3⍴1 0
@Fmbalbuena
1 0 1 0 1 0
1 0 1 0 1 0
1 0 1 0 1 0
1 0 1 0 1 0
{((⍴⍵[⍳(⍴⍵)-2]),((⍵[⍴⍵])+(⍵[(⍴⍵)-1])))⍴⍵}?
Hi @Adám. Yea I am interested, but I can't fully figure out what it's real-world use-cases are
15:05
@Fmbalbuena wdym?
I'm new to the chat interface
Is {((⍴⍵[⍳(⍴⍵)-2]),((⍵[⍴⍵])+(⍵[(⍴⍵)-1])))⍴⍵} = ?
15:25
There is an interesting discussion on HN right now on Smalltalk, and its image-based view of the world, which is very similar to how Dyalog's binary workspaces work (news.ycombinator.com/item?id=29890205)
15:45
@Adám You are wrong
@xpqz that discussion seems to echo my earlier comment to @Adám about the )load command. The integration of APL interpreter with RIDE and the environment is a point of strength but also a limitation. To reiterate on a point I made a couple of times in the last few days, JupyterLab seems to offer lots of that "integrated sandbox" advantages, with the advantage that it is disposable — you can restart afresh any time.
@Fmbalbuena In general or about something in particular?
@Adám LMAO
@Fmbalbuena No {(≢⍵)(×/1↓⍴⍵)⍴⍵}
@AlexB Sure. Workspaces (as does, infact, spreadsheets) bundles state and functions into a blob. I like jupy notebooks, but they suffer from chaotic execution order: as you can execute cells in any order you choose, it's hard to maintain any semblence of sanity without iron discipline.
@Adám lolz :)
15:55
@xpqz you're right, but you can open a JupyterLab console (which guarantees execution order), or simply rerun all cells.
@xpqz ...but for programming in > small scale, the good old editor + revision ctrl + IDE is best (and Makefile, of course!). JupyterLab is good for exploration.
@AlexB I think Dyalog's heading in the right direction, though, with ]link and dyalogscript (18.2) complementing the dynamic, repl-based style. And -- yes -- workspaces have their niche, too, still.
@xpqz OTOH, the integrated APL+RIDE (or Smalltalk, etc.) is a bit of both, but master of none.
@xpqz I haven't learned enough of APL and RIDE to appreciate the latest changes, but I am hopeful!
@AlexB ]LINK is probably what you want, but it's not quite there 'out of the box' and requires a bit of fiddling to set up.
(at least on a Mac)
In some ways, LINK is more expressive than 'editor + bunch of files' -- edits made to the files directly are picked up by Dyalog, and changes made inside the session are reflected in the files.
That's cool.
Def the way to go for anything of non-trivial complexity.
@xpqz In 18.2 you can (on Windows — maybe other GUIs can set up something similar) right-click on a folder/file and select "Open with Dyalog" to get an interpreter with that folder/file linked with the root namespace. Make your changes, and close APL. No need to ever know about Link.
@AlexB Morten gave a presentation on the current state of LINK at the conference: youtu.be/K_-E1tnH06k
16:06
Fun
@Adám That's what it will take; happy to hear this, and hopeful it will make it to us non-Windowzers.
@xpqz Do other OSs have the ability to put items on a context menu or similar?
Sure
Super-easy on a Mac
We'd be most interested.
16:10
But can it have multiple command lines for a single application, with custom command line options?
On Windows, we'll have (subject to naming changes):
"Open with Dyalog" = path/to/dyalog.exe -LOAD="%1"
"Open with Dyalog (do not start)" = path/to/dyalog.exe -x -LOAD="%1"
@xpqz thanks for the tips
If I remember correctly (it was many years ago I last wrote code FOR a mac), your app registers one (or more) internal URIs where you specify whatever you want to specify for the opening of a file. So it should be possible.
@Adám How to see the APL keyboard layout without opening the interpreter?
@Adám is there a nice way to do (1↑c),⍨+\¯1↓c with under?
should I use under in my algorithm implementation? is it painfully slow?
@Fmbalbuena ⊞Win + Space
16:19
@Adám not sure if this is what you need — this can be done by the end user in a not-too-difficult way: apple.stackexchange.com/questions/116947/…
@Adám i mean how to press glyphs without opening APL interpreter
@KamilaSzewczyk I don't see any pre-processing being un-done.
dropping the last element and re-appending it?
@KamilaSzewczyk Under should have reasonable performance.
@KamilaSzewczyk Uh, check your code.
I know that i forgot a ¯ :P
but i can't edit it anymore
16:21
@KamilaSzewczyk +\⍢(¯1∘↓)?
@KamilaSzewczyk +\@(⍳¯1+≢c)
16:42
how would you write P(n) = n(3n - 1)/2 in an apl function, be it tacit or dfn?
i did
P ← .5×(¯1+3∘×)×⊢
could it be written better? im also pretty sure its better to write it out as a dfn, as that could make it a little clearer
looks good for a tacit functions
if I were you, i'd keep it this way, since dfns have some overhead that tacit functions don't.
1-⍨ is more pretty than ¯1+ imo, but that's just preference. I don't think you can make it smaller
2÷⍨⊢×1-⍨3∘×
I shouldn't be so quick to speak heh, by moving around the forks you can remove the brackets
@Adám Visual keyboard?
16:58
thank you @FawnLocke. i see why you like 1-⍨ more, i think i will use that from now on, as it makes reading from right to left a little more pleasant. good to know im getting better at creating quick, tacit functions
17:13
 m←⍝ ...
 p←n⍴0⋄p[m]←⍳n
assuming m is a vector, is there a nicer way to write this
when I tried using @ it gave me RANK ERROR
why would a Jot be better than a right tack?
2÷⍨⊢×1-⍨3×⊢
It wouldn't infact I'd prefer the latter, I just ctrl+c'd
Doesn't really matter here, though, often doesn't
i think the option without function composition is faster.
@FawnLocke Ah, ok. Thanks.
@Adám Yes. If others also find this useful. It works for me at least
17:20
@Richard I second it, @Adám. Useful.
@AlexB im learning about using bind, so its been creeping in all over my code
17:39
@Fmbalbuena Have you "On-Screen Keyboard"?
@KamilaSzewczyk Am I right in assuming that m is a permutation vector or length n?
@Adám yeah. but i figured out how to use At here already lol
@KamilaSzewczyk Ahem: ⍋m
oh. i see.
that's much nicer, i didn't know why i didn't notice it
18:02
what really gets me is that suffix arrays would be trivial but then the memory requirements would be insane
⎕←{z⍳{⍵[⍋⍵]}z←1↓(⍳1+≢⍵)↓¨⊂(⎕ucs⍵),¯1}'banana'
@KamilaSzewczyk 6 5 4 2 3 1
if only APL had something akin to string slices, one wouldn't have to hold all the suffixes in memory
the only solution i'm seeing to circumvent it is to implement my own sorts, etc..., but they all would operate on ranges + a given string
this problem is trivial to implement efficiently in C/++ and even easier to implement naively in APL, but something better seems like a ton of work...
@KamilaSzewczyk No need for ⎕UCS there (other than for performance).
i guess that if i want to build a suffix tree this way, for a 400KiB file I'll have to spare... ⎕←(1E9)÷⍨2÷⍨400000×400001 GB of RAM
@KamilaSzewczyk 80.0002
 
1 hour later…
19:37
@xpqz and @Adám, I am trying the ]LINK command. I created a namespace 'tl' and I linked it with directory 'test_link'. I edited and save a function with VI and now I want to re-sync it with the workspace, but something is wrong.
]LINK.refresh #.tl -source=dir
┌→───────────────────────────────────────┐
↓* Command Execution Failed: LENGTH ERROR│
└────────────────────────────────────────┘
]LINK.refresh tl -source=dir
┌→───────────────────────────────────────┐
↓* Command Execution Failed: LENGTH ERROR│
└────────────────────────────────────────┘
]LINK.refresh 'tl' -source=dir
┌→───────────────────────────────────────┐
↓* Command Execution Failed: LENGTH ERROR│
└────────────────────────────────────────┘
tl

#.tl
What am I doing wrong? I tried everything. The documentation is so terse that I can't figure out what to do.
]LINK.refresh -??
┌→──────────────────────────────────────────────────────────────────────────────┐
↓───────────────────────────────────────────────────────────────────────────────│
│ │
│]LINK.Refresh │
│ │
│Fully synchronise namespace-directory content │
I am doing what the help screen tells me to do...
Different question on the same topic. Is there a way to have RIDE watch the linked directory, checking every 500 msec or so, and sync automatically?
@AlexB Sorry you're having this trouble. Can you try o←⎕NS⍬ ⋄ o.source←'dir' ⋄ o ⎕SE.Link.Refresh tl
@AlexB Yes, but on non-Windows, I highly recommend upgrading to Link 3.0 which is much more polished and supports watching the dir if you install .NET Core 3.1
@AlexB Btw, for the future, press Ctrl+k before posting code, and it'll look better.
@Adám wdym?
@Fmbalbuena Sorry, there was missing a word. Try Windows' built-in On-Screen Keyboard:
I already tested, but not working
Which keyboard layout do you use for APL?
19:58
:60120404 I don't see an answer, but if you use one of my keyboard layouts (they use AltGr as APL key) then the On-Screen Keyboard does work. I can make one for your language and country if you don't like to use an English one.
@Adám error...
      o←⎕NS⍬ ⋄ o.source←'dir' ⋄ o ⎕SE.Link.Refresh tl
SYNTAX ERROR: The function does not take a left argument
      o←⎕NS ⍬ ⋄ o.source←'dir' ⋄ o ⎕SE.Link.Refresh tl
                                   ∧
20:20
@AlexB Sorry, I was looking at the wrong thing. Try breaking the link and re-establishing it, first with ]break tl then ]link.create tl /path/to/tl -source=dir
@Adám yes, of course this is the first thing I tried. Breaking the link and re-creating it updates everything. But this defeats the convenience of using an external editor, if I have to always break-create for every tiny update.
It seems that the MacOS platform is behind w.r.t. Dyalog emphasis. I understand the limited resources. Most developers nowadays use either Linux or Mac, though.
Even with PowerShell and Windows Terminal, the Win platform is not as powerful and consistent as the Unix-based platforms. (At least that's my experience.)
Ah, I didn't catch that every edit caused this problem. It isn't so much a lack of emphasis as lack of in-house expertise. In any case, I recommend updating to Link 3.0 (or waiting for the release of 18.2, which comes with Link 3.0) as that has much better macOS support.
@Adám I will wait for 18.2. I am looking forward to editing source code in VI... :)
@AlexB Btw, you can set RIDE_EDITOR to whichever editor you want, and RIDE will use that instead of its own built-in editor.
Does anyone know the exact semantics of when variables are "evaluated" (or, their value is looked up)? For example, in the sentence 1 a b 2, are a and b evaluated as a part of stranding? or before stranding happens
20:35
@pmikkelsen Is there a difference?
No, i'm just trying to implement my own APL for fun, but I am unsure when to evaluate them. When they are used in a b c←1 2 3 they are not evaluated right away, but rather stranded as a vector of names it seems. Is this only due to the ?
Yes, that only happens with
Okay I see, thanks Adam
Here's a fun trick for you:
      ∇ a←a
       ⎕←'a was evaluated'
       ←65
      ∇
      ∇ b←b
       ⎕←'b was evaluated'
       b←66
      ∇
      1 a b 2
a was evaluated
b was evaluated
1 65 66 2
These two functions are niladic, so they have array semantics, allowing you to detect whenever they are dereferenced.
That is fun indeed, I don't use niladic functions very often
20:40
Even "works" with assignment:
      a b←1 2
b was evaluated
a was evaluated
SYNTAX ERROR
      a b←1 2
         ∧
(Btw, I strongly recommend always parenthesising multiple names on the left of )
I always do that, no worries :)
@Adám good one
How to make dzaima paste?
@Adám really? Thanks!
21:02
@MasterQuiz Looks nice and clean to me. What do you think of this refactoring?
@Fmbalbuena Go to dzaima.github.io/paste and enter your text. Click [view], then [copy link].
You can also use the [lang] button to select language for syntax colouring.
@AlexB Maybe I should add this to apl.wiki/Editors
@Adám I should have made a bouch of things (at least the (s p), when you said this before I was like "Ohh, I already know this thing"...). Thanks!
@Fmbalbuena Looks like you figured it out. Congratulations!
@Richard @AlexB Now added, and that made me realise a really good reason f⍛g Y should be (f Y)g Y: That makes both monadic and dyadic equivalent to g⍨∘f⍨
21:23
Are there some project for monadyc =?
@MasterQuiz No. Iverson used it for ∪∘.≡⊢
@Adám Hey, look this
@Fmbalbuena What about it? It is obviously not an authentic session transcript.
@Adám this is joke
Yeah, I figured.
One of my former colleagues once made a presentation where, in the middle, a seemingly random negative number was printed, whereto he remarked that he didn't know what that was. A while later he entered ⎕DL (delay) with a negative number (⎕DL returns the actual elapsed time) and remarked "Oh, that's what that number was!".
21:30
@Fmbalbuena The IO thing is actually "smart". But I don't understand the second thing...
@MasterQuiz Which one is the second?
@Adám How can I send you a PM?
@Adám 5⍴{'⍵'}1 2 3 This one... i expect 1 2 3 4 5 or 1 2 3
@Richard Email to adam@ with the same domain as www.dyalog.com
@MasterQuiz Uh, did you miss the quotes?
@Adám What about this isUnique, in term of performance? (⊢∊~∘≠⊢⍤/⊢) [Sorry but actually I can't test it, wrote it on the phone]
21:35
@MasterQuiz i'm wrong, thanks
@Adám No, I've got the joke too
@Adám Can you make one?
@Adám What about the famous 2+2 = 5? Or 5=2+2 for APLers
@MasterQuiz Like this:
 (⊢∊∪⊢⍤/⍨1=⊢∘≢⌸)p → 3.0E¯5 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 (≠∧⌽⍤≠⍤⌽)p       → 9.9E¯6 | -67% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
@Adám I was expecting that the operator could make it slower... But the second one?
21:38
Not sure what you're asking.
This (⊢∊~∘≠⊢⍤/⊢)
Doesn't give same result.
@MasterQuiz edited
@Adám Just figured it up, just a moment...
@Fmbalbuena Execute this: ⎕SE.(onSessionPrint←⎕FX,⊂'P←{⎕←''\d''⎕R{⍕10|1+⍎⍵.Match}⍤1⍕⍺}')
21:42
@Adám thanks, done
@Adám nothing happened
@Richard Good thing you told me. It was sent to spam. Maybe because of the subject? :-)
@Fmbalbuena Now try using APL as normal, e.g. 2+2
@Adám how to fix?
⎕SE.onSessionPrint←0 — You didn't like my joke?
21:45
@MasterQuiz Try the above ⎕SE.(
@Adám I've added another tilde, but I don't think I like it anymore... I have always tried to avoid rotate, thinking it's expensive on large arguments, but haven't got proves. (~⊢∊~∘≠⊢⍤/⊢)
@MasterQuiz I'm using reverse, not rotate. It is O(n)
(⊢∊∪⊢⍤/⍨1=⊢∘≢⌸)p → 3.0E¯5 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
(≠∧⌽⍤≠⍤⌽)p       → 9.4E¯6 | -70% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
(~⊢∊~∘≠⊢⍤/⊢)p    → 9.0E¯6 | -71% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
@Adám Oops, I should study better function's name.
@MasterQuiz You're right for large arguments with lots of duplicates:
    p←?⍴⍨1e6
    ≢∪p
632057
(⊢∊∪⊢⍤/⍨1=⊢∘≢⌸)p → 1.5E¯2 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
(≠∧⌽⍤≠⍤⌽)p       → 1.1E¯2 | -24% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
(~⊢∊~∘≠⊢⍤/⊢)p    → 7.6E¯3 | -48% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
I'm suspecting that it is the repeated rather than which takes the time. Indeed:
  ≠p → 5.3E¯3 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
* ⌽p → 3.8E¯4 | -93% ⎕⎕⎕
@Adám Just for everybody, I didn't ask Adam for drugs :)
21:52
@Adám Isn't there someway to calculate one time only? The only way I can figure out is putting it like alpha, but it wouldn't be a train and there must be something better, I think
What's the O-notation for Transpose?
@MasterQuiz Where, in mine? No, the two s are not operating on the same argument.
@user1129322 Hi Elise. If you want to participate here, please email [email protected]
@MasterQuiz O(n), I think. n is ×/⍴
@Richard Can you send me an email at [email protected]?
@Adám So it shouldn't be slow too, right?
No, I wouldn't worry about it.
22:12
@user1129322 Welcome the the APL Orchard. Since you're new to Stack Exchange chat, I highly recommend having a look at apl.wiki/APL_Orchard#Features. Also, feel free to introduce yourself and tell us what brings you here.
Hi! I'm Elise, and I'm pretty new to programming, but I would like to learn more about it and how to do it. Any tips on how to start?
@user1129322 Since you're not a programmer yet (don't worry, we'll make you one!) have a look at apl.wiki/Learning resources#For non-programmers but be aware that we're always happy to teach and guide here, and answer any questions.
@Adám Thanks. I see that you updated already.
@user1129322 Do you want me to give you a quick intro to the very basics of APL?
Yes that would be nice!
22:20
OK. (Btw, your generic avatar and username will change soon.)
@Fmbalbuena run him over
So, APL actually started as a mathematical notation rather than as a programming language (which is a bit ironic, because A.P.L. comes from "A Programming Language). This means that many things in APL will be immediately familiar to you from school mathematics.
I believe you already know a lot of APL.
Can you guess what 2+3 gives in APL?
I would assume that's 5
Absolutely. Oh, and there's nice chat bot here in the room that will evaluate APL statements that adhere to a certain format. They have to begin with `⋄ and end with `.
For example: ⋄ 2+3
@Adám 5
22:25
@Adám Everyone is an APL expert, it's just that they don't know about APL.
You probably don't know how to type but we'll get to that. For now you can copy and paste it, or enter APl code over on tryapl.org where you don't need the
@MasterQuiz That's right. My job is to uncover that inner knowledge.
Continuing on, we can use all the 4 traditional symbol's you'd see on a calculator's buttons: ⋄ 2×3 and ⋄ 10÷4
@Adám
6
2.5
So far, things should be clear enough. Stop me if anything is strange.
If you would like an easier way to enter the symbols that are missing from your keyboard, then visit abrudz.github.io/lb/apl and follow the instructions there.
@Adám * Socrates has entered the chat *
Let me show you some neat things APL can do:
⋄ 1 + 10 20 30
22:31
@Adám 11 21 31
@user1129322 Can you explain what just happened above?
It added one to each of the numbers separately
Exactly. APL loves to work on collections of data. Keep that in mind for later. Can you explain this one? ⋄ 4 5 6 + 10 20 30
@Adám 14 25 36
The fisrt number on the left side was added to the first number of the right side, second to the second, and third to the third.
22:35
Exactly. The rule is that if there's one number on one side (it could be the right side too) and multiple on the other, then the single one is paired up with each of the many. If both sides have multiple, they are matched up one-by-one.
If we try to match up two such lists that have differing lengths, APL will tell us that the lengths don't match: ⋄ 4 5 6 7 + 10 20 30
@Adám
LENGTH ERROR: Mismatched left and right argument shapes
      4 5 6 7+10 20 30
             ∧
The symbol tries to point at where things went wrong, but for the bot, it sometimes fails.
Can you explain this? ⋄ 3 1 4 1 5 > 2 7 1 8 2
@Adám 1 0 1 0 1
It says which number of the left side are bigger than the numbers on the right side, the 1 means it is a bigger number, the 0 means it isn't.
Very good. In general, APL uses the number 1 to mean "yes" or "true" and 0 to mean "no" or "false".
Now, APL can work with more than just number (though numbers are important). We can use texts in single quotes too, but obviously, we can't use + or > on characters. But equality works fine:
⋄ 'Hello' = 'olleH'
22:41
@Adám 0 0 1 0 0
Does this make sense?
I believe it says which of the letters are the same on both sides
Very good.
So, we here's the APL vocabulary you already know: +-×÷<≤=≥≠ — that's about 10% of all of core APL. Not too shabby for only half an hour's study, eh?
10% for half an hour is pretty nice
Here's a bit of a tricky thing: In your school mathematics, you probably used - to mean two different (but related) things. Can you identify what they were?
22:47
For a negative number and for example 10-5=5
Exactly. In fact, it was a bit more than just for a negative number. It was for negation in general, e.g. -(2+3) would give -5
APL, has it much the same way, with one minor difference. The similarity is that many APL symbols (we call them primitive functions) have two (usually related) meanings. E.g. -5 negates 5 while 10-5 subtracts 5 from 10.
The difference is that for actual negative numbers, we write the minus sign raised a bit: -5 negates 5 and ¯5 is negative five.
Now you think this is a silly distinction to make, no? Surely, the two are the same!
But think about how we wrote lists of numbers above? What do you think 3 1 -4 will give? (note that most spaces don't matter in APL)
¯1 ¯3
Wow. You nailed it!
So you see there's a BIG difference between 3 1 -4 and 3 1 ¯4. The high minus allows us to write negative numbers together with other things without issues.
Let me show you something where APL extends traditional mathematics. Note that -5 is like 0-5 so it is as if there's a missing number on the left of - we always use 0 instead of the missing number.
We call that 0 a "default left argument". An "argument" isn't about a conflict. That's just what we call the inputs to our functions.
In APL, all primitive functions (and almost all functions in general) take either one or two arguments. If there's only one, the function goes on the left and the argument goes on the right. If there are two, one goes on each side.
See if you can guess what the default left argument is for ÷:
⋄ ÷1 2 3 4
@Adám 1 0.5 0.3333333333 0.25
the number multiplied by each number, like 4^2= 16 and it's devided by 16
00:00 - 23:0023:00 - 00:00

« first day (1812 days earlier)      last day (1139 days later) »