Skip to content

Instantly share code, notes, and snippets.

@greghendershott
Created August 29, 2018 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greghendershott/d2348b4e95dd0bf6e049f3652522d248 to your computer and use it in GitHub Desktop.
Save greghendershott/d2348b4e95dd0bf6e049f3652522d248 to your computer and use it in GitHub Desktop.
#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