Created
August 29, 2018 21:16
-
-
Save greghendershott/d2348b4e95dd0bf6e049f3652522d248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require racket/match) | |
(define (combining xs pred?) | |
(let loop ([xs xs]) | |
(match xs | |
[(list* (? pred? this) (? pred? next) more) | |
(loop (cons (string-append this next) more))] | |
[(cons this more) | |
(cons this (loop more))] | |
[(list) | |
(list)]))) | |
(define (starts-with-A? s) | |
(regexp-match? #px"^A" s)) | |
(module+ test | |
(require rackunit) | |
(check-equal? (combining '("Apple" "Bear" "Alvin" "Anxious" "Agile" "Body") | |
starts-with-A?) | |
'("Apple" "Bear" "AlvinAnxiousAgile" "Body"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment