Last active
September 7, 2022 20:41
-
-
Save keksipurkki/82f6462d66cfaf3f4f60bafee175b903 to your computer and use it in GitHub Desktop.
My first Clojure program
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
; clojure -M main.clj 3 | |
; 000 | |
; 001 | |
; 010 | |
; 011 | |
; 100 | |
; 101 | |
; 110 | |
; 111 | |
(defn binary-strings [level] | |
(def bits ["0" "1"]) | |
(cond | |
(< level 0) (throw (AssertionError. "Expected a non-negative integer")) | |
(= level 0) [] | |
(= level 1) bits | |
(> level 1) (for [x bits y (binary-strings (dec level))] (str x y)) | |
) | |
) | |
(def level (parse-long (first *command-line-args*))) | |
(run! println (binary-strings level)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment