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