Last active
May 17, 2023 00:44
Star
You must be signed in to star a gist
rendezvous with cassidoo challenge: 22.08.08
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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