((z x) y)))))
(def pair2 (fn [x] (fn [z] (fn [z] ((z x) z)))))
 
(snd ((pair1 "hello") 42))
;=&gt; 42

(snd ((pair2 "hello") 42))
;=&gt; #object[user$snd$fn__9927 0x24ee5473 "user$snd$fn__9927@24ee5473"]
</code></pre>
<p>The problem is that we renamed the bound variable <code>y</code> into <code>z</code> but <code>z</code> is already in use. However, the following works:</p>
<pre><code class="language-clojure">(def pair1 (fn [x] (fn [y] (fn [z] ((z x) y)))))
(def pair2 (fn [x] (fn [w] (fn [z] ((z x) w)))))
