allioli

2024-10-12

Alliolification

Upstream URL

Author

Héctor Galbis Sanchis

License

MIT
README

Allioli

Allioli logo

Welcome to Allioli!!

This is a tiny project that creates the named readtable allioli:syntax with the only dispatch character macro #¿.

The purpose of Allioli is make easier the creation of short lambdas.

Installation

  • Manual:
cd ~/common-lisp
git clone https://github.com/Hectarea1996/allioli.git
  • Quicklisp (Ultralisp):
(ql-dist:install-dist "http://dist.ultralisp.org/" :prompt nil)
(ql:quickload "allioli")

Quick start

After loading the system allioli, enable the named readtable allioli:syntax:

(named-readtables:in-readtable allioli:syntax)
#<:named-readtable allioli:syntax {100522D013}>

And start creating short lambdas on the fly.

We create a lambda with one argument:

(mapcar #¿(cons ? 2) '(1 2 3 4))
((1 . 2) (2 . 2) (3 . 2) (4 . 2))

Or two different arguments:

(mapcar #¿(list ? "Hello" ? "there!") '(1 2 3 4) '(5 6 7 8))
((1 "Hello" 5 "there!") (2 "Hello" 6 "there!") (3 "Hello" 7 "there!")
 (4 "Hello" 8 "there!"))

Or one argument placed in two different places:

(mapcar #¿(list ?arg "Ahoy!" ?arg) '(1 2 3 4))
((1 "Ahoy!" 1) (2 "Ahoy!" 2) (3 "Ahoy!" 3) (4 "Ahoy!" 4))

Or we can get crazy!

(mapcar #¿(list ?num ? ?num ?char "A lot of arguments!" ?num ?char ?)
        '(1 2 3) '(a b c) '(#\x #\y #\z) '("AA" "BB" "CC"))
((1 a 1 #\x "A lot of arguments!" 1 #\x "AA")
 (2 b 2 #\y "A lot of arguments!" 2 #\y "BB")
 (3 c 3 #\z "A lot of arguments!" 3 #\z "CC"))

Description

After #¿ is written, each symbol whose name starts with the character ? can create a new argument for the lambda. If the exact name of the symbol is "?", then a new argument is created. If its name is longer a new argument is created only if a symbol with that name didn't appear before.

;;            1   2       3        4   2          3               5               3
'#¿(some-form ? ?arg ?another-arg (? ?arg) (?another-arg (?yet-another-arg) ?another-arg))
(lambda (?681 ?arg ?another-arg ?682 ?yet-another-arg)
  (some-form ?681 ?arg ?another-arg (?682 ?arg)
   (?another-arg (?yet-another-arg) ?another-arg)))

Dependencies (2)

  • fare-quasiquote
  • named-readtables

Dependents (0)

    • GitHub
    • Quicklisp