Skip to content

Instantly share code, notes, and snippets.

@mikera
Created November 2, 2011 03:22
Show Gist options
  • Select an option

  • Save mikera/1332761 to your computer and use it in GitHub Desktop.

Select an option

Save mikera/1332761 to your computer and use it in GitHub Desktop.

Revisions

  1. mikera revised this gist Nov 2, 2011. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,5 @@

    (take 10 fibs)

    => (0 1 1 2 3 5 8 13 21 34)
    => (0 1 1 2 3 5 8 13 21 34)

  2. mikera renamed this gist Nov 2, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. mikera created this gist Nov 2, 2011.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Frequency analysis (implicitly treating a string as a sequence of chars)

    (frequencies "abracadabra")

    => {\a 5, \b 2, \r 2, \c 1, \d 1}

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Infinite, lazily calculated sequence of Fibonacci numbers

    (def fibs
    (lazy-cat [0N 1N] (map + (rest fibs) fibs)))

    (take 10 fibs)

    => (0 1 1 2 3 5 8 13 21 34)