Thanks Meikel. There's always something new to learn. I'm also fast
learning that if something doesn't look quite elegant in one's code,
then there's bound to be an elegant clojure way of doing it!


On Sun, Feb 8, 2009 at 4:51 PM, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> Am 08.02.2009 um 15:47 schrieb Adrian Cuthbertson:
>
>> Here's one, I'm setting basedir to either :basedir in a map in *locs
>> (a thread-local var) or to "." if :basedir was not found in the map...
>>
>> (let [basedir (if-let [bdir (:basedir *locs)] bdir ".")]
>>   ...)
>>
>> i.e bdir assumes the value of the test and if that is not false (or
>> nil) returns it otherwise the else part.
>
> This can be written more concise with get or even with :basedir alone:
>
> (let [basedir (get *locs :basedir ".")] ...)
> (let [basedir (:basedir *locs ".")] ...)
> (let [basedir (*locs :basedir ".")] ...)
>
> All but the last form work also if *locs is nil.
>
> Sincerely
> Meikel
>
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to