APL study session 6

Discussion of the 6th study group can go here. Overview

[ <<< session 5 | session 7 >>> ]

This is a wiki post - feel free to edit to add links from the lesson or other useful info.


Study session resources

Study session links


Like the generative art from DALL-E. :heart_eyes:
“A cat professor teaching deep learning in a classroom high quality photorealistic”


I’m wondering what the curly brackets in the example pic of function composition signify?

{R} ← {X} f ⍤g Y

Why isn’t Y in curly brackets ? How would I read this expression’s intent in words?

{R} takes value of output of f applied to output of g applied to {X} and Y ?

Excellent study session! Some fun playing around with Dalle, some new useful glyphs, and some interesting philosophical questions. I wish I could attend live!

Metamathematics is a deep and fascinating subject. For those interested in learning more about the history of these ideas I recommend Logicomix by Doxiadis & Papadimitriou. It’s a biographical graphic novel centered around Bertrand Russell and his struggle with these topics. A one of a kind book.

Combinatorial logic is also a deep and fascinating subject. The foundations of computation were developed at the same time as a revolution was occurring in mathematics. For those interested in a hands on explaination of what this stuff is all about I highly recommend David Beazley’s workshop at PyCon 2019 Lambda Calculus from the Ground Up.

If you would rather read than watch, I adapted the talk into an Observable notebook you can play around with → The λ Calculus

Looking forward to the next session! APL study seems to lead to many interesting topics.


Hi all,

Thanks for the great sessions! About the golden ratio: 1 +∘÷⍣= 1

To enhance my understanding, I tried to make to it more clear how the APL code relates to Python. Posting it here, as I thought it might help someone else also. Note that the compose (∘) defined here in Python is not generic but crafted for this specific problem.


from math import isclose

# APL: ∘
def compose(f, g):
    def _inner(*args):
        return f(g(args[0], args[1]), args[1])

    return _inner

# APL: +
def add(x, y):
    return x + y

# APL: ÷
def divide(x, y):
    return x/y

# calculate_phi ← { ⍺ divide_then_add repeat_until_equal ⍵ }
def calculate_phi(a, b):
    # APL: divide_and_add ← +∘÷
    divide_then_add = compose(divide, add)

    # APL: repeat_until_equal ← ⍣=
    res = divide_then_add(a, b)
    prev_res = float('nan')

    while not isclose(res, prev_res, rel_tol=1e-06):
        prev_res = res
        res = divide_then_add(1, res)

    return res

# APL:
# divide_then_add ← +∘÷
# repeat_until_equal ← ⍣=
# a ← 1
# b ← 1
# ⎕ ← phi ← a calculate_phi b
a = 1
b = 1
phi = calculate_phi(a, b)


divide_then_add ← +∘÷
repeat_until_equal ← ⍣=
a ← 1
b ← 1
calculate_phi ← { ⍺ divide_then_add repeat_until_equal ⍵ }
⎕ ← phi ← a calculate_phi b

In the Python version, the functions divide_then_add and repeat_until_equal should be passed to the calculate_phi function as arguments to make it more equivalent to the APL version, but I thought it would make the code more difficult to understand and decided to omit.

Edit: Posted first accidentally to session 5 thread and moved it here.

Thanks for the great resources recommendations.

I have seen the book being recommended by Amazon, but after reading your comment, I finally bought it.


1 Like

For future reference:

Curly braces are ‘explained’ somewhat, here



An ambivalent function with an optional left argument, a conditional control structure, one local variable, and a shy result:

      ∇ {res}←{left} AddMult2 right;local
        :If 0=⎕NC'left'     ⍝ if variable "left" is not defined already
      AddMult2 3     ⍝ result is "shy"
      ⎕←AddMult2 3   ⍝ coerce display of result
      1 AddMult2 3      ⍝ result is "shy"
      10×1 AddMult2 3   ⍝ use result anyway

1 Like

That’s a tradfn, which is something we haven’t covered yet (and quite a few APL programmers avoid nowadays, so I’m not sure we’ll get to it in a hurry either).


Thank you! I was just trying to wrap my head around the curly braces and the situations where they’re used. I didn’t realize trad-itional functions weren’t used so much anymore. :sweat_smile:

I applied for DALL·E 18-April and got acces 18-June. Its been lots of fun.

A tip… the more detailed you are the better. Rather than provide a very general abstract requirement, try to picture a scene as you would describe it to a savant five-year old.

In the context of the course, I thought I would try for something related to machine learning. Sorry I got a bit carried away. (Perhaps there needs to be separate category, with guidelines limiting how often to post generated images (it could be popular).)

Ten detailed tiny copper brains on a printed circuit board connected by copper traces. The brains are very detailed. Photo realistic 3d render.

But I also need more practice to better understand how it will interpret…

Tiny copper brains on GPU chips connected by copper traces across a door in a wall. The brains are very detailed. The door has a lock. A monkey is looking at the lock putting a key into the lock. Photo realistic 3d render.

Photo realistic 3d tender of a gate made out of an array of GPU chips. The gate has a golden lock and border frame. A monkey is putting an ancient golden key into the lock.

A human teacher standing in front of a classroom of robot students. Line drawing viewed from the back of the room. The teacher is writing on the blackboard.

Looking from the back of the room at a classroom of seated robot students looking at a blackboard. The robot students vary in shiny colours. At the front of the room a human teacher wearing a suit is writing the alphabet on the blackboard. photorealistic 3d render.