Skip to content

h4rikris/clojure-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Clojure examples

  • Find nth element in a collection
(defn nth [arr n]
  ((comp last (partial take (inc n))) arr))

Using recursion approach

(defn nth [arr n]
  (if (= n 0)
    (first arr)
    (nth (rest arr) (- n 1))))

Lazy Fibonacci sequence

(defn fib [n]
  (take n (map first
               (iterate
                (fn [[a b]] [b (+ a b)])
                [1 1]))))

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published