[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: format question

William James

6/8/2015 10:15:00 PM

Tim Moore wrote:

> > Can somebody think of a more elegant way to do this:
> > (format nil "~@[~D~]~{+~D~}" (car lst) (cdr lst))
> >where `lst' is a (possibly empty)
> > list of integers?
>
> Elegance is in the eye of the beholder, you might find this more elegant:
> (format nil "~{~D~^+~}" lst)

Gauche Scheme:

(use text.tree)

(let1 lst '(2 3 4)
(tree->string (intersperse '+ lst)))
===>
"2+3+4"

--
[Y]ou can never fix a decaying empire; the empire can only fall when the time
comes. You cannot fix the empire by sending good and honest men to the capital,
because the simple logic of the system corrupts everyone along the way.
www.kolumbus.fi/aquilon/america-middle-class-and-the-end-of-growth.htm