Racket

Deriving Recursion from First Principles

2 Oct 2023
Computer-Science, Programming-Languages, Racket

Or: Approaching the Y Combinator These are some of my class notes. Learning to derive the Y Combinator from first principles is something I’ve always wanted to do. This isn’t quite the Y Combinator, but it’s very close and it still gets you recursion without relying on recursive structures to begin with. In the beginning, we write a recursive function to compute the length of a list: (let* ([len (λ (lst) (if (null? ...

Writing Racket Macros: define-syntax and phases

19 May 2023
Tutorials
Computer-Science, Macros, Racket

There are a bunch of different ways of writing a macro in Racket. There are also some tricky things around phases to keep in mind. This is to help me keep them all straight. 3+1 ways to make a macro # This form: (define-syntax-rule (foo args ...) (use args ...)) is equivalent to: (define-syntax foo (syntax-rules () ([foo args ...] (use args ...)))) Which, is in turn equivalent to: (define-syntax foo (λ (stx) (syntax-case stx () [(gensymed-foo args . ...

microKanren Reading

4 Jul 2022
Tutorials, Featured
Programming-Languages, Racket

μKanren (“micro-Kanren”) is a tiny, embeddable logic programming language. It’s easy to understand and implement in almost any language. It’s a great case study of an embedded language: unlike other common “embedded” languages like SQL or regex, which normally are represented as just plain-old strings, μKanren takes more advantage of the host language’s features. I recommend reading the original paper: it’s short, well-written, and easy to understand. I did a write-up which you can read on Sourcehut. ...

A programmable programming language? I'll drink to that!

21 Aug 2021
Personal, Fun, Racket

My wife and I got a chance to go to a place that lets you paint pottery and then have it fired. The pottery is all pre-made; you just get to paint it. It’s been a very long time since I’ve worked with a physical art medium, so the mug looks kinda dumpy. I did alright with the Racket logo on the bottom-inside of the mug though! I’m working on some fun projects with Racket. ...

Mastodon