On Jan 26, 4:47 pm, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> On Jan 26, 2009, at 4:31 PM, BerlinBrown wrote:
>
> > I want to output a directory with a similar listing (see below), but
> > only a fixed number of spaces. Is there a clojure approach to
> > already do this.
>
> > -rw 13290 1216183460872 LispExample_Flow.png
> > -rw 3211 1217537516267 PDFReport.java
>
> > I think in Common Lisp, the powerful 'format' could make this happen
> > probably in one line. Anyone conjure a clojure approach?
>
> Clojure provides easy access to Java's "format" method via
> clojure.core/format .
>
> Here's one way to produce fixed width fields:
>
> user> (def lines [["-rw" "13290" "1216183460872" "LispExample_Flow.png"]
> ["-rw" "3211" "1217537516267" "PDFReport.java"]])
> #'user/lines
>
> user> (doseq [line lines]
> (println (apply format "%3s %5s %15s %s" line)))
> -rw 13290 1216183460872 LispExample_Flow.png
> -rw 3211 1217537516267 PDFReport.java
> nil
>
> user>
>
> You may also find clojure.core/printf helpful with this.
>
> --Steve
>
> smime.p7s
> 3KViewDownload
Perfect, thanks. Great community here. The lispers would have just
shot me down.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---