« first day (350 days earlier)      last day (2305 days later) » 
13:00 - 22:0022:00 - 00:00

 
1 hour later…
2:29 PM
Informal APL learning session tonight at 18:30 UTC in https://chat.stackexchange.com/rooms/52405/apl. See https://chat.stackexchange.com/transcript/message/41299896 if you don't have 20 Stack Exchange rep points.
 
 
2 hours later…
4:38 PM
@Adám what was that command to use 128-bit floating point representation in the REPL?
 
@J.Sallé Anywhere, not just in the session: ⎕FR←1287
 
@Adám thanks!
 
@J.Sallé It would be really nice if you would ask such questions on SO, so APL could get more exposure there.
 
@Adám you mean in chat or as a general question?
 
@J.Sallé As a main SO question post.
 
4:42 PM
@Adám Okay, I'll keep that in mind :)
 
@J.Sallé Thanks.
 
5:05 PM
@Adám so, when using the operator, I'm getting a syntax error on this dfn {((?⍴⍵)⌷⍕⍵)⍣⍴⍵}. I just wanted to repeat ((?⍴⍵)⌷⍕⍵) ⍴⍵ times, what am I doing wrong? (Also, I can rephrase that question and post it on SO if you feel like giving an in-depth explanation or something)
If it's relevant, I also get a syntax error if I try to use any integer in place of the last ⍴⍵
 
@J.Sallé um, not Adám here, but you're trying to execute an array
also, you need parentheses around ⍴⍵
 
@EriktheOutgolfer input's a string
 
@J.Sallé a string is an array
 
@EriktheOutgolfer and I've tried that also, it still errors on me
 
@J.Sallé because ((?⍴⍵)⌷⍕⍵) isn't a function
 
5:19 PM
@EriktheOutgolfer it does what it's supposed to do when I don't use the operator, though.
 
@J.Sallé then the function is {(?⍴⍵)⌷⍕⍵}, not just (?⍴⍵)⌷⍕⍵
so maybe you want {{(?⍴⍵)⌷⍕⍵}⍣(⍴⍵)} instead
 
@EriktheOutgolfer also tried that already, and it throws a domain error
Actually it throws a domain error without the parens, with them it throws the syntax error again.
 
@J.Sallé well, yes, since isn't length but shape
length is
shape is a 1-dimensional array (vector), while the right operand of is either a 0-dimensional array (scalar) or a function
@J.Sallé does {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)} work?
hm
 
@EriktheOutgolfer Nope, still erroring. But you gave me another idea. I'll try some things out
 
@J.Sallé oh, and one last thing: you need to append ⊢⍵
{{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}
btw you need all of the fixes I mentioned above, or it doesn't work
 
5:28 PM
@EriktheOutgolfer Yeah, I figured as much. It's throwing domain errors now.
 
@J.Sallé what is the argument you're giving it? for me it works for character vectors
 
@EriktheOutgolfer a single string 'Hello World'
 
      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'
l
      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'

      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'
o
      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'
e
      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'
l
      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'
e
      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'
o
      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'
l
      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'
o
      {{(?⍴⍵)⌷⍕⍵}⍣(≢⍵)⊢⍵}'Hello World'
l
@J.Sallé for me it works?
(yes, 4th line is a space)
 
@EriktheOutgolfer it's not what I meant for it to do, though. (to my knowledge) it should be printing a random letter from the string ≢⍵ times.
 
@J.Sallé {{⍵[?≢⍵]}¨(≢⍴⊂)⍵} should work then?
      {{⍵[?≢⍵]}¨(≢⍴⊂)⍵}'Hello World'
rWWlHooW Hd
      {{⍵[?≢⍵]}¨(≢⍴⊂)⍵}'Hello World'
llHHreWleHo
      {{⍵[?≢⍵]}¨(≢⍴⊂)⍵}'Hello World'
eorWldlWerW
      {{⍵[?≢⍵]}¨(≢⍴⊂)⍵}'Hello World'
HrW eooH rH
      {{⍵[?≢⍵]}¨(≢⍴⊂)⍵}'Hello World'
WHler ldWlo
      {{⍵[?≢⍵]}¨(≢⍴⊂)⍵}'Hello World'
ololWldWllH
      {{⍵[?≢⍵]}¨(≢⍴⊂)⍵}'Hello World'
WoH ll ldrH
      {{⍵[?≢⍵]}¨(≢⍴⊂)⍵}'Hello World'
relldlHo ld
 
5:41 PM
@EriktheOutgolfer That was actually my first code, but it didn't seem to work because it doesn't print every letter of the string
And it duplicates some times
 
@J.Sallé oh you mean it should return a random permutation?
 
@EriktheOutgolfer yes
I think I found a solution though
{⍵[(≢⍵)?≢⍵]}'Hello World!'
 llerH!Woold
      {⍵[(≢⍵)?≢⍵]}'Hello World!'
lroelldHW!o
      {⍵[(≢⍵)?≢⍵]}'Hello World!'
!olrdHloelW
      {⍵[(≢⍵)?≢⍵]}'Hello World!'
rllHW!oole d
      {⍵[(≢⍵)?≢⍵]}'Hello World!'
Hl oollWerd!
      {⍵[(≢⍵)?≢⍵]}'Hello World!'
 oHlroeldl!W
That seems to work doesn't it?
Anyway, I was going to post this to the Riffle-Shuffle CnR, but it's way too short (and now way too public) to be any challenge at all.
 
@J.Sallé yes, deal is exactly what you need here
 
It is nice though and some of the permutations look like they could be actual APL code
{⍵[f?f←≢⍵]}'{⍵[f?f←≢⍵]}'
{f[f←?≢]}⍵⍵
 
although you can also write it more elegantly as {⍵[?⍨≢⍵]}
 
5:50 PM
@EriktheOutgolfer yeah, but that's even shorter. I never thought that would be a problem in ppcg lmao
 
and, as a tacit function: ?⍨∘≢⊃⊢
 
@EriktheOutgolfer lol I literally just tried that exact same code in my repl
 
@J.Sallé ⊂⊃¨⍨≢?≢ is shorter.
@EriktheOutgolfer That doesn't work.
 
Yeah it doesn't :p
 
@EriktheOutgolfer Would need to be ?⍨∘≢⊃¨⊂ at same length as mine.
 
5:57 PM
@Adám yeah it's an approximation :P
 
@Adám that doesn't seem to work either
?⍨∘≢⊃¨⊂'{⍵[?⍨≢⍵]}'
1
 
@J.Sallé It's a train:
 
@J.Sallé parentheses
 
Duh >.>
 
⍞←(?⍨∘≢⊃¨⊂)'{⍵[?⍨≢⍵]}'
 
5:58 PM
@Adám ≢{⍨⍵]?[⍵}
 
Anyhow, I'd need to obfuscate the living hell out of that to try to stall you guys long enough on a CnR thread :p
 
@J.Sallé I have no idea what the challenge is.
 
@Adám Basically: create a fn/program that makes a riffle-shuffle and run the source code through it.
That program doesn't actually riffle-shuffles though, so I can still change it I think
 
@J.Sallé yep, that is what you shouldn't disclose
 
@J.Sallé Like this?
 
6:04 PM
@Adám that's scary
the hell's ⎕AV do?
 
constant that contains the Dyalog Classic codepage
 
@EriktheOutgolfer I see
 
@Adám that's cool, actually hahahahah
 
@Adám APL-f*ck :P
 
6:30 PM
Welcome to the APL learning session!
We're going through the system functions. Next up are some easy constants.
⎕A is the uppercase English alphabet:
⍞←⎕A
 
@Adám ABCDEFGHIJKLMNOPQRSTUVWXYZ
 
There's no Dyalog built-in for the lowercase alphabet, but you can get it with:
⍞←819⌶⎕A
 
@Adám abcdefghijklmnopqrstuvwxyz
 
⎕D has the digits:
 
(temporary solution; likely to stop working at a later version :D I'd rather 'abcdefghijklmnopqrstuvwxyz' >.>)
 
6:31 PM
⍞←⎕D
 
@Adám 0123456789
 
@EriktheOutgolfer Well, 819⌶ is likely to be replaced with a proper system function at some point.
 
> An event is starting 2 mins ago in APL - "APl learning session"
 
@Adám Why specifically 819?
 
wait what?
 
6:33 PM
@Pavel 819 looks like BIg :-)
 
@Adám Um, really?
 
@Pavel Yes.
 
...huh
 
Anyway, ⎕NULL is a scalar null value. It isn't really used much in APL itself, but you can meet it e.g. when importing spreadsheets where it represents empty cells.
 
6:35 PM
What does monadic I-beam do?
 
@Pavel I-beam is a monadic operator.
 
I-beam is an operator, there's no "monadic/dyadic" ...duh Adám is so fast
 
@Pavel So N⌶ derives a monadic, dyadic, or ambivalent function which you can then apply. The N selects which function.
 
⍞←⌶
 
@Pavel ⌶
 
6:37 PM
@Pavel See Lesson 4.
 
⍞←819⌶
 
@Pavel 819 ⌶
 
¯\_(ツ)_/¯
 
@Pavel That's completely analogous to:
⍞←,¨
 
@Adám ,¨
 
6:39 PM
It should be noted that ⎕NULL equals itself.
These three (⎕A ⎕D ⎕NULL) are system constants; you can't assign to them.
 
@Adám hooray, finally a language which isn't a weirdo!
 
Is ⎕NULL also the .NET null?
 
@Pavel Yes.
 
@EriktheOutgolfer Other than JS, when does null ever not equal null?
 
@Pavel But it is not JSON null, which is represented as ⊂'null' to match true and false being ⊂'true' and ⊂'false'.
Let's go on with more advanced features.
⎕CMD and ⎕SH are exactly identical, but obviously the first feels more natural to Windows users while the second feels more natural to UNIX users. Pressing on them will give you the help appropriate for that OS.
As you of course can guess, they are used to call the OS command processor.
⍞←⎕SH'ls /'
 
6:44 PM
@Adám  bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
 
@DyalogAPL TIO root directory contents.
 
⍞←⎕SH'ls' , '/'
 
@Pavel ERROR: Use ⎕← for a full error report
 
@Pavel You need a space after ls, no?
 
@Adám I forgot that the comma makes it a single character vector, I meant to have an array of two strings there
 
6:47 PM
@Pavel Why? A UNIX command is a single string, no?
 
@Adám In e.g. python's equivalent of ⎕SH, you can either pass a full command, or a list containing the executable to run and then the arguments to pass in, which wouldn't be processed by the shell.
 
@Pavel Dyadic ⎕SH/⎕CMD starts an auxiliary processor where the processor name is the left argument and the right argument is a list of arguments.
 
@Adám Ah, I see. So I would use 'ls'⎕SH'/'
Um, how do I define a list with one element?
So I have a list containing '/'
 
I think it's
 
@Pavel You can just use a simple scalar or vector if you only need one.
@Pavel ,'a' is a 1-element list.
Anyway, see the full documentation for details.
⎕CSV will import and export Character Separated Values.
⎕←⎕CSV '"abc","def",3' 'S'
 
6:55 PM
@Adám
┌───┬───┬─┐
│abc│def│3│
└───┴───┴─┘
 
It has a ton of options for almost anything you could want. Again, the full documentation is available by pressing F1 with the cursor on it, and also online. Now you know it exists.
Btw, it can import and export directly to and from text files.
⎕DR is Data Representation. Monadically, it will tell you how an array is represented internally, and dyadically, it allows you to convert between data types:
⍞←⎕DR 42
 
@Adám 83
 
⍞←⎕DR 1 'a' 2 3 'beth'
 
@EriktheOutgolfer 326
 
Dyalog APL data type codes have two parts, the 1's place and the rest.
The 1's place tells you which kind of data it is, the rest tells you how many bits are used to store it (with one exception).
 
@EriktheOutgolfer 6 means a memory pointer, and 32 means 32-bit. However, TIO really runs a 64-bit system. This is the exception; pointers are always 326 even on 64 bit systems.
The number 42 gave us 83, where 3 means integer and 8 means 8-bit.
 
hello
 
@osmelg Hi, welcome to.
Dyalog APL has single-bit Boolean arrays, so they are type 11 where the rightmost 1 means Boolean, and the leftmost 1 means 1-bit.
⍞←⎕DR 1 0 1 1 1 0
 
@Adám 11
 
Dyadic ⎕DR lets you convert between types:
⍞←11 ⎕DR 42
 
7:04 PM
@Adám 0 0 1 0 1 0 1 0
 
what kinds of problems can we solve here ?
 
This takes the memory which was used to represent 42 and interprets it as if it was a Boolean array.
@osmelg The problem of not knowing all of Dyalog APL.
 
⍞←11 ⎕dr ○1
 
@dzaima 0 0 0 1 1 0 0 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 0 1 1 1 1 1 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 0 0 0 0
 
excellent, because i need the basics
any basic examples?
 
7:07 PM
@osmelg I'd suggest looking back at the first lessons
 
thats it :D
ty erik
 
@osmelg alternatively, you can also use this to get a very, very basic understanding (beware hurts eyes)
 
jejeje let me check it
 
You can also combine two steps of ⎕DR into one. A two-element left argument will interpret the right argument as that type, then convert it to the type given by the second element of the left argument.
⎕FMT is ForMaT. It is like a beefed up version of .
returns a vector for single line arguments, and a matrix otherwise. ⎕FMT always returns a matrix.
Also, treats control characters as normal characters, while ⎕FMT will resolve them:
⍞←'abc',(⎕UCS 8),'def' ⍝ 8 is backspace
 
@Adám abcdef
 
7:13 PM
⍞←⍕'abc',(⎕UCS 8),'def' ⍝ 8 is backspace
@DyalogAPL Hello?
⍞←⍕'abc',(⎕UCS 8),'def' ⍝ 8 is backspace
Oh well.
 
@DyalogAPL WAKE UP before I slap you harshly on your face!
 
⍞←⎕FMT 'abc',(⎕UCS 8),'def' ⍝ 8 is backspace
 
@Adám abdef
 
see? you need to discipline
 
⍞←⍴⎕FMT'abc',(⎕UCS 8),'def' ⍝ 8 is backspace
 
7:15 PM
@Adám 1 5
 
So you see that the c really was erased by the backspace.
Dyadic ⎕FMT gives you access to a whole new language, namely a formatting specification language. I won't go though all the details here (see docs!), but here's a taste:
⎕←'I3,F5.2' ⎕FMT 2 4⍴⍳8
 
@Adám
  1 2.00  3 4.00
  5 6.00  7 8.00
 
The formatting string I3,F5.2 means that each row should first have an integer, then a float which uses five characters in width and has 2 decimals, then this formatting is cycled as much as needed for all the columns (here twice).
@all Anyone up for guessing what ⎕JSON does?
 
Does dyalog have dictionaries?
 
@Pavel Dyalog has namespaces which work pretty much the same.
 
7:23 PM
⍞←⎕SH¨'ls' '..' 'ls'
 
@RosLuP ERROR: Use ⎕← for a full error report
 
is .. a valid command
 
@RosLuP .. isn't a valid UNIX command, is it?
ninja'd.
 
⍞←⎕SH¨'ls' 'ls'
 
@RosLuP
 
7:25 PM
@RosLuP Try with ⎕←
 
you need ⎕← not ⍞←
ninja'd
 
So ⎕JSON imports/exports JSON, of course. It works for both arrays and objects:
⎕←⎕JSON'[[42,null],"hello"]'
 
@Adám
┌───────────┬─────┐
│┌──┬──────┐│hello│
││42│┌────┐││     │
││  ││null│││     │
││  │└────┘││     │
│└──┴──────┘│     │
└───────────┴─────┘
 
⎕←⎕SH¨'ls' 'ls'
 
@RosLuP
┌┬┐
│││
│││
│││
└┴┘
 
7:27 PM
⎕←ns←⎕JSON'{"abc":42,"de":null,"f":"hello"}' ⋄ ⎕←ns.(abc f)
 
@Adám
#.[JSON object]
┌──┬─────┐
│42│hello│
└──┴─────┘
 
@RosLuP I think the current directory is empty. Try giving a path to ls.
And export:
⍞←⎕JSON ('abc' 1 2 3)4 5
 
@Adám [["abc",1,2,3],4,5]
 
Just be aware that if you want to convert and APL string to JSON, you need use the left argument to specify whether you want import (0) or export (1).
 
⎕←⎕SH 'ls ../'
 
7:30 PM
@RosLuP

Rebuilding user command cache... done
ls: cannot open directory '../': Permission denied
⍎DOMAIN ERROR: Command interpreter returned failure code 2
 __field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄''''' ⋄ ⎕←⎕SH'ls ../'
                                                                                                              ∧

Real time: 1.260 s
User time: 1.120 s
Sys. time: 0.069 s
CPU share: 94.31 %
Exit code: 0
 
You can also tell ⎕JSON that you want your JSON fully white-spaced:
⎕←⎕JSON⍠'Compact'0⊢('abc' 1 2 3)4 5
 
@Adám
[
  [
    "abc",
    1,
    2,
    3
  ],
  4,
  5
]
 
@DyalogAPL eugh
 
Finally, while you can import any JSON object, not every APL namespace can be exported. E.g. a namespace with APL functions cannot be converted to JSON. (Would be cool though if they were converted to JavaScript objects with the equivalent JavaScript functions…)
@EriktheOutgolfer Well, you don't have to.
Again, ⎕JSON has some more advanced options — see the docs.
 
What is "JSON" and if it is a library, what is the language it first it was implemented? Thanks
 
7:36 PM
I think it means JavaScript Object Notation or something?
 
@RosLuP JSON is a widely used (especially online) notation for objects and arrays.
@EriktheOutgolfer Yes, but it is not identical to JavaScript's object notation.
 
@Adám well of course no why would APL rely on something so JS-y
 
(There is valid JSON which is not valid JavaScript, and JavaScript object notation which is not valid JSON.)
@EriktheOutgolfer ⎕JSON is fully compliant with JSON, though, but we do allow some leniency which allows you to create some JavaScript objects which are not valid JSON.
E.g.:
⍞←⎕JSON 'hello' (⊂'world')
 
@Adám ["hello",world]
 
⎕←⎕JSON 'hello',0,'world'
 
7:42 PM
@RosLuP
["h","e","l","l","o",0,"w","o","r","l","d"]
 
@RosLuP JSON doesn't have the concept of a scalar character, so APL does its best to give you something useful.
 
⎕←⎕JSON ('hello' 0 'world')
 
@Pavel
["hello",0,"world"]
 
⎕←⎕JSON ⎕NULL
 
@Pavel

Rebuilding user command cache... done
⍎DOMAIN ERROR: The right argument cannot be converted to JSON (⎕IO=1)
 __field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄''''' ⋄ ⎕←⎕JSON ⎕NULL
                                                                                                              ∧

Real time: 1.046 s
User time: 0.944 s
Sys. time: 0.047 s
CPU share: 94.70 %
Exit code: 0
 
7:44 PM
Aww
 
@Pavel As I mentioned above, you need to use ⊂'null' for that.
 
@Adám I remember, but I still was curious if using ⎕NULL did anything.
 
@Pavel We opted for a generalised system for strings without quotes, rather than special casing null. The i-beam that preceded ⎕JSON did in fact use ⎕NULL. By using enclosed strings, we can losslessly roundtrip.
⎕MAP is a function I'll only mention and not demonstrate (again, see docs) because TIO makes this hard. It basically allows you to use a file as an array instead of keeping the array in memory. Very useful.
 
⎕←⎕JSON ('hello' , 'world')
 
@RosLuP

Rebuilding user command cache... done
⍎DOMAIN ERROR: Invalid character at offset 1 (⎕IO=1)
 __field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄''''' ⋄ ⎕←⎕JSON('hello','world')
                                                                                                              ∧

Real time: 1.041 s
User time: 0.947 s
Sys. time: 0.052 s
CPU share: 96.07 %
Exit code: 0
 
7:48 PM
@RosLuP That's a simple character vector, so ⎕JSON defaults to converting from JSON, but it isn't valid JSON, hence the error.
 
@RosLuP you need left argument 1
⍞←1⎕JSON'hello','world'
 
@EriktheOutgolfer "helloworld"
 
Great for ensuring proper escaping:
⍞←1 ⎕JSON 'abc',(⎕UCS 9 10),'def'
 
@Adám "abc\t\ndef"
 
This brings us to ⎕UCS which in its monadic form flips characters and their Unicode code points:
⍞←⎕UCS 954 945 955 951 956 941 961 945
 
7:51 PM
@Adám καλημέρα
 
(Our documentation manager lives in Greece.)
The dyadic form takes a left argument specifying an encoding scheme and converts to and from byte values rather than code points:
⍞←'UTF-8' ⎕UCS 206 179 206 181 206 185 206 177 32 207 131 206 191 207 133
 
@Adám γεια σου
 
⎕←2⎕JSON ('hello' , 'world')
 
@RosLuP

Rebuilding user command cache... done
⍎DOMAIN ERROR: Invalid left argument
 __field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄''''' ⋄ ⎕←2 ⎕JSON('hello','world')
                                                                                                              ∧

Real time: 1.049 s
User time: 0.953 s
Sys. time: 0.045 s
CPU share: 95.13 %
Exit code: 0
 
@RosLuP Just 0 and 1 for import and export.
 
7:58 PM
⍞←⎕JSON 'hello' ⊂'world'
 
@RosLuP ERROR: Use ⎕← for a full error report
 
⎕VFI is Verify and Fix Input. It takes a string and returns two lists. It cuts the string into space separated fields. Then it attempts to convert each field to a number. If it succeeds then the corresponding element of the left result list is 1 (else 0) and the corresponding element of the right list is the number (else 0).
@RosLuP You need to stop from taking 'hello' as left argument:
⍞←⎕JSON 'hello' (⊂'world')
 
@Adám ["hello",world]
 
⎕←⎕VFI '123 four 42'
 
@Adám
┌─────┬────────┐
│1 0 1│123 0 42│
└─────┴────────┘
 
8:00 PM
You can also specify one or more valid field separators as left argument:
⎕←';/'⎕VFI '123 four,42 5/2/4'
 
@Adám
┌─────┬─────┐
│0 1 1│0 2 4│
└─────┴─────┘
 
Here 123 four were grouped because space is not a separator anymore, and so it is an invalid number. So too with 42 5. Only 2 and 4 were valid.
You can get just the valid numbers with:
⎕←//';/'⎕VFI '123 four,42 5/2/4'
 
@Adám
┌───┐
│2 4│
└───┘
 
2 messages moved to trash
⎕XML is converts to and from XML, but the corresponding APL format is rather involved. I usually just use ⎕XML to verify that my XML is valid or to normalise whitespace:
 
⍞←⎕JSON 'h' 'e' 'l' 'l' 'o'
 
8:04 PM
@RosLuP ERROR: Use ⎕← for a full error report
 
⎕←⎕XML⍣2 ⊢ '<xml><document id="001">An introduction to XML</document></xml>'
 
@Adám
<xml>
  <document id="001">An introduction to XML</document>
</xml>
 
And that concludes the lesson for today.
Thank you all for joining in. Feel free to return with questions etc. throughout the week. However, it would be nice if you would post general APL programming questions to Stack Overflow so APL could get some exposure there and others could benefit too. Don't forget to tag your questions !
 
⎕←⎕JSON ('h' 'e' 'l' 'l' 'o')
 
@RosLuP

Rebuilding user command cache... done
⍎DOMAIN ERROR: Invalid character at offset 1 (⎕IO=1)
 __field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄''''' ⋄ ⎕←⎕JSON('h' 'e' 'l' 'l' 'o')
                                                                                                              ∧

Real time: 1.051 s
User time: 0.957 s
Sys. time: 0.050 s
CPU share: 95.85 %
Exit code: 0
 
8:12 PM
@RosLuP A vector of scalars is just a vector, so 'a' 'b' 'c' is the same as 'abc', and ⎕JSON will again try to convert this from JSON even though it isn't valid JSON. To force conversion to JSON, use 1 ⎕JSON 'hello'.
 
⎕←⎕JSON ( ⊂ 'h' 'e' 'l' 'l' 'o')
 
@RosLuP
hello
 
@RosLuP While that generates invalid JSON, it is valid JavaScript.
 
Ok thank you
 
Actually, that's an interesting use of ⎕JSON. You can use it to insert proper escapes into any string without adding quotes by using ⎕JSON⊂:
⍞←⎕JSON ⊂(⎕UCS 27),'hello',(⎕UCS 10)
 
8:16 PM
@Adám \u001Bhello\n
 
@Adám ⎕JSON∘⊂0↓⊢, sounds interesting
 
@EriktheOutgolfer Huh, what's 0↓⊢ for?
 
@Adám so that it's easier to use with char scalars
 
@EriktheOutgolfer Why not just ,?
 
@Adám because I'm afraid it would prevent errors which shouldn't be prevented...
 
8:23 PM
@EriktheOutgolfer E.g. what? 0↓⊢ will not prevent matrices.
 
@Adám well, the least side effects the merrier :P
@Adám yes, that's why I use it, so that it ensures gets something with 1≤≢∘⍴, not necessarily 1≡≢∘⍴ (trains returning boolean)
 
@EriktheOutgolfer TIL. 0↓ hasn't always worked though, and doesn't work in some APLs. The classic method is 1/ which has worked in all APLs since the beginning of time.
 
@Adám well, whatever
btw monadic ⊂1/⊢ can be thought as "the monadic that encloses everything!", right?
 
@EriktheOutgolfer Yes. We considered making use ⊂1/ but figured it safer to make it do what is says on the tin. The user can always write ⊆1/ if they want.
 
@Adám so now here i am resorting to hackish ways :p
 
8:30 PM
@EriktheOutgolfer It isn't hackish at all. Perfectly valid and sensible Dyalog APL.
 
⎕←⊂¨ 1 2 3 4, '123'
 
@RosLuP
1 2 3 4 123
 
@RosLuP Nothing happens when you enclose a simple scalar:
⍞←3 = ⊂3
 
@Adám 1
 
⍞←a = ⊂¨ a←1 2 3 4, '123'
 
8:38 PM
@Adám 1 1 1 1 1 1 1
 
⍞←a,¨ a←1 2 3 4, '123'
 
@RosLuP  1 1  2 2  3 3  4 4  11  22  33
 
⍞←a=a←1 2 3 4, '123'
 
@RosLuP 1 1 1 1 1 1 1
 
9:05 PM
#tio alias command )explain #TIO do apl-dyalog
⎕←('%args%'⍳⍨⊃¨t)⊃(t←⎕JSON'["← ASSIGN","+ conjugate plus","- negate minus","× direction times","÷ reciprocal divide","* exponential power","⍟ natural logarithm logarithm","⌹ matrix inverse matrix divide","○ pi times circular","! factorial binomial","? roll deal","| magnitude residue","⌈ ceiling maximum","⌊ floor minimum","⊥ decode","⊤ encode","⊣ same left","⊢ same right","= equal","≠ not equal","≤ less than or equal to","< less than","> greater than","≥ greater than o
 
@Adám Added alias for )explain
 
)explain *
#tio view
 
No session found for @Adám
 
#tio alias view
 
@Adám
Command Aliases:
⍞← -> #TIO do apl-dyalog ⎕TRAP←(0 1000)'E' '''ERROR: Use ⎕← for a full error report'''⋄⎕←%args%
⎕← -> #TIO run apl-dyalog (⎕NS⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄'''''⋄⎕←%args%
)explain -> #TIO do apl-dyalog ⎕←('%args%'⍳⍨⊃¨t)⊃(t←⎕JSON'["← ASSIGN","+ conjugate plus","- negate minus","× direction times","÷ reciprocal divide","* exponential power","⍟ natural logarithm logarithm","⌹ matrix inverse matrix divide","○ pi times circular","! factorial binomial","? roll deal","| magnitude residue","⌈ ceiling maximum","⌊ floor minimum","⊥ decode"
 
9:06 PM
)explain ∧
 
Can somebody remind me what is ⊆ about?
 
@Uriel Enclose if simple and partition.
 
@Adám Huh? You mean enclose when monadic and partition when dyadic? What's the use for it then?
 
@Uriel No, monadic only encloses when the argument is simple. Dyadic is the partition primitive (not to be confused with dyadic which is "partitioned enclose").
⎕←⊂'abc' ⋄ ⎕←⊆'abc' ⋄ ⎕←⊂'abd' 'def' ⋄ ⎕←⊆'abc' 'def'
 
@Adám
┌───┐
│abc│
└───┘
┌───┐
│abc│
└───┘
┌─────────┐
│┌───┬───┐│
││abd│def││
│└───┴───┘│
└─────────┘
┌───┬───┐
│abc│def│
└───┴───┘
 
9:10 PM
@Uriel ^ It didn't enclose the last one because it was already nested.
⎕←1 1 1 2 2⊆'Hello'
 
@Adám
┌───┬──┐
│Hel│lo│
└───┴──┘
 
⎕←1 0 0 1 0⊂'Hello'
@DyalogAPL Hey!
 
@Adám It separates on higher numbers or matching groups?
 
@Uriel On higher numbers. It also removes as indicated by 0s.
)explain*
 
⎕←1 1 1 2 2 0 1 3 3 4 3 5 6 1 0 0 4 7 9 10 5123⊆'HelloWorldTwentychars'
 
9:12 PM
@Uriel
┌───┬──┬─┬──┬──┬─┬──┬─┬─┬─┬─┬─┐
│Hel│lo│o│rl│dT│w│en│c│h│a│r│s│
└───┴──┴─┴──┴──┴─┴──┴─┴─┴─┴─┴─┘
 
#TIO do apl-dyalog
⎕←('∧'⍳⍨⊃¨t)⊃(t←⎕JSON'["← ASSIGN","+ conjugate plus","- negate minus","× direction times","÷ reciprocal divide","* exponential power","⍟ natural logarithm logarithm","⌹ matrix inverse matrix divide","○ pi times circular","! factorial binomial","? roll deal","| magnitude residue","⌈ ceiling maximum","⌊ floor minimum","⊥ decode","⊤ encode","⊣ same left","⊢ same right","= equal","≠ not equal","≤ less than or equal to","< less than","> greater than","≥ greater than or equal to","≡ depth match","≢ tally not match","∨ greatest common divisor/or","∧ lowest common multiple/and","
#tio do apl-dyalog ⎕←2+2
 
@Adám 4
 
#tio do apl-dyalog
⎕←2+2
#tio do apl-dyalog
⎕←2+2
 
@Adám It resets the count on 0s as well, eh?
 
@Uriel Not "counts", but yes, 1 is greater than 0, so that begins a new partition.
 
9:15 PM
@Adám ok cool, thanks
 
#tio
do apl-dyalog ⎕←2+2
 
@Adám 4
 
#tio
alias command )explain #TIO do apl-dyalog ⎕←('%args%'⍳⍨⊃¨t)⊃(t←⎕JSON'["← ASSIGN","+ conjugate plus","- negate minus","× direction times","÷ reciprocal divide","* exponential power","⍟ natural logarithm logarithm","⌹ matrix inverse matrix divide","○ pi times circular","! factorial binomial","? roll deal","| magnitude residue","⌈ ceiling maximum","⌊ floor minimum","⊥ decode","⊤ encode","⊣ same left","⊢ same right","= equal","≠ not equal","≤ less than or equal to","< less than","> greater than","≥ greater than or equal to","≡ depth match","≢ tally not match","∨ greatest common divisor/or"
 
@Adám Added alias for )explain
 
)explain ∧
)explain∧
#tio help
 
9:19 PM
@Adám expected more arguments...
 
#tio help
 
#tio alias rcommand )explain
 
@Adám removed alias for ")explain"
 
13:00 - 22:0022:00 - 00:00

« first day (350 days earlier)      last day (2305 days later) »