Clojure Examples

ClojureOct 23, 2026

plain-text-table-renderer

Renders maps as an aligned plain-text table with padded columns, a header row and a dashed separator.

formattingtableterminal
000
ClojureOct 23, 2026

field-validation-error-map

Validates a map against per-field predicate and message pairs, returning every field error at once.

mapserrorsvalidation
000
ClojureOct 23, 2026

base64-encode-decode-utf8

Encodes strings or byte arrays as Base64 and decodes them back, wrapping malformed input in ex-info.

encodingstringsbase64
000
ClojureOct 23, 2026

url-query-string-round-trip

Encodes maps into URL query strings and parses them back into decoded maps of key to value vectors.

query-stringurlencoding
000
ClojureOct 23, 2026

json-read-with-error-context

Parses JSON text into EDN and rethrows read failures with the error message and a nearby input snippet.

parsingerrorsjson
000
ClojureOct 23, 2026

bounded-worker-pool-pmap

Runs a function over a collection on a fixed thread pool, preserving input order and surfacing task exceptions.

concurrencyworker-poolthreads
000
ClojureOct 23, 2026

http-json-get-with-timeout

Performs an HTTP GET with a millisecond timeout and decodes the JSON body through a small JSON-to-EDN pass.

timeoutshttpjson
000
ClojureOct 23, 2026

env-config-with-validation

Reads environment variables with defaults and validators, throwing ex-info that names the offending variable.

environmentconfigvalidation
000
ClojureOct 23, 2026

token-bucket-rate-limiter-clj

A stateful token bucket that allows short bursts up to capacity while enforcing a steady refill rate.

concurrencyrate-limitingatoms
000
ClojureOct 23, 2026

atom-backed-lru-cache

A compact atom-backed LRU cache that evicts the least recently used key once it grows past its capacity.

lrucacheatoms
000
ClojureOct 23, 2026

multi-key-stable-sort-with-nils

Stable multi-key sort over maps with per-key direction, keeping nil values predictable at either end.

sortingcollectionscomparator
000
ClojureOct 23, 2026

chunked-lazy-sequence-batches

Splits any collection into fixed-size vectors eagerly, plus a lazy variant that also handles infinite sequences.

batchinglazysequences
000
ClojureOct 23, 2026

stream-file-lines-with-closing

Streams a UTF-8 file line by line with a reader that always closes, counting or transforming each line.

lazyiofiles
000
ClojureOct 23, 2026

deep-clone-and-recursive-merge

Recursively deep-copies nested maps, vectors, sets and seqs, then merges two maps without mutating either.

mergedata-structuresclone
000
ClojureOct 23, 2026

with-retry-exponential-backoff

Retries a thunk with capped exponential backoff and random jitter, rethrowing the final exception.

resiliencebackoffretry
000