Last active
November 3, 2022 14:37
-
-
Save PEZ/3b66d5ad0242a7fbbb163a14c2df96f2 to your computer and use it in GitHub Desktop.
Intro to Destructuring 2 – Rich 4Clojure Problem 173 – See: https://github.com/PEZ/rich4clojure
This file contains hidden or 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 rich4clojure.easy.problem-173 | |
| (:require [hyperfiddle.rcf :refer [tests]])) | |
| ;; = Intro to Destructuring 2 = | |
| ;; By 4Clojure user: hangkous | |
| ;; Difficulty: Easy | |
| ;; Tags: [Destructuring] | |
| ;; | |
| ;; Sequential destructuring allows you to bind symbols to | |
| ;; parts of sequential things (vectors, lists, seqs, | |
| ;; etc.): (let [bindings*] exprs*) | |
| ;; | |
| ;; Complete the bindings so all let-parts evaluate to 3. | |
| (def __ :tests-will-fail) | |
| (comment | |
| ) | |
| (tests | |
| 3 := | |
| (let [[__] [+ (range 3)]] (apply __)) | |
| (let [[[__] b] [[+ 1] 2]] (__ b)) | |
| (let [[__] [inc 2]] (__))) | |
| ;; To participate, fork: | |
| ;; https://github.com/PEZ/rich4clojure | |
| ;; Post your solution below, please! |
blogscot
commented
Aug 20, 2022
(tests
3 :=
(let [[f coll] [+ (range 3)]] (apply f coll))
(let [[[f v] b] [[+ 1] 2]] (f v b))
(let [[f v] [inc 2]] (f v)))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment