Here's a merge sort I wrote trying to learn Scheme.
(define mergesort
(lambda (l cmp)
(define merge
(lambda (left right)
(cond
((null? left) right)
((null? right) left)
((cmp (car left) (car right)) (cons (car left) (merge (cdr left) right)))
(else (merge right left)))))
(define split
(lambda (l)
(define splitr
(lambda (l left right)
(if (null? l)
(list left right)
(splitr (cdr l) right (cons (car l) left)))))
(splitr l '() '())))
(cond
((null? l) l)
((null? (cdr l)) l)
(else (let* ((parts (split l))
(left (car parts))
(right (cadr parts)))
(merge (mergesort left cmp)
(mergesort right cmp)))))))
I know there's already a merge sort question on code review. Frankly, that approach has some nuances I'm not sure I'm prepared to understand yet. So here's my much more naïve approach.
So, keeping in mind I'm pretty much still an FP newbie (so if I don't understand your critique, I'll ask followup questions) and I may have missed some opportunities to do things "the scheme way", how did I do?