Skip to content

Instantly share code, notes, and snippets.

@chase-lambert
Last active May 17, 2023 00:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chase-lambert/655177989928ba54b9b0e03c45c5b4e3 to your computer and use it in GitHub Desktop.
rendezvous with cassidoo challenge: 22.08.08
(ns swap-pairs
(:require [clojure.test :refer [deftest is]]))
(defn swap-pairs [coll]
(->> (partition 2 coll)
(mapcat (fn [[a b]]
[b a]))
(into [])))
(deftest swap-pairs-test
(is (= [2 1 4 3] (swap-pairs [1 2 3 4]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment