[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: #'format and string interpolation

William James

5/21/2015 8:41:00 PM

Tim Bradshaw wrote:

> (defun stringify (&rest strings/objects)
> (apply #'concatenate 'string
> (mapcar #'(lambda (x)
> (typecase x
> (string x)
> (t (princ-to-string x))))
> strings/objects)))
>
> * (stringify "this is " 'stringify " thing with " 4 " arguments")
> "this is stringify thing with 4 arguments"
>
> ? It's not quite as simple as perl, but it's OK I think.

Gauche Scheme:

(define (stringify . items)
(string-join (map x->string items) ""))

(stringify "this is " 'stringify " thing with " 4 " arguments")
===>
"this is stringify thing with 4 arguments"

--
You have politicians saying that ... as many Africans as want to come into
Sweden should be able to come.... I think there's a billion Africans now.
They've already said that everybody from Syria can come to Sweden because they
have a civil war there.... They have a huge housing crisis; they are actually
thinking of commandeering people's vacation homes because they need more housing
for immigrants. --- Kevin MacDonald (http://lnrlive.com/tpc/tpc201...)
1 Answer

William James

1/15/2016 11:23:00 AM

0

WJ wrote:

> Tim Bradshaw wrote:
>
> > (defun stringify (&rest strings/objects)
> > (apply #'concatenate 'string
> > (mapcar #'(lambda (x)
> > (typecase x
> > (string x)
> > (t (princ-to-string x))))
> > strings/objects)))
> >
> > * (stringify "this is " 'stringify " thing with " 4 " arguments")
> > "this is stringify thing with 4 arguments"
> >
> > ? It's not quite as simple as perl, but it's OK I think.
>
> Gauche Scheme:
>
> (define (stringify . items)
> (string-join (map x->string items) ""))
>
> (stringify "this is " 'stringify " thing with " 4 " arguments")
> ===>
> "this is stringify thing with 4 arguments"

MatzLisp (Ruby):

["this is ", :stringify, " thing with ", 4, " arguments"].join
==>"this is stringify thing with 4 arguments"

--
Use this [sword] for me, if I rule well; if not, against me. --- Trajan
"If a government uses the instruments of power in its hands for the purpose of
leading a people to ruin, then rebellion is not only the right but also the
duty of every individual citizen."