#lang racket (define/contract (find-peaks mountain) (-> (listof exact-integer?) (listof exact-integer?)) (let _go ([i 1] [prev (car mountain)] [cur (cdr mountain)] [res '()]) (if (= 1 (length cur)) res (let ([s (car cur)] [t (cadr cur)]) (_go (+ i 1) s (cdr cur) (append res (if (and (> s prev) (> s t)) (cons i '()) '()))) ) ) ) ) (define (main) (define (r mountain exp) (printf "(find-peaks ~a) = ~a | Exp: ~a\n" mountain (find-peaks mountain) exp ) ) (r '(2 4 4) '()) (r '(1 4 3 8 5) '(1 3)) ) (main)