llamascii art

That unusual llama symbol

I first mentioned llama in The art of replacing long lambdas I. It's a library for shortening lambdas in Emacs Lisp:

(lambda (str) (upcase (reverse str)))  ; regular lambda
(##upcase (reverse %))                 ; llama

Some things, however, I haven't mentioned.

First, that these three are equivalent:

(llama + %1 %2) => (lambda (%1 %2) (+ %1 %2))  ;| Emacs 30:
(## + %1 %2)    => (lambda (%1 %2) (+ %1 %2))  ;| #[(%1 %2) ((+ %1 %2)) nil]
(##+ %1 %2)     => (lambda (%1 %2) (+ %1 %2))  ;|

Second, that the symbol '## corresponds to the empty string:

(symbol-name '##) => ""
(intern "")       => '##

Third, that '## seems to be the only symbol in Emacs Lisp that, when used as a function (as above), would parse correctly even when there's no space after it. This property is one reason why the symbol was chosen in the first place. It's also short and distinct, and looks like actual syntax.

You may wonder whether there's anything else this unusual property could be applied to.

A strange idea

So as I was brushing my teeth on a Thursday night, I was struck by a strange idea:

Does that mean that I can—

(##+     %1 %2) => (lambda (%1 %2) (+ %1 %2))
(####+   %1 %2) => (lambda nil #'(lambda (%1 %2) (+ %1 %2)))                 ; !!!!
(######+ %1 %2) => (lambda nil #'(lambda nil #'(lambda (%1 %2) (+ %1 %2))))  ; !!!!!!

Yes, I can.

I can nest as many llamas as I want — spaces not required.

As I return to my unbrushed molars, I wonder why on Earth I'd want to do that anyway. I mean, those lambdas seem useless. Where would you use a nested lambda like that? It receives no arguments. All it can do is return the next inner lambda, which also receives no arguments and can only return the next inner lambda, which... hmmmm...

Matryoshka llama

What if we nested a bunch of llamas just to, you know, unnest them again?

(-> (################+ %1 %2)
    funcall  funcall  funcall
    funcall  funcall  funcall
    funcall (funcall   17 25))
=> 42

Now, isn't that a peculiar evaluation?
It feels so... meaningful... somehow...

Is that because—

Hey, Emacs! Question: what is the answer to, like, you know, everything?

?* => 42

I see. That explains it.

Art for the revelation of meaning sounds good, so let's dial that up.

(-> (######################+ % %2)
    funcall  funcall  funcall
    funcall  funcall  funcall
    funcall  funcall  funcall
    funcall (funcall   17 25))
=> 42

More llamas, more funcalls — I have a nagging feeling this might get out of hand soon. Let's -iterate:

(--> (######################+ % %2)
     (-iterate #'funcall it 11)
     last  car  (funcall it 17 25))
=> 42

Oh my, that's now up to eleven!

But why stop there?

(--> (############################
      ############################
      ############################+ % %2)
     (-iterate #'funcall it 42)
     last  car  (funcall it 17 25))
=> 42

We can play with spaces, so let's reshape it.

(--> (## ############
      ## ############
      ## ############
      ## ############
      ## ############
      ## ############  + %1 %2)
     (-iterate #'funcall it 42)
     last  car  (funcall it 17 25))
=> 42

Looks like a cozy place for a llama to rest inside, doesn't it?

(--> (## ######## ##
      ##   llama  ##
      ## ######## ##
      ## ######## ##
      ## ######## ##
      +  % 2 2 2 2 7)
     (-iterate #'funcall it 27)
     last  car  (funcall it 27))
=> 42

But why stop there?

llamascii art

(--> (##      ##        ##    ##   ##     ##        ######  ##
      ##      ##       ####   ##   ##    ####       ##      ##
      ##      ##       ####   ########   ####       ######  ##
      ##      ##      ##  ##  ## ## ##  ##  ##      ##      ##
      ##      ##      ######  ## ## ##  ######      ##      ##
      ######  ######  ##  ##  ##    ##  ##  ##  ##  ######  ######
      -> % (+ 7) (/ 2))
     (-iterate #'funcall it 77)
     last  car  (funcall it 77))
=> 42

I tried to draw an actual llama, and... it looked like a cross between a stiff-necked giraffe and a pony. I'll spare you.

Let's try some Emacs:

(--> (########  ##      ##  ########  ########  ########  ##
      ##        ####  ####  ##    ##  ##        ##        ##
      ########  ##  ##  ##  ########  ##        ########  ##
      ##        ##      ##  ##    ##  ##              ##
      ########  ##      ##  ##    ##  ########  ########  ##
      - %1 %2)
     (-iterate #'funcall it 70)
     last  car  (funcall it 70 28))
=> 42

Small? Ok, let's embiggen it:

(--> (##########  ##        ##  ##########  ##########  ##########  ##
      ##          ####    ####  ##      ##  ##          ##          ##
      ##          ##  ####  ##  ##      ##  ##          ##          ##
      ##########  ##  ####  ##  ##########  ##          ##########  ##
      ##          ##   ##   ##  ##      ##  ##                  ##  ##
      ##          ##        ##  ##      ##  ##                  ##
      ##########  ##        ##  ##      ##  ##########  ##########  ##
      --> % sqrt
      (format "#b%d%d%d" it it it) read)
     (-iterate #'funcall it 100)
     last  car  (funcall it 100))
=> 42

Which is my favorite.

Drawing a huge ASCII llama next to a huge ASCII GNU Emacs logo is left as an exercise for the reader.

Any llamascii artists out there? Show us your talents.

📆 2025-08-24