Advertisement
satou_

core.clj

Jul 3rd, 2018
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. (ns firstclojureprog.core)
  2.  
  3. (defn foo [x]
  4. (println x "Hello, World!"))
  5.  
  6. (defn sum [l]
  7. (if (empty? l)
  8. 0
  9. (+ (first l)(sum (rest l)))))
  10.  
  11. (defn fact [n]
  12. (if (zero? n)
  13. 1
  14. (* n (fact (- n 1)))
  15. )
  16. )
  17.  
  18. ;; (foo "")
  19. (println (sum '(1 2 3)))
  20. (print (fact 10))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement