Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Let's not repeat ourselves
- (def unix-good "This is a Unix box and therefore good")
- (def windows-bad "This is a Windows box and therefore bad")
- (def mac-superior "This is a Macintosh box and therefore far superior")
- (def not-box "This is not a box")
- ;; Returning a string given some other string is not a unique and special
- ;; snowflake. Someone else did this before you did, so the language has it built
- ;; in. It's in an agent so it's easy to add to.
- (def boxen (agent {"Linux" unix-good
- "SunOS" unix-good
- "Mac OS" mac-superior
- "Windows NT" windows-bad
- "Windows 95" windows-bad}))
- (defn get-box []
- (get @boxen (System/getProperty "os.name") not-box))
- ;; Oh, let's add something. Someone using this as a library could do this too.
- (def osx-arrogant "This is both a Macintosh and a Unix box. I look down my nose at you.")
- (send boxen assoc "Mac OS X" osx-arrogant)
- ;; Did I mention this is all non-blocking and thread-safe?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement