The inverting power (pun intended) of β£ is much greater than you demonstrated. It can both do non-mathematical things and seemingly impossible things.
The following function takes a three-letter word, reverses it, puts a space between the first and second letters, then prepends the letters xyz:
fβ'xyz',1 0 1 1\β½
f 'ABC'
xyzC BA
If we apply the inverse function on 'xyzC BA' we should get back our 'ABC', right?
(fβ£Β―1)'xyzC BA'
ABC
It is seemingly impossible to solve 2x5+x4+5x3β2x2β6x=100, however:
fβ(2Γ*β5)+(*β4)+(5Γ*β3)+(Β―2Γ*β2)+(Β―6βΓ)
(fβ£Β―1)100
2
f 2
100
You were trying to use β¨ for removing the double mention of v in v/β¨β v. You can indeed do that, as you do want v as both left and right argument to /β¨. However, the right argument version of v much be preprocessed by β . βPre-process rightβ? Thatβs fβg:
x β 1 2 3
β The following three are equivalent and compute the array divided by its length
x Γ· (β΄ x)
x Γ·ββ΄ x
Γ·ββ΄β¨ x
β Now we can use the above to compute the mean of an array
mean β +/β(Γ·ββ΄β¨)
mean β +/β(Γ·ββ΄β¨)
mean β +/(Γ·ββ΄β¨) β atop: f g ββ fβg
mean β +/Γ·ββ΄β¨ β simplify: f ββ (f)
mean β +/Γ·β΄ β distributivity: (f g h)Y ββ (f Y)g(h Y)
Thanks. trains seem useful (but not obvious). It may be a good concept to cover in the course. Maybe youβve covered it already. Iβve only watched up to middle of the 10th session.
As much as I enjoy APL (and your way of teaching it, in particular), I find it more like a cute and powerful puzzle framework than a practical programming language. As you said in ArrayCast podcast, I wish it was available as a module in python and swift to be used the same way RegExp are used within the language.
Iβm fairly confident that in a few months Iβll have a hard time making sense of APL expressions that I have written.
Itβs a real shame that some of the best and most paradigm changing languages come across like so. Maybe itβs because the current emphasis seems to be on winning obfuscated code contests and code golf competitions and making expressions as terse is possible (which, naturally, would scare the bajeezas out of mere mortals) but I think in its heyday, APL was used by regular office workers to do regular work. I think maybe because in those days of submitting jobs to the mainframes, your other options were COBOL, BASIC, PL1 or other beasts.
I mean, itβs good that some people have the advanced mental capacities to understand the rarified mathematical nuances of each operation, but some of us yerts just want to get some run of the mill stuff accomplished (like reading data in, cleaning it, maybe doing some EDA β¦ ) etc. etc.
Maybe itβs the nature of the beast? The more powerful and magical the language is, the bigger the probability that the practitioners of this βmagical artβ will become separated from the masses. Iβve seen it in Lisp and Forth as well, but APL is a totally new experience because the language is literally executable Math! I honestly feel like I need to know proper math before I an even use it for regular stuff.
I listen to the arraycast and I understand Iβm not the intended audience, but most of the time, I can appreciate that this is great content, but at the same time, I also frequently find myself saying , βI have no frikking idea what these dudes are talking aboutβ
At this stage weβre focused on getting thru all the glpyhs, so no we havenβt done trains yet. I expect after weβve finished the glyphs weβll do a session or two on tacit/point-free programming, including glyphs.
No-one can remember things that they donβt practice retrieving. So yes, if you donβt keep working on it, youβll forget. Try using Anki with cards for all the glyphs you use, and for checking your understanding of some important combinations and concepts.
but some of us yerts just want to get some run of the mill stuff accomplished (like reading data in, cleaning it, maybe doing some EDA β¦ ) etc. etc.
Iβve gradually over time rewritten all my boring βworkβ stuff from Python to APL β an unholy bunch of utility scripts that typically gather data from a set of disparate sources (JSON-over-HTTP APIs mostly), massages, cleans, combines and otherwise aggregates it and spits out some report or other as json or csv. I built these as ]usercommands inside Dyalog, and to me it came as somewhat of a surprise both how nice it was to use APL this way, a million miles away from the cut and thrust of the code golferβs APL that we often see on display. The other realisation was that having created easy ways to get my data into Dyalog, Iβm much faster when it comes to cook up some combination that I hadnβt scripted for already. My codebase easily halved in size, even when writing APL in an expansive style.
I used to scoff at the tradfn-style of APL, but when youβre in βget stuffs doneβ mode, it can be super-helpful. APL (IMHO) is an excellent tool for doing boring data processing.
I totally agree, thereβs something to be said about empowering the masses with easily approachable computation! BTW, Iβm loving your current book, thanks for making it available to us all! maybe your next book could be βDo the boring stuff with APLβ
I am very interested in knowing more about your workflow.
for example, do you get the JSON using python (using http requests) and then somehow feed it to your APL code and then use feed the output back to python? Do you use pynapl for doing this?
Sure. So the first thing I had to wrap my head around was the concept of Dyalog user commands β at first glance, this (like many other APL things) seem utterly backwards. Normally, Iβd expect to interact with scripts I write in the unix shell, and enter switches or sub-commands as parameters. Doing this with APL in a reasonably portable way was until recently at best awkward or at worst hopeless.
Writing Dyalog user commands sort of inverts this pattern: you use Dyalog as the βshellβ and have it manage configuration and parameter passing, and simply write functions for the guts of your business logic. For this to be smooth, some of it works best as using the trad form, but this is mostly a wrapper.
@abrudz has a nice video on how to write your own user commands, and this is definitely the place to start if this sounds interesting. But basically, code you place in the directory ~/MyUCMDs becomes available inside Dyalog as user commands. Below is a snippet of some of mine. The List and Run functions basically does the command-line processing, and in this example Iβve left in one of my βbusiness logicβ functions, called defaults, which fetches a json document, does a bit of grouping and reformatting. The weird function dotcreds just grabs the relevant credentials from a file.
To use this, I simply type ]CLUSTERS.defaults into the Dyalog session.
As @rak1507 pointed out, I did write some stuff on how to do HTTP in Learn APL, and also a bit on json and friends. The HttpCommand http client lib is excellent.