A conditionally transforming combinator

?-> is a combinator that takes a predicate test and a transformer, and returns a unary procedure that transforms its argument if the predicate applies.

That’s a mouthful. Let’s break it down with some examples:

You can make a car that only cars if the list is not null:

Or a reverse that only reverses if it receives a list:

The default when the predicate doesn’t apply is to just pass through the argument, but you can set a different default with a keyword argument:

As for the name, I know I said no new ASCII art names, but ? for predicates and -> for transformation are both grandfathered in.

?-> is available in brev-separate from version 1.52.

Naming philosophy (for Lisp stuff)