Skip to content

Instantly share code, notes, and snippets.

@AKST
Last active December 23, 2015 19:29
Show Gist options
  • Save AKST/6682963 to your computer and use it in GitHub Desktop.
Save AKST/6682963 to your computer and use it in GitHub Desktop.
Just a simple implementation of the max function in scheme.
;; original function from a while back
(define (max . lst)
(let (
(x (car lst))
(xs (cdr lst)))
(if (null? xs)
x
(let ((xs_max (apply max xs)))
(if (> x xs_max)
x
xs_max)))))
;; update after enlightenment
(define (max . args)
(define (fn acc e)
(if (> acc e) acc e))
(reduce fn args))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment