« first day (308 days earlier)      last day (2330 days later) » 
09:00 - 19:0019:00 - 22:00

7:00 PM
What is <c-L> supposed to do?
 
Is (⊂3 3⍴⎕A) one scalar? If is a scalar ⍴⍴ of it is 0?
 
@RosLuP yes and yes
 
@Pavel Control L clears the terminal. That's what I tried to type
 
Oh, neat
 
@RosLuP Feel free to try things like that using the chatbot:
⍞←⍴⍴⊂3 3⍴⎕A
 
7:01 PM
@Adám 0
 
@all Are we clear about dyadic ?
 
⍞←⍴⍴1
 
@EriktheOutgolfer 0
 
@Adám yes
 
Monadic is pretty much the inverse of monadic . It discloses a scalar (again, if possible; a simple scalar remains the same).
If you use it on a high rank array (i.e. not enclosed), it will give you the first (top left) element:
⎕←3 3⍴⎕A ⋄ ⎕←⊂3 3⍴⎕A ⋄ ⎕←⊃⊂3 3⍴⎕A ⋄ ⎕←⊃3 3⍴⎕A
 
7:05 PM
@Adám
ABC
DEF
GHI
┌───┐
│ABC│
│DEF│
│GHI│
└───┘
ABC
DEF
GHI
A
 
The last feature ("first") means that you can combine it with reverses etc, to get corner elements:
⍞←⊃⌽3 3⍴⎕A ⍝ top right
 
@Adám C
 
⍞←⊃⊖3 3⍴⎕A ⍝ bottom left
 
@Adám G
 
⎕←⊃⌽⊖3 3 ⍴⎕A ⍝ bottom right.
 
7:07 PM
@Adám
I
 
I often use it with ¨ (each) to get initials:
⍞←⊃¨'Hello' 'World'
 
@Adám HW
 
Dyadic is "Pick". It digs into nested arrays. Every scalar on its left is the index of an element in subsequent layers of nestedness:
⍞←(⊂2 3)⊃3 3⍴⎕A
 
@Adám F
 
⍞← 2 3 1⊃(1 2 3)(4 5 (6 7 8))
 
7:10 PM
@Adám 6
 
@Adám it can't be used with high-rank arrays, right?
 
@EriktheOutgolfer I just did in my first example. The index has to be a scalar though, so you have to enclose it.
 
@Adám cool
 
⍞←(1 2) 2⊃2 2⍴(1 2)(3 4)(5 6)(7 8)
 
@Adám 4
 
7:13 PM
Here the first index is 1 2, which picks the element (3 4), and the second index is 2, which picks the 4.
Note that 2 2⍴(1 2)(3 4)(5 6)(7 8) is a 2-by-2 matrix of two-element vectors:
⎕← 2 2⍴(1 2)(3 4)(5 6)(7 8)
 
@Adám
┌───┬───┐
│1 2│3 4│
├───┼───┤
│5 6│7 8│
└───┴───┘
 
⎕←(⊂1 3)2⊃2 3⍴(1 2)(3 4)(5 6)(7 8)(9 10)(11 12)
 
@EriktheOutgolfer

Rebuilding user command cache... done
Was OFF -fns=off
⍎DOMAIN ERROR
 __field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''box on -fns=on''⊣enableSALT' ⋄ ⎕←(⊂1 3)2⊃2 3⍴(1 2)(3 4)(5 6)(7 8)(9 10)(11 12)
                                                                                           ∧

Real time: 1.015 s
User time: 0.930 s
Sys. time: 0.041 s
CPU share: 95.65 %
Exit code: 0
 
@Adám
why does it throw?
oh wait do I enclose too much
 
@EriktheOutgolfer Because the first index was doubly enclosed. Remember stranding!
 
7:16 PM
⍞←(1 3)2⊃2 3⍴(1 2)(3 4)(5 6)(7 8)(9 10)(11 12)
 
@EriktheOutgolfer 6
 
OK, next up is the new . (Stop me if I go too fast!)
 
@Adám will take some time to get used to :-D
 
Monadic is called Nest because it guarantees you that the result is nested (non-simple).
@EriktheOutgolfer Well, you don't have to use stranding if you don't want:
⍞←((⊂1 3),2)⊃2 3⍴(1 2)(3 4)(5 6)(7 8)(9 10)(11 12)
 
7:18 PM
@Adám 6
 
(1 2)(3 4 5) is already nested, and won't do anything:
⎕←(1 2)(3 4 5) ⋄ ⎕←⊆(1 2)(3 4 5)
 
@Adám
┌───┬─────┐
│1 2│3 4 5│
└───┴─────┘
┌───┬─────┐
│1 2│3 4 5│
└───┴─────┘
 
And so in :
⍞←⊃¨'Hello' 'World'
Dyalog APL
@Adám HW
What is HW? Is it a vector of chars? So /rho /rho of that is 1? Or possible something else
 
@RosLuP Yes, correct.
 
@RosLuP you can use the bot to try out yourself ;)
 
7:21 PM
@RosLuP Also, to write rho (⍴) use the linked language bar on the right (second pinned message), or copy from the list of characters (third pinned).
@RosLuP Even though ¨ would make a list of enclosed items, since the items here are simple scalars, they cannot be enclosed, and thus fuse into a simple vector.
@RosLuP Compare to:
⎕←1↑¨'Hello' 'World'
 
@Adám
┌─┬─┐
│H│W│
└─┴─┘
 
Here we take the first 1 element(s) of each, so that makes one 1-element vector for each, and since vectors can be enclosed, the result is nested.
1 2 3 is not nested, so will nest it:
⎕←⊆1 2 3
 
@Adám
┌─────┐
│1 2 3│
└─────┘
 
Works on higher rank too, of course:
⎕←⊆2 3⍴⊂'abc' ⍝ already nested, so no-op
 
@Adám
┌───┬───┬───┐
│abc│abc│abc│
├───┼───┼───┤
│abc│abc│abc│
└───┴───┴───┘
 
7:25 PM
⎕←⊆2 3⍴'abc'
 
@Adám
┌───┐
│abc│
│abc│
└───┘
 
⎕←⍴⍴(1↑¨'Hello' 'World')
 
@RosLuP
1
 
Dyadic is also called partition ( and originate with different APL dialects, but Dyalog APL now features both). To distinguish them, we can call "partitioned enclose" and just "partition", but it doesn't say much.
@RosLuP What you want to look at is the depth, not the rank:
 
⎕←⍴⍴,(1↑¨'Hello' 'World')
 
7:28 PM
@RosLuP
1
 
⍞←≡1↑¨'Hello' 'World' ⋄ ⍞←≡⊃¨'Hello' 'World'
 
@Adám 2
 
⎕←≡1↑¨'Hello' 'World' ⋄ ⎕←≡⊃¨'Hello' 'World'
 
@Adám
2
1
 
The first one has an additional layer of nesting (="deeper depth").
@RosLuP Both of them are two element vectors, however. The first is a vector of vectors, the second a vector of scalars.
Dyadic works similarly to dyadic but with different rules for the left argument. The left argument is non-negative integer instead of Boolean, and new partitions begin whenever an element is higher than its neighbour on the left. Also, elements indicated by 0s are dropped completely:
⎕←1 0 0 1 1 3 2 2 5 5 0⊆'Hello World'
 
7:33 PM
#tio help
 
@Adám
┌─┬──┬───┬──┐
│H│lo│ Wo│rl│
└─┴──┴───┴──┘
 
@Pavel )about is probably a better fit for what you need.
 
@EriktheOutgolfer You can evaluate an APL expression by typing it into chat prefixed by ⍞←. Use ⎕← instead for boxed display and multi-line results. Do not use markdown. Commands: )lb for language bar, )help for table of language elements, )docs for full documentation, )ref for PDF reference card.
 
@Pavel this
 
7:36 PM
@all Is clear?
 
@Adám for me yeah
 
Oh, one more trick: 1⊆array is the same as ,⊂array but uses a single dyadic function instead of two monadic ones, i.e. great for trains.
 
@Adám that's useful
 
Monadic , then.
 
basically dyadic also does dyadic 's job with ⎕ML ← 3
 
7:40 PM
@EriktheOutgolfer Yes, which means that in most cases you can count as a single byte, even though it isn't in the character set. However, then you can't use , and monadic becomes less powerful.
Monadic is almost the same as monadic (i.e. identity). However, it will "materialise" the default property of a class. For collections, this means the Item property, so in effect it turns collections into vectors of items.
 
@Adám talking about .NET stuff right?
 
@EriktheOutgolfer E.g., but it applies to all objects with default property. You can create one yourself too.
 
@Adám example please?
 
working on it…
 
hello? can you see this?
 
7:50 PM
@EriktheOutgolfer yes
 
@Adám phew, many flags make chat irritatingly slow
 
@EriktheOutgolfer Try it online!
 
@Adám That's new to me. Nice to know it's how you make classes
 
⎕←≡0↑¨'Hello' 'World'
 
7:57 PM
@RosLuP
2
 
@Adám can classes have any number of properties other than default?
 
@Adám Proposed topic for next learning session: OOP
 
@J.Sallé Yes.
@Pavel Maybe for when we finish with the primitive functions?
 
@Pavel we're not over with the functions yet :p
 
Dyadic is similar to dyadic but works its way into the rank instead of the depth. On a 3D array, the first element selects layer, the second row, the third column:
⎕←2 3 4⍴⎕A
 
7:59 PM
now we're through functions which are very important
 
@Adám
ABCD
EFGH
IJKL

MNOP
QRST
UVWX
 
and we had many timeouts with flags
 
⎕←2⌷2 3 4⍴⎕A
 
@Adám
MNOP
QRST
UVWX
 
⎕←2 1⌷2 3 4⍴⎕A
 
8:00 PM
@Adám
MNOP
 
⎕←2 1 3⌷2 3 4⍴⎕A
 
@Adám
O
 
Each element of the left argument may be may be any simple array:
 
⎕←≡'' ''
 
@RosLuP
2
 
8:01 PM
⎕←(⊂1 3)⌷2 3 4⍴⎕A
 
@Adám

Rebuilding user command cache... done
Was OFF -fns=off
⍎INDEX ERROR
 __field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''box on -fns=on''⊣enableSALT' ⋄ ⎕←(⊂1 3)⌷2 3 4⍴⎕A
                                                                                           ∧

Real time: 1.070 s
User time: 0.918 s
Sys. time: 0.077 s
CPU share: 92.99 %
Exit code: 0
 
⎕←(⊂1 1)⌷2 3 4⍴⎕A ⍝ sorry!
 
@Adám
ABCD
EFGH
IJKL

ABCD
EFGH
IJKL
 
⎕←2 (1 3)⌷2 3 4⍴⎕A ⍝ first and third row of second layer
 
@Adám
MNOP
UVWX
 
8:03 PM
⎕←(1 2)1 3⌷2 3 4⍴⎕A ⍝ third char of first row of layers 1 and 2
 
@Adám
CO
 
⎕←(1 2)(2 3)⌷2 3 4⍴⎕A ⍝ rows 2 and 3 of each of layers 1 and 2
 
@Adám
EFGH
IJKL

QRST
UVWX
 
That concludes this weeks lesson. Thank you all, and feel free to hang around!
 
well, this time we also had timeouts. :D
 
8:06 PM
@EriktheOutgolfer Do you want to continue now?
 
@Adám nah
it was enough for today
 
@EriktheOutgolfer I think we are holding at a good spot, having covered the array-packaging and array-unpackaging functions. Next up are the unrelated grades.
@EriktheOutgolfer ⍳ / ⍴ are pretty essential, no?
 
@Adám and index generators, membership tester, setwise operations, boolean NOT
@Adám especially you can't do without
 
@EriktheOutgolfer and / and form the core of most applications. Interesting, isn't it, that we added a new primitive in 16.0 which encapsulates exactly those three? is essentially {⍵/⍳⍴⍵}.
@EriktheOutgolfer In fact, the interpreter recognises the sequence /⍳⍴ and tokenises it as a single token. It then evaluates it in an optimised manner, increasing speed and reducing memory usage compared to performing each of the three operations separately.
 
8:26 PM
@Adám huh? how?
 
@EriktheOutgolfer When you fix (i.e define) a function, the interpreter tokenises your code so that it will run without interpretive overhead. It recognises certain multi-primitive patterns at tokenisation time and makes them into single tokens that are different from the single-primitive tokens.
 
@Adám then why not add them as builtins :p
 
@EriktheOutgolfer Well, we did add , but there are so many patterns. You wouldn't want a symbol for each one. Part of the power of (Dyalog) APL is exactly that you can express yourself in a relatively simple language, and then have very optimised C code actually do the computation – all without you having to worry about which special arguments' case you have this time around.
@EriktheOutgolfer There are also many function compositions and dfn snippets that are recognised in certain contexts or with certain arguments, and run special dedicated code.
 
8:56 PM
@Adám I'm not completely sure of the difference between pick and materialize. Can you show a case where their action will differ?
 
@Uriel You mean pick and index? (Dyadic vs )
 
@Adám yup, the thin box thingy
 
⎕←(⊂2 3)⌷3 4⍴⎕A
 
@Adám
EFGH
IJKL
 
⎕←(⊂2 3)⊃3 4⍴⎕A
 
8:58 PM
@Adám
G
 
@Uriel (⊂2 3)⌷ selects second and third row. (⊂2 3)⊃ selects second row's third element.
 
@Adám so the pick one rewritten for index is 2 3⌷?
 
@Uriel Yes. But that only applies to simple arrays. can never dig into the scalars of an array. can never return multiple elements from different locations.
 
@Adám index can't do that, unless applied in chains. pick can't do that, unless combined with each.
 
@Uriel can never do that. It doesn't disclose. You can dispense with and just use ⊃¨. Indeed some APL dialects only have and not .
@Uriel cannot get 5 from 1 (2 3 ((4 5) 6) 6 7 )9 like
 
9:08 PM
@Adám thanks!
 
⍞←2 3 1 2⊃1 (2 3 ((4 5) 6) 6 7 )9
 
@Adám 5
 
just out of curiosity, is materialize an original APL thingy or dyalog specific?
 
9:19 PM
@Uriel It was not in APL until quite late, but APL2, APLX, and NARS have it too. J has a very similar function.
 
@Adám well, J founder did deflect to the APL side
 
09:00 - 19:0019:00 - 22:00

« first day (308 days earlier)      last day (2330 days later) »