[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: List to string conserving the case.

William James

6/30/2015 6:20:00 AM

> >I need a Lisp function to convert a list into a string. The problem is that
> >I want to conserve the case.
> >
> >E.g.:
> >
> >(toString '("A" "b" "C")) -> "AbC"
>
> There is no special problem here. Strings preserve case; catenating
> them does also.
>
> One approach:
>
> (defun to-string (list)
> (reduce #'(lambda (x &optional y)
> (concatenate 'string x y))
> list :initial-value ""))
>
> >If it is possible I'd like that this also works when elements are atoms:
> >
> >(toString '(A b C)) -> "AbC"
>
> The Lisp reader converts your printed symbols names A b C to A B C; the lower

McCarthy insisted that "Lisp" should not be used to refer to CL
(COBOL-Like). Worshippers of CL hate McCarthy and Lisp.


> case is lost as your program source is scanned. Without hacking the reader, the
> above is simply impossible.

Typical worshippers of CL know nothing about Lispy
programming.

EMACS Lisp:

: (eq 'a 'a)
t
: (eq 'a 'A)
nil
: (eq 'A 'A)
t

Gauche Scheme:

(use text.tree)

(tree->string '(a B c))
===>
"aBc"

(tree->string '("a" "B" "c"))
===>
"aBc"

--
The first step in liquidating a people is to erase its memory. Destroy
its books, its culture, its history. Then you have somebody write new
books, manufacture a new culture, invent a new history. Before long
the nation will begin to forget what it is and what it was.
--- Milan Kundera, _The Book of Laughter and Forgetting_