Last active
June 28, 2017 23:58
-
-
Save iku000888/a158d022043e66cf18c7916cfab8c9ed to your computer and use it in GitHub Desktop.
IPersistentStack ref: http://qiita.com/iku000888/items/4b65a0b030195d19e111
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
;; conj to a list | |
(conj '(1 2 3 4) 5) => (5 1 2 3 4) | |
;; conj to a vector | |
(conj [1 2 3 4] 5) => [1 2 3 4 5] |
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
(-> [1 2 3 4] | |
(conj 5) | |
peek) =>5 | |
(-> '(1 2 3 4) | |
(conj 5) | |
peek) => 5 |
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
;; popping from a vector | |
(-> [1 2 3 4] | |
(conj 5) | |
pop) => [1 2 3 4] | |
;; popping from a list | |
(-> '(1 2 3 4) | |
(conj 5) | |
pop) => (1 2 3 4) |
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
(time | |
(last [1 2 3 4 5 6 7 8 9])) | |
;; "Elapsed time: 0.171368 msecs" | |
(time | |
(peek [1 2 3 4 5 6 7 8 9])) | |
;; "Elapsed time: 0.066708 msecs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment