In *Clojure Programming* (Emerick, Carper, Grand) a swap-pairs function is 
defined in the section describing how empty allows you to write functions 
against abstractions. That function operates on sequentials, and, 
importantly, is carefully designed (invoking empty) so that its return type 
is consistent with its argument's type.

For example:

(swap-pairs [1 2 3 4])

;=> [2 1 4 3]


(swap-pairs '(1 2 3 4))

;=> (3 4 1 2)


Things go awry with MapEntry:


(sequential? (first {:a 1}))

;=> true


(swap-pairs (first {:a 1}))

;=> (:a 1)

Compare this with what you get in ClojureScript:

(sequential? (first {:a 1}))

;=> true


(swap-pairs (first {:a 1}))

;=> [1 :a]



-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to