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