Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; returns the rounded mid of a value
- (defn calculateMid [paramx]
- (- (int (Math/ceil (/ paramx 2))) 1)
- )
- (defn printTree [paramx]
- ; create the first vector with many dots (........)
- (def dots (vec (replicate paramx ".")))
- ; creates new vector - adds a X in the mid of the list
- (def midValue (calculateMid paramx))
- (def lines (assoc dots midValue "X"))
- ; creates the actual tree shape
- (dotimes [n midValue]
- (-> lines
- (assoc (- midValue n) "X")
- (assoc (+ midValue n) "X")
- (println)
- )
- )
- )
- ; prints the last row with xxxxxxxxx
- (defn printLastRow [paramx]
- (println (vec (replicate paramx "X")))
- )
- ; prints the trunk of the tree
- (defn printTrunk [paramx]
- (dotimes [n paramx]
- (-> lines
- (assoc (- midValue 1) "X")
- (assoc (+ midValue 1) "X")
- (println)
- )
- )
- )
- (println "Bitte die Groesse des Baums angeben (Zahlen von 5-100)")
- (def amount (read-string (read-line)))
- (printTree amount)
- (printLastRow amount)
- (printTrunk 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement