« first day (372 days earlier)      last day (2579 days later) » 

00:15
@Adám How do I use an ⎕SM on Linux?
@Pavel It is just a variable you assign to. I've never used it myself, but have a look at here.
@Adám What's Dyalog APL/X?
@Pavel Dyalog APL on UNIX-based OSs.
Got it
 
6 hours later…
06:46
I wonder if it's possible to interop Mathematica and Dyalog.
⎕sh 'wolfram -code 2+2' is of course an option, but...
07:49
@Pavel Maybe have a look at the bridges to R and Python?
 
4 hours later…
11:57
@Adám should i install dyalog classic or unicode
@betseg Unicode!
test~∊⌈~ yup keyboard layout switch key works
@betseg The only reason to ever use Classic is if you are trying to solve a challenge that involves the binary representation of your code's characters. (And very large databases with accented characters may save some memory by using Classic.) For all normal purposes (even golfing), you should use Unicode, as you can (implicitly) refer to SBCS so that you may count each character as a single byte.
$ xxd aplkeys/default
00000000: 0a                                       .
$ ./dyalog
Stream 1: /opt/mdyalog/16.0/64/unicode/apltrans/default line : 1 file not ASCII / not terminated by newline. ""
wut
oh you were supposed to conenct to the interpreter through ride right
i forgot that
12:17
@betseg I'd recommend letting RIDE spawn an interpreter.
"Cannot find the interpreter's executable" when I click "Go"
@betseg Did you put in the proper path?
yes
$ /opt/mdyalog/16.0/64/unicode/mapl
Please execute /opt/mdyalog/16.0/64/unicode/make_scripts to generate a configured /opt/mdyalog/16.0/64/unicode/mapl
$ /opt/mdyalog/16.0/64/unicode/make_scripts
$ /opt/mdyalog/16.0/64/unicode/mapl
Stream 0: /opt/mdyalog/16.0/64/unicode/aplkeys/default line : 1 file not ASCII / not terminated by newline. ""
hm
@betseg What OS (and distro if relevant) are you on?
Linux, Arch
12:31
@betseg Hang on. Jay should be with you shortly.
@betseg (This is Jay typing as Adam) did you manually unpack the .deb or .rpm package? Have you seen the post-install script that normally gets run after a proper automated install?
Yes, I manually extracted .rpm fiel but I couldn't see any scripts there?
12:55
@betseg Did you use rpm2cpio? If so, I think the problem is that it doesn't preserve hard links. aplkeys/default and apltrans/default should each be a link to the "xterm" file in the same directory.
OK, I used a script called debtap that turns .deb files into Arch Linux package files and I was struggling with the post-install script because debtap removed an if block but forgot to remove the fi, but after fixing the script dyalog is installed.
Now I have to do the same for Ride :/
@betseg OK, but I think the hard links are a separate problem. Running post-install scripts will not fix them.
13:25
i.sstatic.net/qEBql.png @JayFoad CLI interpreter works but Ride still says it can't find it, is there more to the packages then hard links because rpm2cpio didn't output anything more than what I could do without it.
@betseg Yay! Now can you get RIDE running too?
@Adám see edit
(i'll be back in 10 min)
i.sstatic.net/jgkLk.png ride has this instead of what i used in the screen shot but this works too
@betseg Does the drop-down box just above that say "v16.0, 64-bit, Unicode" ?
@betseg If you hit F12 in RIDE after it has failed to start the interpreter, you can get a Javascript console. Are there any useful error messages there?
@betseg Does your mapl script definitely have executable permissions?
13:51
@JayFoad yes for 1 & 3
console has an error: "spawn /opt/mdyalog/16.0/64/unicode/mapl ENOENT"
... oh ...
@JayFoad i'm so sorry
previously i typed ~ for working directory
when i typed /home/username it worked
There are more hard links you may be missing. See the entries I've marked with ####:

/opt/mdyalog/16.0/64/unicode$ ls -li aplkeys/ apltrans/ fonts/
aplkeys/:
total 40
3408428 -rw-r--r-- 2 root root 7774 Feb 1 03:00 default ####
3408427 -rw-r--r-- 2 root root 575 Feb 1 03:00 file ####
3408374 -rw-r--r-- 1 root root 6731 Feb 1 03:00 file_siso
3408427 -rw-r--r-- 2 root root 575 Feb 1 03:00 utf8 ####
3408424 -rw-r--r-- 1 root root 8173 Feb 1 03:00 utf8codes
3408428 -rw-r--r-- 2 root root 7774 Feb 1 03:00 xterm ####
@betseg Ah! Interesting. I'm not sure why ~ wouldn't work. It would certainly be nice if it gave you a useful error message.
@betseg (You can also leave the working directory box blank if you don't care)
huh, at first when it said interpreter couldn't be found i wanted to leave no variables and filled everything
14:08
@betseg I've raised a RIDE issue:github.com/Dyalog/ride/issues/321
thanks!
@JayFoad BTW, I have Ride 4.0 and there is no installing option for 4.1 in my.dyalog.com
 
1 hour later…
15:33
@Adám ExternalEvaluate['Python', 'from pynapl import APL']
@Pavel What's that?
Ven
Ven
@Adám Mathematica?
I'm guessing from the brackets.
@Adám Hacky mathematica/apl interop using pynapl and mathematica's built-in python evaluator.
@Pavel Ha! That's pretty cool though. So you're using Python as an interop layer. Does it work?
@Adám Don't know yet, I'm still in the process of installing pynapl.
15:41
@Pavel Let me know.
$ wolfram
Wolfram Language 11.2.0 Engine for Linux x86 (64-bit)
Copyright 1988-2017 Wolfram Research, Inc.

In[1]:= ExternalEvaluate["Python", "from pynapl import APL; APL.APL().eval('2+2')"]

Out[1]= 4
@Adám It totally does.
@Pavel Amazing. I'm going to tell my colleagues right now!
@Pavel Can Python call Mathematica too?
@Adám Through an old and poorly documented library called PYML: library.wolfram.com/infocenter/MathSource/585
Also this indirect workaround: stackoverflow.com/a/10287297/3553138
@Adám The great thing about both pynapl and ExternalEvaluate is that the result of the expression is actually the number 4, not the string "4".
@Pavel Right.
@Pavel Have you tried with array results? Try e.g. ⍳9 and ∘.×⍳3 and ,\⍳9 and ⍳3 3
@Adám The second one fails (ERROR: Function requires a left argument), but the rest work as expected.
15:56
@Pavel My mistake, it should be ∘.×⍨⍳3. Can you show me the transcript?
ExternalEvaluate["Python", "from pynapl import APL; APL.APL().eval(',\
\\⍳9')"]
{1, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5,
  6}, {1, 2, 3, 4, 5, 6, 7}, {1, 2, 3, 4, 5, 6, 7, 8}, {1, 2, 3, 4, 5,
   6, 7, 8, 9}}
@Pavel I'd be interested in what happens to the high-rank result of ∘.×⍨⍳3 and the high-rank, deep depth result of ⍳3 3.
⍳3 3
{{{1, 1}, {1, 2}, {1, 3}}, {{2, 1}, {2, 2}, {2, 3}}, {{3, 1}, {3,
   2}, {3, 3}}}
∘.×⍨⍳3
{{1, 2, 3}, {2, 4, 6}, {3, 6, 9}}
dyalogEval[x_] :=
 ExternalEvaluate["Python",
  "from pynapl import APL; APL.APL().eval(u'''" <>

   StringReplace[x, {"'" -> "\\'", "\\" -> "\\\\"}]
   <> "''')"]
Mathematica function to evaluate an APL expression
@Pavel OK, thanks. So it converts all rank to depth. Can I bother you to try 2 0⍴0 and 0 2⍴0 and 0 0⍴0?
@Pavel Neat. Maybe that should be added to the Py'n'APL repo as an example of the possibilities this gives.
Yes, but before that: ExternalEvaluate["Python", "from pynapl import APL; APL.APL().eval('''⎕sh 'python -c \"print(2+2)\"' ''')"] ==> {4}
@Adám {{}, {}}, {}, and {}, respectively.
@Adám I'm also intrested in how namespaces would be evaluated, what's some APL I can test? I don't really know namespaces yet.
I've just tested, you can't evaluate an APL function and get back a Mathematica function. This is a limitation of pynapl. Although really, that would be borderline wizardry if it worked.
16:17
@Pavel Try ns⊣(ns←⎕NS⍬).(a b c)←'Hello' 3.14 (1 2 3)
@Adám Yes, we get back an association list: <|"a" -> "Hello", "b" -> 3.14, "c" -> {1, 2, 3}|>
@Pavel Right, but I suspect it would be fairly trivial to write an add-on to Py'n'APL which allows it.
ExternalEvaluate doesn't allow importing python functions either, so it would still be pretty tricky.
Ven
Ven
@Adám Uh? That'd sound incredible.
@Pavel Neato. Namespace with a function: (ns←⎕NS⍬).sum←+/ ⋄ ns
Ven
Ven
16:21
ExternalEvaluate, as I understand it, just runs an interpreter, without any shared bindings
@Pavel Oh, I thought it did, based on your message, no, then it won't work, of course.
@Adám Nope. Empty association.
@Pavel At least it didn't fall over.
Python gets back an empty dictionary from pynapl, then sends the empty dictionary to Mathematica.
@Adám Going the other way (call mathematica from Dyalog) would be much harder. There isn't anything that exists to call Mathematica from any language and get back an actual object in that language. However, Mathematica provdes a means to export functions as a dll. I don't know how loading this dll from C would go.
@Pavel Oh, it is really easy to call functions in a dll from within Dyalog APL.
16:33
@Adám I just don't know if you'll get back something useful or some garbage data Dyalog can't interpret.
16:49
@Pavel Association lists will probably not work, but I don't see why simple (non-nested) arrays shouldn't arrive in a sane format. E.g. Math calls Fortran90 functions to compute Eigenvalues.
@Adám Because even compiled functions can return Mathematica symbolic values (e.g. Pi) rather than floats that Dyalog can make sense of. It could work sometimes, but not consistently enough to be useful.
@Pavel Couldn't you compose each function that you want to export with something that causes it to return approximate float results?
17:07
@Adám I suppose, with N@whatever. Hmm
@Pavel Have fun!
17:39
@Adám Got the week off next week or just busier than usual?
@J.Sallé We have our yearly off-campus all-hands-on planning meeting Wednesday–Thursday. I did conduct the lesson during my vacation:
Nov 22 '17 at 20:06, by Adám
@J.Sallé You're very welcome. My pleasure. In fact, I'm on vacation this week, but didn't want to miss the lesson. You guys are great1
@Adám ooooh, I see.
Yeah I remember the vacation lesson, I was wondering if it was a holiday or something hahahah
17:55
@Adám uh, why not feb 6
(you need to change the schedule btw if that's the case?)
18:40
@Adám How do I write to a file?
I need to know both overwrite and append mode
My current implementation is through ⎕sh calls, which is suboptimal, obviously.
@Pavel dyalog.com/uploads/documents/MasteringDyalogAPL.pdf search for topic 6.6, I believe it's what you need
Honestly, ⎕sh is how I do most impure things in Dyalog.
@J.Sallé Thanks!
19:17
Yeah, still can't get file IO to work
I keep getting VALUE ERROR
      'foo' PutText '/home/pavel/foo.txt'
VALUE ERROR
      'foo'PutText'/home/pavel/foo.txt'
     ∧
1 message moved to trash
@EriktheOutgolfer Thank you for correcting this:
Next lesson is Tuesday, Feb 6 at 18:30 UTC.
@J.Sallé Oops should be ^
How do I put a newline in a string literal?
@Pavel Unicode or raw?
@Adám A normal line break
@Pavel That question was on the file writing question.
19:26
@Adám Oh, unicode
@Pavel 'first line',(⎕UCS 10),'second line' Yes, it is verbose, but at least there are no characters that need escaping etc. When I need it multiple times, I define nl←⎕UCS 10 and then 'first line',nl,'second line',nl,'third line'
@Pavel To write a Unicode file is just (⊂content)⎕NPUT 'filename' or (⊂content)⎕NPUT 'filename' 1 if you want to overwrite rather than throw an error on clash with existing file.
@Pavel To append you either need to use the methods @J.Sallé linked to, or do additional_content ((⊂,∘⊃∘⎕NGET)⎕NPUT 1,⍨⊢) filename'`
@Adám Ok, I think I should just accept I don't know enough APL to create a function to evaluate wolfram code. Do you have time to help out with that?
@Pavel I would love to. However, know that I just arrived home from work so my responses may be delayed. My wife leaves for work tomorrow at 8:15 UTC so at least then I'll have time… What have you got?
# Wolfram code to evaluate is stored in $CODE

echo 'Needs["CCodeGenerator`"]' > /tmp/INTEROP.wls
echo -n 'LibraryGenerate[Compile[{}, (' >> /tmp/INTEROP.wls # `echo -n` just means no newline
echo -n $CODE >> /tmp/INTEROP.wls
echo ')], "export"]' >> /tmp/INTEROP.wls
wolframscript /tmp/INTEROP.wls > /dev/null

# Creates file called "~/.Mathematica/SystemFiles/LibraryResources/Linux-x86-64/export.so" on Linux
# This is a shared object (dll) containing the function `export`
# Called with no arguments, this function gives the result of evaluated code
This shell snippet produces a dll (or rather an so on my Linux machine)
On Mac it produces the same file but export.dylib instead of export.so. I'm not sure where it goes on Windows
19:49
@Pavel That's all fine, as you can see on the ⎕NA that it should be a .so on Linux, a .dylib on macOS and it will be a .dll on Windows.
@Pavel So APL just needs to call the function export after storing the code to evaluate in an environment variable?
@Adám Well, yeah, to use that particular script
The script doesn't do anything hard so it could be written in APL entirely
I just don't know how
@Pavel A bit odd. I would have export take an 8-bit or 16-bit string, but whatever.
The function for import the result could have its argument all as string (and Mathematica does conversion) the same the result as string (and Mathematica does conversions)
@Adám The function export isn't doing the exporting, it's the exported function. If you call the above script with $CODE='2+2', export would be roughly equal to return 4;. It doesn't take anything as a parameter.
@Pavel No problem. However, export will be statically typed (no?) so we need to know what data type comes back.
19:56
@Adám Remember my original concern that the data wouldn't be comprehensible to Dyalog? You can take a look at the generated C for a function called interopfun and the expression 2+2:
#include "math.h"

#include "WolframRTL.h"

static WolframCompileLibrary_Functions funStructCompile;

static mint I0_0;

static mbool initialize = 1;

#include "interopfun.h"

DLLEXPORT int Initialize_interopfun(WolframLibraryData libData)
{
if( initialize)
{
funStructCompile = libData->compileLibraryFunctions;
I0_0 = (mint) 4;
initialize = 0;
}
return 0;
}

DLLEXPORT void Uninitialize_interopfun(WolframLibraryData libData)
{
if( !initialize)
{
initialize = 1;
}
}

DLLEXPORT int interopfun(WolframLibraryData libData, mint *Res)
@Pavel Btw, you can get an environment variable with ⊢2⎕NQ#'GetEnvironment' 'ENVVARNAME', the rest is just string concatenation and a single ⎕NPUT.
@Adám It doesn't have to be an environment variable. That was just an example for taking input.
Anyway, as you can see, the function interopfun returns 0, always.
The return value is not what Mathematica gets from the dll, and there's not a good way to get the result without mathematica.
@Pavel While I know almost nothing of C, it does look like we need to capture that I0_0 somehow, but if the function doesn't return it, it seems a bit hopeless.
@Pavel Never mind.
@Pavel Wait, doesn't all this mean that export.so will have a function called interopfun which returns that mint *Res which is the result we want?
@Adám All of these return 0
The result is stored in whatever *Res points to. Mathematica knows what Res is pointing to, but Dyalog doesn't.
Code export functionality in Mathematica is not at all there for the purpose of allowing you to use Mathematica constructs in other languages. They're there just to increase performance of mathematica libraries, since compilation is faster than interpretation.
I actually think it's intentionally designed like this, and nothing can be done since Mathematica is proprietary software.
@Pavel Ninja'd. I was about to say it looks like Mr. Wolfram doesn't want other languages to call Mathematica. At least Dyalog isn't like that.
20:07
The only way I can imagine this working is to produce C, then modify that C to return Res. This will let Dyalog to look at the blob of binary data that represents the return value. From there, it would have to be parsed - it's not just a number, it's a list that first contains the type, than other metadata, and then the number. For complex types like arrays it would be near impossible.
@Pavel And I would bet that it breaks the Wolfram licence to do so.
@Adám Undoubtedly. Reverse Engineering is the very second clause of things-you-cant-do, after distributing copies to others.
@Pavel And I thought Dyalog's licensing was bad…
@Pavel Maybe you should instead make a bridge to some other language than Mathematica?
no license is strong enough to defend from all pirates :-D
@Adám It would still have to go through that other lang's python interop library f it has one and then pynapl. I'm not good enough to marshal, say, Ruby objects to APL objects without builtins.
20:25
@Pavel But Isn't there a Ruby-Python/Python-Ruby library? I don't see it on this list.
@Adám Probably. What I'm saying is, I'd have to use that, and then pynapl.
I couldn't write a ruby-apl lib from scratch
@Pavel Question is if there is anything to be gained for an APLer to be able to call those languages… Python has a lot of useful libraries, and R has a lot of statistical tools, but we already have good bridges to those two. C/C++ (and other languages which can compile to so/dylib/dll) are easy to use. What other bridges would actually be useful? Though of course everyone (except for J) may benefit from the ability to call APL.
@Adám Mathematica would be useful but that doesn't work ;-;
Maybe MATLAB/Octave, but I don't know those
@Pavel Me neither (duh, I only know APL), but again, I doubt there is much for the APLer to gain there, and MATLAB/Octave users may as well just switch to APL if they desire APL…
@Adám I meant the other way. MATLAB and Octave have a lot of math libraries that could be useful in APL.
20:40
@Pavel Maybe. I can mention it…
20:51
I'm glad that at least Mathematica -> pynapl works
Yeah, our CTO said:
Great. I wonder what we'd need to do to get this working:

In[1]:= ExternalEvaluate["APL", "+/1 2 3"]

Out[1]= 6
@Pavel … so I sent him your dyalogEval.
@Adám An email to Wolfram, Inc. ExternalEvaluate only supports parameters "Python" and "NodeJS" currently.
@Pavel I told him that it only supports those. I'd think they would prioritise other (more popular) languages than APL if they decided to add more.
ExternalEvaluate["APL", expression_] := dyalogEval[expression] should work, but Mathematica is mean and makes builtin symbols read only.
 
1 hour later…
22:15
@wizzwizz4 Welcome to the Orchard!
Hello! Just popping in to bookmark the room for when I'm untired enough to learn new languages. :-)
@wizzwizz4 May I recommend bookmarking the past lessons?
@Adám Wow, thanks. That's a lot more useful than scrolling through the whole transcript! :-)
@wizzwizz4 You're very welcome. Yeah, I think especially the first 10 lessons turned out really well. I'm thinking of editing them into a booklet "APL a day – APL in 24 hours for the impatient programmer"
@Adám All messages are CC-BY SA 3.0, so sounds like a good plan!
22:24
@wizzwizz4 Thanks for letting me know.
Of course, you can license your messages under whatever you want.
22:38
@Adám sorry, but you can't actually do that without including intermediate messages too :(
@EriktheOutgolfer Meaning messages between the lessons?
@Adám yes
@Adám hasn't ever happened to me, but who knows :)
@EriktheOutgolfer Why? May I not quote two messages from SE chat without quoting what's between them? Anyway, I didn't intend to include anything verbatim, just follow the order and looking at questions that were asked to know what to include.
@EriktheOutgolfer Happens to me a lot that I end up editing my previous message rather than responding with a new message.
@Adám learning APL in 24 hours might have a very severe impact for the sanity of the subject. let alone their understanding of it
@Uriel Well, the idea is that the material can be gone through in 24 hours, not that they must do so in 24 consecutive hours.
@EriktheOutgolfer Possibly because of a userscript which allows me to press UpArrow to edit messages.
22:44
also, I do not recommend staying awake 24 hours doing nothing but reading. you'd probably end up dehydrated, hungry and tired
@Uriel (Off topic: Yom Kippur‽)
@Adám nah, there's difference between not eating when possible and when not
@EriktheOutgolfer Do you have a source for that?
@EriktheOutgolfer even better, "learn PL-A through a Q&A"
@Uriel PL-A? Anyway, I'm not intending it to be in a Q&A format, just follow the general style and order of the lessons.
22:55
@Adám APL, I figured rotation would be the quickest rhyming solution
@Adám I still haven't gotten the keyboard layout down all the way, I think all of APL in 24 hours is a bit pushing it
⍞←12⌷⍉¯11 4 0⌽3⌿⍉⍪⎕A
@Adám APL
@Pavel When I was 12, my father made a bet with another APLer that my father could teach me the entire layout in an hour and a half. My father won.
@Pavel While I learned it in Danish, this English version is based on what I learned:
user image
2
⍞←⎕A[⎕PP×.5 8 6×0.2]
23:04
@Uriel APL
@Adám That sounds like an unfair bet, given you claim you've been exposed to APL since the age of 1 :P
@Pavel I didn't know the keyboard though. Until then I used to copy and paste a lot.
The top bar's gone again
@Zacharý Much cleaner design that way. /s I'll tell them.

« first day (372 days earlier)      last day (2579 days later) »