Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Your lover will never wish to leave you.


comp / comp.lang.scheme / Re: Poll: StudlyChallenge

SubjectAuthor
o Re: Poll: StudlyChallengeB. Pym

1
Subject: Re: Poll: StudlyChallenge
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Sat, 14 Sep 2024 20:47 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: Poll: StudlyChallenge
Date: Sat, 14 Sep 2024 20:47:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <vc4sp8$1m02t$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Sat, 14 Sep 2024 22:47:38 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f2477dd8f5f86e6d1f3e8deefdebd6cb";
logging-data="1769565"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vtemwCNJcs4eX4lR3oHcB"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:fA+8UHcrPRhBowSt6b2GhQUVo+Q=
View all headers

Kenny Tilton wrote:

> (defun lisp-fn (n$ &aux ln)
> (dotimes (n (length n$) (intern (coerce (nreverse ln) 'string)))
> (let ((c (elt n$ n)))
> (when (and (upper-case-p c)
> (or (lower-case-p (elt n$ (1- n)))
> (lower-case-p (elt n$ (1+ n)))))
> (push #\- ln))
> (push (char-upcase c) ln))))
>
> > (lisp-fn "sTuDlYcApS")
> S-TU-DL-YC-AP-S

Gauche Scheme

(use srfi-13 :only (string-downcase string-trim))

(define (de-stud name)
;; Clojure-style threading or pipelining.
(-> name
((swap regexp-replace-all) #/[A-Z]/ "-\\0")
(string-trim #\-)
string-downcase
string->symbol))

(de-stud "XsTuDLYcApS")
===>
xs-tu-d-l-yc-ap-s

Given:

(define-syntax ->
(syntax-rules ()
[(_ x) x]
[(_ x (y more ...) z ...)
(-> (y x more ...) z ...)]
[(_ x y z ...)
(-> (y x) z ...)]))

(define (swap func)
(lambda (a b . args)
(apply func b a args)))

1

rocksolid light 0.9.8
clearnet tor