[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: concatenate atoms into string

William James

7/27/2015 9:22:00 AM

Marco Antoniotti wrote:

> FORMAT is your friend
>
> (defun join (word-list separator)
> (if word-list
> (format nil "~A~:{~C~A}" (first word-list)
> (mapcar (lambda (w)
> (list separator w))
> (rest word-list)))
> ""))



CL-USER(2): (join '("S" "I") "-")
Debugger invoked on condition of type FORMAT-ERROR:
error in format: no corresponding close brace
~A~:{~C~A}
^


> in alternative
>
> (defun join (word-list separator)
> (if word-list
> (with-output-to-string (s)
> (princ (first word-list) s) ; Or maybe PRIN1.
> (loop for w in word-list
> do (princ w s)
> (princ separator s)))
> "")

There is a missing parenthesis.

Once that is supplied:

CL-USER(2): (join '("S" "I") "-")
"SS-I-"

Worshippers of CL (COBOL-Like) are the dumbest of the dumb.

Gauche Scheme:

(string-join '("I" "D" "I" "O" "T") "-")
===>
"I-D-I-O-T"

--
[T]he entire program of research ... involved deception from beginning to end.
This is suggested by the authors' clear political agenda and the pervasive
double standard in which gentile ethnocentrism and gentile adherence to
cohesive groups are seen as symptoms of psychopathology whereas ... no mention
is made of Jewish ethnocentrism or allegiance to cohesive groups.
--- Dr. Kevin MacDonald; "The Frankfurt School of Social Research and the
Pathologization of Gentile Group Allegiances"