Skip to content

Instantly share code, notes, and snippets.

@ntoronto
ntoronto / inline-merge-sort.rkt
Created August 24, 2012 22:38
A macro that expands to a fully inlined merge sort
#lang racket
(require (for-syntax racket/list)) ; for list functions
(define-syntax (inline-sort stx)
(syntax-case stx ()
[(_ lst ...)
(with-syntax ([(vs ...) (generate-temporaries #'(lst ...))])
#`(let ([vs lst] ...)
#,(inline-sort/k #'(vs ...) (λ (vs) #`(values #,@vs)))))]))