On Wed, May 25, 2016 at 11:03:34AM +0200, Ricardo Wurmus wrote:
> 
> Efraim Flashner <efr...@flashner.co.il> writes:
> 
> > +(define (wc-command file)
> > +  (if (and (file-exists? file) (access? file 4))
> > +     (let* ((wc-l ((@@ (guix build bournish) wc-l-command) file))
> > +            (wc-w ((@@ (guix build bournish) wc-w-command) file))
> > +            (wc-c ((@@ (guix build bournish) wc-c-command) file)))
> > +       (begin 
> > +         (display wc-l)(display #\space)
> > +         (display wc-w)(display #\space)
> > +         (display wc-c)(display #\space)
> > +         (display file)
> > +         (newline)))))
> 
> Have you considered using “format” instead of “display”?  The last
> “begin” could just be this:
> 
>   (format #t "~a ~a ~a ~a\n"
>     wc-l wc-w wc-c file)
> 
> or
> 
>   (format #t "~{~a ~}\n"
>     (list wc-l wc-w wc-c file))

I looked at the manual more and I found for-each which does what I was
looking for before which gave me this:

(for-each display (list wc-l #\space wc-w #\space wc-c #\space file))

but I do like the (format #t "~{~a ~}\n" (list ...)) better. I'm working
on trying to get it to read flags and the variable size of the list
works better with that.

format vs display, I knew I wanted display over write but I hadn't come
across format yet. If I don't need to specify #\space to get a space
then that sounds great.

> 
> Why is it necessary to do “(@@ (guix build bournish) ...)”?  Can it not
> be imported once?

When you say it out loud then it seems obvious it shouldn't need to be
imported more than once. I've also read more about let vs let* and I've
changed some to let.

> 
> ~~ Ricardo

Thanks!

-- 
Efraim Flashner   <efr...@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

Attachment: signature.asc
Description: PGP signature

Reply via email to