[racket] Super basic question about strings
Two minutes ago, Richard Lawrence wrote:
> Dear Racketeers:
>
> Ok, I feel really silly asking this, because I feel like I am missing
> something really conceptually basic, but the answer isn't apparent to me
> from the examples in the Guide:
>
> What's the right way to programatically build up strings in Racket?
>
> For example, suppose I want to consume an association list like
> '((k1 . v1) (k2 . v2) ...)
> and produce a string that looks like:
> "k1=v1 k2=v2 ..."
Here's one way to do this:
(define (alist->string alist)
(string-join
(for/list ([a (in-list alist)])
(format "~a=~a" (car a) (cdr a)))
" "))
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!