Stuart, I took a second look at your suggestion. I integrated it
directly in my code, which became much more elegant as a direct
consequence. :) And it's a tiny, tiny little bit faster too. :)
(defn all-zips []
"Returns a lazy list of all possible American zipcodes."
(let [zips5 (zip-formatted-range 5)
zips4 (zip-formatted-range 4)
zips5-4 (for [x zips5, y zips4] (str x "-" y))]
(concat zips5 zips5-4)))
It definitely looks simpler. So my question becomes: is there a faster
way than using 'for'? I suppose not. Well, we've achieved ~71%
optimization, which is already quite good, thank you all.
On Jun 5, 11:17 am, Stuart Sierra <[email protected]> wrote:
> On Jun 5, 10:56 am, Daniel Jomphe <[email protected]> wrote:
>
> > I need to generate a list of all possible American zipcodes, MD5-
> > digested. Later on, I will need to do much more involving stuff,
>
> I'm not sure if this is exactly what you want, but maybe this will
> help:
>
> (defn all-zipcodes []
> (for [x (range 1 99999), y (range 1 9999)]
> (format "%05d-%04d" x y)))
>
> -Stuart Sierra
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---