more simplification

main
Inga 🏳‍🌈 12 months ago
parent 827d301949
commit f6617f0521
  1. 9
      day01-easy/main.scm

@ -33,6 +33,13 @@
(define (sum numbers) (reduce numbers + 0)) (define (sum numbers) (reduce numbers + 0))
(define
(repeat value number)
(if
(= number 0)
'()
(cons value (repeat value (- number 1)))))
(define (is-numeric-char char) (if (char-numeric? char) #t #f)) (define (is-numeric-char char) (if (char-numeric? char) #t #f))
(define (first-last list predicate) (define (first-last list predicate)
@ -43,7 +50,7 @@
(cons (cons
(if (if
(predicate (car list)) (predicate (car list))
(cons (car list) (cons (car list) '())) (repeat (car list) 2)
'()) '())
(first-last (cdr list) predicate)) (first-last (cdr list) predicate))
(lambda (current rest) (lambda (current rest)

Loading…
Cancel
Save