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.119 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.118 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.117 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.116 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.115 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.114 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.113 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.111 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.110 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.109 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.108 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.107 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.106 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.105 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.104 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.103 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.102 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.101 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.100 tracks/racket/exercises/acronym/example.rkt
trackler-2.2.1.99 tracks/racket/exercises/acronym/example.rkt