« first day (322 days earlier)      last day (1625 days later) » 

9:52 AM
@Adám wait, why would ISO APL cap ww at 3 elements?
@Ven Three.
Thanks, brain-o. the question is still valid, though.
@Ven Because The first operator with array right-operand was and it needs between one and three scalars as right operand. So for convenience (but at the cost of general applicability), and because tacit APL had not been introduced yet, it was decided that the parsing should automagically chop the right hand array and give as much as needed to the operator while treating the remainder as right-argument.
Ahh... I see. Sounds like Perl prototypes. :P
Probably one of those "you think it's cute now, but...".
@Ven Also note that ISO APL does not have so without tacit programming, there simply isn't a way to do (f⍤1 2 3) 4 5 6
@Ven Exactly, but luckily Dyalog did not jump on that bandwagon.
9:57 AM
well, writing tack by hand isn't too hard, right?
@Ven You mean as a user defined function?
   ∇x←T x
[1]  ∇
@Ven ^ should be enough reason for ISO APL to settle on a convenient shortcut, no?
@Adám I didn't catch that one, sorry.
@Ven That is how you would write monadic right tack in ISO APL.
10:08 AM
right. it doesn't seem to bad. Of course it's gonna be a tad repetitive to put it everywhere tho...
@Pavel Example of golfing Dyalog APL with .NET ← may have interest for @Uriel and @EriktheOutgolfer too.
ah, nice!
I remember Morten talking about Silverlight(?) and how things turned around fast and how it's .NET now.
@Ven Yeah, we dropped Silverlight, but fully support .NET and now CEF too.
@Adám sorry, CEF?
oh, is that it? cefsharp.github.io
The Chromium Embedded Framework (CEF) is an open source framework for embedding a web browser engine based on the Chromium core. It allows developers to add web browser control and implement an HTML5-based layout GUI in a desktop application or to provide web browser capabilities to a software application or game, and provides the infrastructure for developers to add HTML rendering and JavaScript to a C++ project. It also comes with bindings for C, C++, Delphi, Go, Java, .NET / Mono, and Python and runs on Linux, Mac OS X and Windows. == Overview == There are two versions of Chromium Embe...
10:19 AM
Alright. I remember presentations showcasing some very nice graphs and al. I suppose it used that :).
@Ven No, that requires .NET. Our CEF interface is cross-platform.
Oh ok.
Makes sense :). I still need to try MiServer someday...
@Ven The cool thing is that you will very soon be able to make a MiSite app and then chose to run it as a web server or as a local cross-platform desktop app. You can already do that, but need to modify your code slightly. The idea is that no code changes would be necessary.
kind of like electron and all?
10:38 AM
@Adám so you guys use lamps instead of candles in the UK?
@Uriel :-D Oil lamps.
@Adám it was a nice touch btw, but I think only APLers will get the lamp thing
@Uriel I linked the text actual lamp symbol, but anyway, it doesn't cost me anything, and it looks better than *, imho.
3 hours later…
2:07 PM
Adám is hosting an informal APL learning session tonight at 18:30 UTC in https://chat.stackexchange.com/rooms/52405/apl continuing the "APL primitive functions' marathon". See https://chat.stackexchange.com/transcript/message/41299896… … if you don't have 20 Stack Exchange rep points.
2 hours later…
4:11 PM
Hey @Adám, I think you didn't see it earlier, but anyway: do you think this is an acceptable answer to a challenge?
Specifically, this challenge.
@J.Sallé Sorry about that. Yeah, I did see it, but :-) I can hardly read/understand it. Does it pass the test cases? If so, then post and explain/ungolf it. Then maybe I will be able to do a sanity check.
@Adám Okay, sounds good. It does pass the test cases, I was just worried about possible consensus/rules violations
4:27 PM
@J.Sallé Ah, I see what you mean. You need to count the function header, as it is significant (not just "F"). Also the "calling" method is unusual. If you reverse the arguments of s, then you should be able to take k n as a single input. Finally, add a line to the Code which calls with the right format, e.g. (⍬⎕f nk)s nk←⎕
2 hours later…
6:20 PM
hm, looks like we haven't got many participants, it's less than 12 minutes before start...
@EriktheOutgolfer True. I guess it will be more personal then.
I'm kinda here :p My boss actually made me work today though flips table
well, let's wait a bit, the notification banner just appeared
@EriktheOutgolfer Unusually late today. And I didn't notice any 2h-before notification.
@Adám I did
(except it was kinda way more than 2h)
6:25 PM
@EriktheOutgolfer Ah, then I might have been in a meeting.
Welcome to the APL learning session!
We are proceeding with the functions' marathon. If we are swift, we may be able to finish next week. The first function for today is .
Monadic just takes a simple Boolean array and returns the list of True indices.
⍞←⍸0 1 0 1 1
@Adám 2 4 5
⎕←2 3⍴0 1 0 1 1 0 ⋄ ⎕←⍸2 3⍴0 1 0 1 1 0
0 1 0
1 1 0
│1 2│2 1│2 2│
A code golf trick: Sum a Boolean array with ≢⍸ instead of +/,
⍞←≢⍸2 3⍴0 1 0 1 1 0
@Adám 3
6:33 PM
@all Clear?
@Adám only if we use your encoding altering stuff
@EriktheOutgolfer Yeah, that should be implicit by now: Feel free to use Dyalog Unicode, but add <sup>SBCS</sup> after "bytes".
This refers to github.com/abrudz/SBCS which allows you to use the new symbols which are not in the character set.
Dyadic is interval index. It takes a list of sorted arrays on the left, and for each array on the right, tells which "gap" (interval) it belongs.
⍞←1 10 100 1000⍸0 500 2000 3 10
@Adám 0 3 4 1 2
So 0 is in interval number 0 (that is, before 1–10). 500 is in interval 3, which is 100–1000, etc.
And as you can see from 10, it is in interval 2; 10–100. So intervals are [min,max)
For higher rank arrays, it works like grade, i.e. on major cells. See lesson 8.
@all Please interrupt with any questions.
Dyadic is membership. For each scalar in the left argument, return a Boolean if it is a member of the right argument:
⍞←'aeiou'∊'Hello World'
@Adám 0 1 0 1 0
6:42 PM
Does APL have an "insert at index" command?
@cairdcoinheringaahing You mean to extend the length of the array?
@Adám As in, given an array, an index and a value, insert value at the index in the array. Example: [1, 2, 4, 5], 2, 3 => [1, 2, 3, 4, 5]
@cairdcoinheringaahing There are a couple of approaches:
⍞←∊(⊂,∘3)@2⊢1 2 4 5
@Adám 1 2 3 4 5
This appended a 3 to the 2, then flattened.
You flatten with monadic which is the function we're up to.
6:47 PM
@Adám That looks too complicated for what I know in APL, but thanks!
@cairdcoinheringaahing If you go over lesson 4 on @ and lesson 7 on it should be pretty obvious how it works.
@cairdcoinheringaahing A more traditional and better performing approach would be:
⍞←{3@(1+2)⊢⍵\⍨1+2=⍳≢⍵}1 2 4 5
@Adám 1 2 3 4 5
But we have not covered the \ function yet.
So, "enlists":
⎕←(⍳3)(2 2⍴⍳4)
6:51 PM
│1 2 3│1 2│
│     │3 4│
⍞←∊(⍳3)(2 2⍴⍳4)
@Adám 1 2 3 1 2 3 4
Next up is which is (as of yet) only dyadic.
is "Find". It returns a Boolean array of the right argument's shape with a 1 at the "top left" corner of occurrences of the left argument in the right argument:
@Adám 0 0 1 0 0 1 0 0 0 0 0
The ones here indicate the left "s" wherever "ss" begins.
6:57 PM
@EriktheOutgolfer 1 1 0
@EriktheOutgolfer Yes, overlaps are ok.
Works on high-rank arrays too:
⎕←2 2⍴0 1 0
0 1
0 0
@Adám I just investigated if they can be done, and it's useful to only have the top-left corner be a 1 instead of the whole area
⎕←3 3⍴0 1 1 0
6:58 PM
0 1 1
0 0 1
1 0 0
⎕←(2 2⍴0 1 0)⍷(3 3⍴0 1 1 0)
1 0 0
0 1 0
0 0 0
@EriktheOutgolfer Yes, otherwise you couldn't detect overlaps.
@Adám of course overlaps can only be done if all chars are equal
@EriktheOutgolfer No:
7:00 PM
@Adám 0 0 1 0 1 0 0
oh right
Works on nested arrays too:
⍞←'aa' 'bbb'⍷'c' 'aa' 'bbb' 'dddd' 'aa' 'aa' 'bbb'
@Adám 0 1 0 0 0 1 0
@all Quiz using : Determine if A is a prefix of B.
⍞←'abc' 'def' 'abc'⍷'abc' 'def' 'abc' 'def' 'abc' 'dea' 'ace'
7:01 PM
@EriktheOutgolfer 1 0 1 0 0 0 0
@Adám ⊃⍷
@EriktheOutgolfer Exactly. Nice!
@Adám ⊃⍷
@H.PWiz Good!
@all How about: Is A a suffix of B?
hm, that's harder
7:03 PM
@EriktheOutgolfer Yes. We'll get there. Don't worry.
Next function is . It is basically Union of multi-sets.
However, it is symmetrical in a way you can often use to your advantage:
2 messages moved to trash
@DyalogAPL um, where is the next line?
@EriktheOutgolfer I probably typed something wrong (like a nbsp instead of a space).
So, anyway, you can see that it preserves duplicates from the left argument, while only adding the items from the right necessary to make the result contain all elements from both.
It will add duplicate elements from the right if they are not in the left, though:
7:08 PM
@Adám abccdd
The monadic is Unique. It simply removes duplicates:
@Adám Misp
Unfortunately it only works on vectors (lists) but we will probably extend it to handle major cells soon.
Dyadic is of course intersection, again asymmetric:
⎕←'abcc'∩'cda' ⋄ ⎕←'cda'∩'abcc'
So it removes elements from the left which are not in the right. Duplicates in the right do not matter.
The last multi-set function is dyadic ~ which is "without" or "except". It simply removes from the left whatever is on the right. Note that it can take even high-rank right arguments.
7:13 PM
@Adám Miiii
Monadic ~ is logical NOT, simply swapping 1→0 and 0→1:
⎕←(3 3⍴0 1 1 0) (~3 3⍴0 1 1 0)
│0 1 1│1 0 0│
│0 0 1│1 1 0│
│1 0 0│0 1 1│
@all How are you all holding up? Too fast?
Next up is /. You may think we covered it in lesson 3 but that was as an operator, e.g. +/ for sum. When what's on its left is an array rather than a function it instead acts like a function. (This does make it unusual.)
/ as a function is called replicate. It replicates each element on the right to as many copies as indicated by the corresponding element on the left:
⍞←1 1 2 1 2 1 2 1/'Misisipi'
@Adám Mississippi
A more common usage is with a Boolean left argument, where it then acts as a filter:
⍞←1 0 1 1 0 0 1 0 1 1 1/'Hello World'
7:22 PM
@Adám HllWrld
It has one more trick: If you use a negative number, then it replaces the corresponding element with that many prototypes (spaces for characters and zeros for numbers).
⍞←1 1 ¯1 1 1/'Hello'
@Adám He lo
You can also use a single scalar to "empty" and array:
⎕←0/'abc' ⋄ ⎕←1/'abc'

/ has a cousin, \ which when used as a function is called "Expand".
Positive numbers on the left also replicate like with / but negative numbers insert that many prototypical elements at that position.
⍞←1 1 ¯1 1 1 1\1 2 3 4 5
7:29 PM
@Adám 1 2 0 3 4 5
@cairdcoinheringaahing And now you can begin to see how we can insert into an array.
Btw, you can use 0 instead of ¯1 which makes it convenient to use Boolean left arguments.
Let's go back to the problem of inserting 3 in between 2 and 4 in the list 1 2 4 5.
My method was: Get the indices of the elements:
⍞←⍳≢1 2 4 5
@Adám 1 2 3 4
Look where the index is 2:
⍞←2=⍳≢1 2 4 5
@Adám 0 1 0 0
That's where we want to expand:
⍞←1+2=⍳≢1 2 4 5
7:33 PM
@Adám 1 2 1 1
Do it:
⍞←(1+2=⍳≢1 2 4 5)\1 2 4 5
@Adám 1 2 2 4 5
And then we replace the extra 2 with our desired element:
⍞←3@(1+2)⊢(1+2=⍳≢1 2 4 5)\1 2 4 5
@Adám 1 2 3 4 5
Just like the operators / and \ each have a sibling, and which do the same thing but along the first axis (i.e. on the major cells) so to with the functions / and \ :
⎕←(1 0 1/3 3⍴⎕A) (1 0 1⌿3 3⍴⎕A)
7:38 PM
│GI│   │
⎕←(1 ¯2 1 1\3 3⍴⎕A) (1 ¯2 1 1⍀3 3⍴⎕A)
│D  EF│   │
│G  HI│   │
│     │DEF│
│     │GHI│
@all Any questions before we move on to , ?
Monadic , ravels. It takes all the scalars of an array and makes a single vector (list) our of them.
This includes a scalar, so ,3 is a one-element vector.
⎕←3 3⍴⎕A
7:45 PM
⎕←,3 3⍴⎕A
@Adám um, isn't that the same as monadic ?
⎕←∊3 3⍴⎕A
⎕←∊3 3 3⍴⍳27
7:47 PM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
@EriktheOutgolfer will take all the data and make it a simple vector. , will take all the scalars and make it a (potentially nested) vector.
⎕←,3 3 3⍴⍳27
⎕←∊2 2⍴'abc' 'def' 'ghi' 'jkl'
⎕←,2 2⍴'abc' 'def' 'ghi' 'jkl'
7:47 PM
@EriktheOutgolfer is the same as ,/,⊃,/,⊃,/,
@EriktheOutgolfer Clear?
Which brings us to dyadic , which is simply concatenation:
⍞←1 2 3,4 5 6
@Adám 1 2 3 4 5 6
, can also get specified an axis upon which to act:
⎕←(2 3⍴⎕A),[1](2 3⍴⍳6)
7:52 PM
1 2 3
4 5 6
⎕←(2 3⍴⎕A),[2](2 3⍴⍳6)
ABC 1 2 3
DEF 4 5 6
You can even use fractional axes to specify that you want to concatenate along a new inserted axis between the next lower and higher integer axes:
⎕←(2 3⍴⎕A),[0.5](2 3⍴⍳6) ⍝ 3D array

1 2 3
4 5 6
⎕←(2 3⍴⎕A),[1.5](2 3⍴⍳6) ⍝ 3D array
7:54 PM
1 2 3

4 5 6
This works for the monadic form too:
⎕←,[0.5]2 3⍴⎕A
⍞←⍴,[0.5]2 3⍴⎕A
@Adám 1 2 3
⎕←,[1.5]2 3⍴⎕A
7:55 PM

⍞←⍴,[1.5]2 3⍴⎕A
@Adám 2 1 3
And finally for tonight; :
The dyadic is a synonym for ,[1] :
⎕←(2 3⍴⎕A),[1](2 3⍴⍳6)
1 2 3
4 5 6
⎕←(2 3⍴⎕A)⍪(2 3⍴⍳6)
⎕←(2 3⍴⎕A)⍪(2 3⍴⍳6)
7:58 PM
1 2 3
4 5 6
Monadic is called "Table" as it ensures that the result is a table. It ravels the major cells of an array and makes each one of them into a row (i.e. a major cell) of a matrix:
⎕←2 3 4⍴⎕A

⎕←⍪2 3 4⍴⎕A
This is, monadic is just a synonym for ,⍤¯1 (except for scalars).
And this concludes today's lesson. See you all next week for the year's last lesson, where will hopefully be able to go through the remaining six functions.
8:03 PM
@Adám 12
each has a monadic and dyadic variant :p
@EriktheOutgolfer OK, true.
1 hour later…
9:22 PM
@Adám Hey, sorry for bothering so late :p When you have some time, could you give me some insight? I did what you suggested and the function f fails when I try (⍬⎕f nk)s nk←⎕ and input 15, then 2 4. It works if I do (⍬⎕f 2 4)s 2 4 with input 15 though. Debugger says it needs a boolean singleton on f[3], which is :While j<⊃⌽n.
Current code is this
@J.Sallé It asks for nk first. Right-to-left!
good god
Okay, now it works! Thanks a lot hahahah I'll post it now.
@Adám how do I do the input on TIO though? I was testing on my REPL
@J.Sallé Just add lines to Input; one for each .
@Adám Like this? >.>
Output doesn't show anything
@J.Sallé Inside Code, you need ⎕← to output. However, there is a lot of golfing you can do.
9:33 PM
@Adám Oh, okay. I'll do whatever golfing I can tomorrow, though. As always, thanks for the help!
1 hour later…
10:40 PM
@J.Sallé I am very impressed by your APL skills. You started learning from nothing, right? I still have no idea what your code does or how you managed to write it. Anyway, I golfed it a bit just by moving stuff around; it is still doing exactly the same: Try it online!

« first day (322 days earlier)      last day (1625 days later) »