Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlos
sebastiancarlos / pretty-print-readtable.lisp
Last active April 24, 2025 00:55
Pretty-print a human-readable summary of a Common Lisp Readtable.
; All my gist code is licensed under the MIT license.
(defun safe-char-name (char)
"Return a printable representation of a character."
(cond ((graphic-char-p char) (format nil "'~C'" char))
(t (format nil "#\\~A" (char-name char)))))
(defun get-character-range ()
"Generates a list of characters ASCII characters."
(loop for code from 0 to 255
; All my gist code is licensed under the MIT license.
(defun count-quicklisp-dependencies ()
"Count the number of times each system is used as a dependency in Quicklisp."
(let ((system-list-names (sort (mapcar #'ql-dist::name (ql:system-list))
#'string<))
(file "/tmp/deps.csv"))
(with-open-file (out file
:direction :output
:if-exists :supersede
system uses used-by
alexandria 1048 '3b-bmfont' '3b-bmfont/common' '3b-bmfont/json' '3b-bmfont/tests' '3b-bmfont/text' '3b-bmfont/xml' '3b-hdr' '3b-swf' '3bgl-shader' '3bmd' '3bmd-ext-code-blocks' '3bmd-ext-definition-lists' '3bz' '40ants-ci' '40ants-doc-full' '40ants-doc-test' 'a-cl-logger' 'access' 'adp' 'adp-github' 'aether' 'agutil' 'alexa' 'alexandria+' 'alexandria/tests' 'amazon-ecs' 'amb' 'anatevka' 'ansi-test-harness' 'antik-base' 'aplesque' 'apply-argv' 'april' 'architecture.builder-protocol' 'architecture.builder-protocol.json' 'architecture.builder-protocol.json/test' 'architecture.builder-protocol.print-tree' 'architecture.builder-protocol.print-tree/test' 'architecture.builder-protocol.universal-builder' 'architecture.builder-protocol.universal-builder/test' 'architecture.builder-protocol.xpath' 'architecture.builder-protocol.xpath/test' 'architecture.builder-protocol/test' 'architecture.service-provider' 'architecture.service-provider-and-hooks/test' 'architecture.service-provider/test' 'array-o
@sebastiancarlos
sebastiancarlos / python-combinator-examples.lisp
Created March 19, 2025 05:40
Examples for the Python-Combinator (A multi-argument Z-Combinator for Common Lisp)
(let ((factorial (PY (lambda (self n)
(if (<= n 1)
1
(* n (funcall self (- n 1)))))))
(fibonacci (PY (lambda (self n)
(if (<= n 1)
n
(+ (funcall self (- n 1))
(funcall self (- n 2)))))))
(ayy-lmao (PY (lambda (self ayy lmao)
@sebastiancarlos
sebastiancarlos / python-combinator.lisp
Created March 19, 2025 04:42
The Python-Combinator (A multi-argument Z-Combinator for Common Lisp)
(defun PY (recursive-logic)
"The 'Python combinator'. A variation of the 'Z combinator' which takes
recursive lambdas with a 'self' recursive argument (hence 'python'),
and any number of arguments.
How does it work? I have no fucking idea. Ask God."
((lambda (x) (funcall x x))
(lambda (x) (lambda (&rest args)
(apply recursive-logic
(lambda (&rest inner-args)
(apply (funcall x x) inner-args))
@sebastiancarlos
sebastiancarlos / once-only-explanation.lisp
Last active March 8, 2025 16:11
Explanation of the ONCE-ONLY Common Lisp macro.
;; Deus Vult, Compilamus
;; The following code is compliant with the Holy See's ANSI Standard Of 2054.
:; Here's an example of a classic Lisp macro, ONCE-ONLY, which ensures
;; parameters to a Lisp macro are executed only once, along with a dense
;; explanation.
;; Example implementation of ONCE-ONLY
(defmacro do-primes ((var start end) &body body)
(once-only (start end)
@sebastiancarlos
sebastiancarlos / quasiquotation-on-lisp-bawden-apendix-a-algorithm.md
Last active March 1, 2025 04:52
Quasiquotation in Lisp (Bawden) - Appendix A Algorithm. (Plaintext OCR from PDF)

"Quasiquotation in Lisp" (Bawden) - Appendix A

This appendix contains a correct S-expression quasiquotation expansion

@sebastiancarlos
sebastiancarlos / girls_and_boys.pro
Last active January 8, 2025 03:40
Blur's "Girls and Boys" lyrics generator in Prolog
#!/usr/bin/env swipl --quiet
% All my gist code is licensed under the MIT license.
:- use_module(library(clpfd)).
% ORIGINAL LYRICS:
% Looking for
% Girls who want boys
% Who like boys to be girls
@sebastiancarlos
sebastiancarlos / gutenberg-dl.bash
Created March 28, 2024 19:56
gutenberg-dl - download text books from Project Gutenberg
#! /usr/bin/env bash
# All my gist code is licensed under the MIT license.
# gutenberg-dl <search-term>
# - Download books from Project Gutenberg in plain text format
# - Actually uses "gutendex" to search for the download link. It seems to be
# the current best third-party Gutemberg API
# - Source: https://github.com/garethbjohnson/gutendex
@sebastiancarlos
sebastiancarlos / bkp.bash
Last active March 9, 2024 14:38
bkp - toggle ".bkp" extension
#! /usr/bin/env bash
# All my gist code is licensed under the MIT license.
# Add this somewhere in your .bashrc
# bkp
# - toggle a ".bkp" extension to a file(s)
function bkp () {
# print usage on -h/--help or no arguments