Sha256: 1fa96ca3318ed3cbd58aa6e82ccf9efb8ea26bf1d06d65df7635938c58649f26

Contents?: true

Size: 680 Bytes

Versions: 216

Compression:

Stored size: 680 Bytes

Contents

#lang racket

(provide acronym)

(define (all-upper-case? s)
  (equal? s (string-upcase s)))

(define (all-lower-case? s)
  (equal? s (string-downcase s)))

(define (process-word word)
  (define (first-letter s)
    (~a (char-upcase (string-ref s 0))))
  (define (filter-caps s)
    (list->string (filter char-upper-case? (string->list s))))
  (cond
    [(all-upper-case? word) (first-letter word)]
    [(all-lower-case? word) (first-letter word)]
    [else (filter-caps word)]))  ;; camelcase/mixed case

(define (acronym str)
  (let ([words (string-split str #px"(\\s+)|-")])
    (apply string-append
           (for/list ([w (in-list words)])
             (process-word w)))))

Version data entries

216 entries across 216 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.179 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.178 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.177 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.176 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.175 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.174 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.173 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.172 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.171 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.170 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.169 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.167 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.166 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.165 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.164 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.163 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.162 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.161 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.160 tracks/racket/exercises/acronym/example.rkt