Skip to content

Instantly share code, notes, and snippets.

@PEZ
Last active November 3, 2022 14:37
Show Gist options
  • Select an option

  • Save PEZ/3b66d5ad0242a7fbbb163a14c2df96f2 to your computer and use it in GitHub Desktop.

Select an option

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
(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
Copy link

(tests
 3 :=
 (let [[a c] [+ (range 3)]] (apply a c))
 (let [[[a c] b] [[+ 1] 2]] (a c b))
 (let [[a b] [inc 2]] (a b)))

@esciafardini
Copy link

(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