add min and max
This commit is contained in:
		
							parent
							
								
									066575fa1c
								
							
						
					
					
						commit
						cc1adb93ce
					
				|  | @ -286,6 +286,18 @@ | |||
|       ((pair? nums) acc) | ||||
|     (set! acc (* acc (car nums))))) | ||||
| 
 | ||||
| (define (min x . args) | ||||
|   (let loop ((pivot x) (rest args)) | ||||
|     (if (null? rest) | ||||
| 	pivot | ||||
| 	(loop (if (< x (car rest)) x (car rest)) (cdr rest))))) | ||||
| 
 | ||||
| (define (max x . args) | ||||
|   (let loop ((pivot x) (rest args)) | ||||
|     (if (null? rest) | ||||
| 	pivot | ||||
| 	(loop (if (> x (car rest)) x (car rest)) (cdr rest))))) | ||||
| 
 | ||||
| ;;; so ugly code, must rewrite everything as soon as possible... | ||||
| (define-macro (define-transitive-predicate op) | ||||
|   `(define (,op . args) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Yuichi Nishiwaki
						Yuichi Nishiwaki