background preloader

Quick Refs

Facebook Twitter

A Concise Guide to Clojure. A Concise Guide to Clojure (under construction)Copyright ©2011, David Matuszek The following list is from which is abstracted from However, one reviewer said that the latter is hopelessly out of date. Nevertheless, it's the best source I've found so far. Clojure is a modern variant of Lisp-1. The following comparisons are to the "original" Lisp. As in Lisp, code and data have the same syntax. Numbers: Clojure has integers, floating point numbers, and ratios. Integers include decimal integers (255), octals numbers (012), hexadecimal numbers (0xff) and radix numbers (2r1111), where the radix is an integer between 2 and 36, inclusive. Atoms (variables): Names for values. Important atoms: true, false, and nil. Strings are enclosed in double quotes, and can contain escaped characters: "hello", "line one\nline two". (first sequence) (empty? Tests. Clojure Programming/Examples/API Examples.

This page gives example usage for Clojure API function calls. For a more general introduction to Clojure by example please see Documentation[edit] This page provides examples for the following functions. Data Structures[edit] Numbers[edit] Strings[edit] str Characters[edit] Advanced Data Structures[edit] Lists[edit] Vectors[edit] Maps[edit] Struct Maps[edit] Array Maps[edit] Sets[edit] union Zippers[edit] Sequences[edit] Sequence Building[edit] Mapping Operators[edit] Macros[edit] do Macros[edit] Variable Definition[edit] MultiMethod[edit] This page defines the following functions Reference Tools[edit] This page defines the following functions. Predicate functions[edit] Recursion Tools[edit] Function Tools[edit] Java Interaction[edit] Namespaces[edit] ns[edit] (ns test.test (:refer-clojure :exclude [+ -])) (defn + [a b] 33) (+ 1 2) ;= 33 require[edit] (require '[clojure.zip :as zip]) (require ['clojure.contrib.sql :as 'sql]) Misc. test[edit]

Clojure Programming/By Example. This is intended to be a hands on first look at Clojure. If you wish to try the examples as you go, then you may wish to have already set up a working environment as per so you can see the results of the example code. Clojure programs are written in forms. Forms enclosed in parenthesis indicate function calls: calls the '+' function with arguments 1 2 3 and returns the value 6, the sum of arguments. New functions can be defined using defn: (defn average [x y] (/ (+ x y) 2)) Here x and y are symbols representing the input arguments. And will return 4. Clojure provides easy access to the JVM: (.show (javax.swing.JFrame.))

This calls the show method on the result of (javax.swing.JFrame.) which constructs a new Jframe. Functions can be passed to other functions: (map + [1 2 3] [4 5 6]);; Equivalent to (list (+ 1 4) (+ 2 5) (+ 3 6)) returns (5 7 9). Returns (5/2 7/2 9/2) We see here that Clojure supports ratios as a data types. Clojure - Functional Programming for the JVM. By R. Mark Volkmann, Partner Object Computing, Inc. (OCI) last updated on 6/2/13 Contents Introduction The goal of this article is to provide a fairly comprehensive introduction to the Clojure programming language.

A large number of features are covered, each in a fairly brief manner. Feel free to skip around to the sections of most interest. Please send feedback on errors and ways to improve explanations to mark@ociweb.com, or fork the repository and send a pull-request. You said X, but the correct thing to say is Y. Updates to this article that indicate the "last updated" date and provide a dated list of changes will be provided at Code examples in this article often show the return value of a function call or its output in a line comment (begins with a semicolon) followed by "->" and the result. (+ 1 2) ; showing return value -> 3 (println "Hello") ; return value is nil, showing output -> Hello Functional Programming Clojure Overview Getting Started.

Overview - clojure-contrib v1.2 API documentation. The user contributions library, clojure.contrib, is a collection of namespaces each of which implements features that we believe may be useful to a large part of the clojure community. This library was created by Rich Hickey but has been populated and is maintained by a group of volunteers who are excited about the success of the Clojure language and want to do our part to help it along. The current list of contributors is available on the clojure-contrib GitHub source page. More contributions (and contributors) are welcome. If you wish to contribute, you will need to sign a contributor agreement (which allows Clojure and clojure.contrib to proceed without entanglements, see contributing for more info).

The best way to start is to share a project you've written with the google group and gauge the interest in adding it to contrib. (Publishing it in an open source form on google code, github or some other easy-to-access place in the net will also help.) Important clojure-contrib resources. Clojure Categorized. Clojure Cheatsheets. Franks42/clj-ns-browser. Cheatsheet. Clojure Atlas – An experimental visualization of the Clojure language and its standard library. Clojure Core 1.3.0.