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
(def person {:name "Lucas" :address {:street "Any Street" :number "321", :city "São Paulo"}}) | |
(let [{name :name {street :street city :city} :address} person] | |
(println name " lives in " city " at " street)) ; => "Lucas lives in São Paulo at Any Street" |
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
(def point {:x 1}) | |
(let [{:keys [x y] :or {x 0 y 0}} point] | |
(println "x:" x "y:" y)) ; => "x: 1 y: 0" |
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
(def point {:x 1 :y 4}) | |
(let [{:keys [x y]} point] | |
(println "x:" x "y:" y)) ; => "x: 1 y: 4" |
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
(def point {:x 1 :y 4}) | |
(let [{x :x y :y} point] | |
(println "x:" x "y:" y)) ; => x: 1 y: 4 |
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
(def point {:x 1 :y 4}) | |
(let [{x-value :x y-value :y} point] | |
(println "x:" x-value "y:" y-value)) ; => x: 1 y: 4 |
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
(def elements [0 1 2 3 5]) | |
(let [[head & tail :as full-elements] elements] | |
(println "head: " head " tail: " tail "full-elements: " full-elements)) ; => "head: 0 tail: (1 2 3 5) full-elements: [0 1 2 3 5]" |
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
(def elements [0 1 2 3 5]) | |
(let [[head & tail] elements] | |
(println "head: " head " tail: " tail)) ; => "head: 0 tail: (1 2 3 5)" |
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
(def point [5 7]) | |
(let [[_ y] point] | |
(println "y:" y)) ; => "y: 7" |
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
(def point [5 7]) | |
(let [[x] point] | |
(println "x:" x)) |
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
(def point [1 2]) | |
(let [[x y] point] | |
(println "x:" x "y:" y)) ; => "x: 1 y: 2" |
NewerOlder