Skip navigation.
Home
Freedom is contagious.

GatorLUG Meeting | 2009-02-18 | 6-8pm | Clojure Programming

Feb 18 2009 6:00 pm
Feb 18 2009 8:00 pm
Etc/GMT-4
Description: 

GatorLUG Meeting Agenda for February, 18 2009

6:00 - 6:30 Announcements / General Discussion

6:30 - 7:30 Presentation - Programming with Clojure | Eric Lavigne

Clojure is a dynamic programming language that targets the Java Virtual Machine. It is designed to be a general-purpose language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. Clojure is a compiled language - it compiles directly to JVM bytecode, yet remains completely dynamic. Every feature supported by Clojure is supported at runtime. Clojure provides easy access to the Java frameworks, with optional type hints and type inference, to ensure that calls to Java can avoid reflection.

Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system. Clojure is predominantly a functional programming language, and features a rich set of immutable, persistent data structures. When mutable state is needed, Clojure offers a software transactional memory system and reactive Agent system that ensure clean, correct, multithreaded designs.

This presentation will introduce the Clojure programming language. You will learn how to write simple Clojure programs, how to use Java code from Clojure, and how to use Clojure code from Java. You'll learn how to use agents and software transactional memory to make multithreaded programming easier. You'll also see a few examples of how Clojure can save you from re-implementing the same patterns over and over again.

Bio

Eric Lavigne is a Java programmer for UF's Bureau of Economic and Business Research. He has written several Clojure web development tutorials on his blog at http://ericlavigne.wordpress.com/

7:30 - 7:40 Raffle off book "Real World Haskell"

7:40 - 8:00 Socialize and meet someone new

Location: 
Virtually Cuban (2409 SW 13th St, Gainesville, FL 32608)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Codeslinger 2008 program, in Clojure

I made the minimum changes to get my shootout program to run in Clojure. Here it is:

(defn shoot [num-cards index]
  (let [main-loop
        (fn [index factorials in out] ; in & out are lists of cards
          (if (zero? index)
            (concat (reverse out) in)
            (let [fact (first factorials)
                  card (nth in (quot index fact))]
              (recur (rem index fact) (rest factorials)
                     (remove #(== % card) in) (cons card out)))))]
    ; the loop below just builds a list of cards and a list of factorials
    (loop [n 2
           fact 1
           cards '(1)
           facts ()]
      (if (> n num-cards)
        (main-loop (dec index) facts (reverse cards) ())
        (recur (inc n) (* n fact) (cons n cards) (cons fact facts))))))

; user=> (shoot 9 100000)
; (3 5 8 9 2 6 4 7 1)
;
; user=> (shoot 70 (* 100000000000000000000000000000000000000000000000000
;                     100000000000000000000000000000000000000000000000000))
; (59 31 14 44 33 24 51 1 29 9 17 12 43 61 69 70 53 21 65 36 68 30 41 19 66 34
; 50 7 26 6 32 10 60 20 55 42 4 25 67 64 2 57 39 27 52 48 38 15 54 45 58 18 23
; 37 3 22 13 16 46 40 56 11 62 63 49 8 35 28 47 5)

(comment edited 2009-03-25: specified 2008 in subject)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.