[racket] Super basic question about strings

From: Richard Lawrence (richard.lawrence at berkeley.edu)
Date: Wed Nov 17 10:59:31 EST 2010

Matthias Felleisen <matthias at ccs.neu.edu>
writes:

> On Nov 17, 2010, at 2:40 AM, Eli Barzilay wrote:
>
>>   (define (alist->string alist)
>>      (string-join
>>       (for/list ([a (in-list alist)])
>>         (format "~a=~a" (car a) (cdr a)))
>>       " "))
>
>
> Somewhat more 'native': 
>
> (define (alist->string l) 
>   (string-join 
>     (map (lambda (x) (format "~s=~s" (car x) (cdr x))) l) " "))
>
> in the sense that map preceded our for/ loops by 4 decades. 
>
> -- Matthias

Oy, how did I get it into my head that somehow format required an output
port?  And somehow I missed string-join, too. Thank you, Matthias and
Eli, for your succinct examples.  That clears some things up.

Richard



Posted on the users mailing list.