|
|
|
@ -22,29 +22,32 @@ |
|
|
|
|
current |
|
|
|
|
(reduce (cdr list) reducer (reducer current (car list))))) |
|
|
|
|
|
|
|
|
|
(define (first-last-combine current rest) |
|
|
|
|
(define (combine list combiner) |
|
|
|
|
(if |
|
|
|
|
(null? current) |
|
|
|
|
rest |
|
|
|
|
(null? (car list)) |
|
|
|
|
(cdr list) |
|
|
|
|
(if |
|
|
|
|
(null? rest) |
|
|
|
|
current |
|
|
|
|
(cons (car current) (cdr rest))))) |
|
|
|
|
(null? (cdr list)) |
|
|
|
|
(car list) |
|
|
|
|
(combiner (car list) (cdr list))))) |
|
|
|
|
|
|
|
|
|
(define (sum numbers) (reduce numbers + 0)) |
|
|
|
|
|
|
|
|
|
(define (is-numeric-char char) (if (char-numeric? char) #t #f)) |
|
|
|
|
|
|
|
|
|
(define (first-last list predicate) |
|
|
|
|
(if |
|
|
|
|
(null? list) |
|
|
|
|
'() |
|
|
|
|
(first-last-combine |
|
|
|
|
(combine |
|
|
|
|
(cons |
|
|
|
|
(if |
|
|
|
|
(predicate (car list)) |
|
|
|
|
(cons (car list) (cons (car list) '())) |
|
|
|
|
'()) |
|
|
|
|
(first-last (cdr list) predicate)))) |
|
|
|
|
|
|
|
|
|
(define (sum numbers) (reduce numbers + 0)) |
|
|
|
|
|
|
|
|
|
(define (is-numeric-char char) (if (char-numeric? char) #t #f)) |
|
|
|
|
(first-last (cdr list) predicate)) |
|
|
|
|
(lambda (current rest) |
|
|
|
|
(cons (car current) (cdr rest)))))) |
|
|
|
|
|
|
|
|
|
(define (solve-line line) |
|
|
|
|
( |
|
|
|
|