background preloader

Learn Clojure

Learn Clojure
Related:  Programming, Coding & Scripting

7 Rules for Writing Clojure Programs « Two Guys Arguing Over the past 5 months, I’ve had the incredible opportunity at Revelytix to write Clojure every day and get paid for it. 5 months is an incredibly short time to pretend to have learned anything, but I can feel the beginnings of a style emerge in my programming and while writing a small program some ideas congealed into actual words that I thought I’d capture here. Update: Ugh. I really messed up. As it has been noted in the comments below, on Hacker News and even Twitter, my final solution is much (much) slower thanks to it’s not one, but two sorts. In the end, the whole thing is doubly redundant as clojure.contrib.seq-utils implemented a function ‘frequencies’ which will be in 1.2′s clojure.core. It uses ‘reduce’ and you should too. #1 – Your brain will think in steps. The program that brought these ideas to life was a small utility I needed to read a file and print out the set of characters contained within along with the number of occurrences of each character. "abcdaabccc"

Foreword | Clojure for the Brave and True As you read this hilarious book, you will at some point experience a very serious moment. It is the moment you admit to yourself that programming is more enjoyable after knowing some Clojure. It is also the moment that your investment in this book, in money and time, comes back to you—with interest. Humor has a certain relationship to seriousness. This book works in the opposite way. This approach is refreshing because most of the programming books I’ve read are drier than a camel’s fart. Clojure is the topic of this book, but in a way it—or perhaps its creator, Rich Hickey—is also one of the authors, since Clojure is the most elegant programming language ever designed. Elegance is a quality regularly ascribed to many dialects in the family of programming languages known collectively as Lisp, of which Clojure is one. Since 1958, there have been many Lisps and Lisp books. I find Clojure, and this particular book about it, especially right for the present. Alan Dipert

Clojure - home Clojure made-simple - John Stevenson SICP in Clojure Learn clojure in Y Minutes Clojure is a Lisp family language developed for the Java Virtual Machine. It has a much stronger emphasis on pure functional programming than Common Lisp, but includes several STM utilities to handle state as it comes up. This combination allows it to handle concurrent processing very simply, and often automatically. (You need a version of Clojure 1.2 or newer) Further Reading This is far from exhaustive, but hopefully it’s enough to get you on your feet. Clojure.org has lots of articles: Clojuredocs.org has documentation with examples for most core functions: 4Clojure is a great way to build your clojure/FP skills: Clojure-doc.org (yes, really) has a number of getting started articles: Got a suggestion?

Practical: An MP3 Database Copyright © 2003-2005, Peter Seibel In this chapter you'll revisit the idea first explored in Chapter 3 of building an in-memory database out of basic Lisp data structures. This time your goal is to hold information that you'll extract from a collection of MP3 files using the ID3v2 library from Chapter 25. You'll then use this database in Chapters 28 and 29 as part of a Web-based streaming MP3 server. Of course, this time around you can use some of the language features you've learned since Chapter 3 to build a more sophisticated version. The Database The main problem with the database in Chapter 3 is that there's only one table, the list stored in the variable *db* . This time you'll solve both problems by defining a class, table , to represent individual database tables. (defclass table () ((rows :accessor rows :initarg :rows :initform (make-rows)) (schema :accessor schema :initarg :schema))) Defining a Schema (defgeneric make-column (name type &optional default-value)) Inserting Values

magnars/prone · GitHub Closure (computer science) def start(x): def increment(y): return x+y return increment The closures returned by start can be assigned to variables like first_inc and second_inc. Invoking increment through the closures returns the results below: first_inc = start(0) second_inc = start(8) first_inc(3) # returns 3 second_inc(3) # returns 11 # The x value remains the same for new calls to the function: first_inc(1) # returns 1 second_inc(2) # returns 10 In ML, local variables are allocated on a linear stack[citation needed]. Closures are closely related to Actors in the Actor model of concurrent computation where the values in the function's lexical environment are called acquaintances. Closures are closely related to function objects; the transformation from the former to the latter is known as defunctionalization or lambda lifting. ; Return a list of all books with at least THRESHOLD copies sold. Here is the same example rewritten in JavaScript, another popular language with support for closures:

Learning Clojure - What should I know about Java and more robflaherty/jquery-annotated-source

Related: