Last active
December 23, 2015 19:29
-
-
Save AKST/6682963 to your computer and use it in GitHub Desktop.
Just a simple implementation of the max function in scheme.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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