Clojure Getting Started
2012-06-19 10:32
246 查看
this page gives an overview of common closure scripting calls.
The following steps help you write your first clojure script:
1. Get Counterclockwise, the Eclipse plug-in at http://updatesite.counterclockwise.googlecode.com/hg (for
more information, see Clojure's getting started page).
2. Then create a new Clojure project and a clojure file.
3. Add the following: (println "Hello, world").
4. Run as > clojure
More detailed info on Clojure syntax, see:
primer: http://www.moxleystratton.com/article/clojure/for-non-lisp-programmers
detailed quick reference: http://faustus.webatu.com/clj-quick-ref.html
book: http://java.ociweb.com/mark/clojure/article.html
Clojure is a functional programming language. It provides the tools to avoid mutable state, provides functions as first-class objects, and emphasizes recursive iteration instead of side-effect based looping. Clojure is impure, in that it doesn't force your
program to be referentially transparent, and doesn't strive for 'provable' programs. The philosophy behind Clojure is that most parts of most programs should be functional, and that programs that are more functional are more robust.
The naming convention in Clojure is to use all lowercase with hyphens separating words in multi-word names, unlike the Java convention of using camelcase.
Clojure makes heavy use of lazy evaluation. This allows functions to be invoked only when their result is needed. "Lazy sequences" are collections of results that are not computed until needed. This supports the efficient creation of infinite collections.
Alternatively, see the Clojure Sample Code.
(Alternatively, see the entire clojure MySQL demo code.)
http://clojure.blip.tv/?sort=custom;date=;view=archive;user=clojure;nsfw=dc;s=posts;page=1
The following steps help you write your first clojure script:
1. Get Counterclockwise, the Eclipse plug-in at http://updatesite.counterclockwise.googlecode.com/hg (for
more information, see Clojure's getting started page).
2. Then create a new Clojure project and a clojure file.
3. Add the following: (println "Hello, world").
4. Run as > clojure
More detailed info on Clojure syntax, see:
primer: http://www.moxleystratton.com/article/clojure/for-non-lisp-programmers
detailed quick reference: http://faustus.webatu.com/clj-quick-ref.html
book: http://java.ociweb.com/mark/clojure/article.html
Clojure Philosophy
Clojure is a functional programming language. It provides the tools to avoid mutable state, provides functions as first-class objects, and emphasizes recursive iteration instead of side-effect based looping. Clojure is impure, in that it doesn't force yourprogram to be referentially transparent, and doesn't strive for 'provable' programs. The philosophy behind Clojure is that most parts of most programs should be functional, and that programs that are more functional are more robust.
The naming convention in Clojure is to use all lowercase with hyphens separating words in multi-word names, unlike the Java convention of using camelcase.
Clojure makes heavy use of lazy evaluation. This allows functions to be invoked only when their result is needed. "Lazy sequences" are collections of results that are not computed until needed. This supports the efficient creation of infinite collections.
Common Syntax
Alternatively, see the Clojure Sample Code.Built in forms | ||
common arithmetic operations | ||
comparisons | ||
comment | ||
functions | ||
Lists | Lists can have zero or more items, enclosed in parentheses. The list's elements are delimited with a space. | |
vector | immutable, between [] | |
list | immutable, between () | |
map | immutable, between {} | |
sets | immutable, between #{} | |
hash-map | immutable, between () | |
set | ||
get | ||
def assoc dissoc merge- with doseq | ||
looping | In the absence of mutable local variables, looping and iteration must take a different form than in languages with built-in for or while constructs that are controlled by changing state. In functional languages looping and iteration are replaced/implemented via recursive function calls. Many such languages guarantee that function calls made in tail position do not consume stack space, and thus recursive loops utilize constant space. | |
sequence | A Sequence is not a data structure but an interface, or view, into a data structure. A sequence can be derived from a collection. The relation between collection and sequence is similar to the relation between database table and database view. sequence from a map: | |
Java integration | ||
Automated tests | tests. | |
Java integration
General | ||
Static methods | ||
Class and fields | ||
Import | ||
Create instance | ||
Call instance methods | ||
Call Java static methods | ||
Chaining | ||
Implementing interfaces and extending classes (use the reify macro): |
MySQL
(Alternatively, see the entire clojure MySQL demo code.)
Commands
Join
References
http://clojure.blip.tv/?sort=custom;date=;view=archive;user=clojure;nsfw=dc;s=posts;page=1
相关文章推荐
- Clojure入门指南(Getting Started)
- Clojure入门指南(Getting Started)
- Getting started: Clojure Web App with Compojure and Envlive
- Microsoft Windows Forms QuickStarts Tutorial - Getting Started
- AndroMDA Getting started(八)
- ASP.NET AJAX Roadmap--Getting Started (2): Installing ASP.NET AJAX
- Using JDBC with MySQL, Getting Started
- Ehcache 1.5.0 User Guide - Getting Started(开始)
- Chapter 1. Getting Started(2)
- Getting Started[Asterisk 1.8 Documentation]
- Getting started with the MeeGo v1.2 SDK for Linux
- Clojure语言 vs Scala语言
- Clojure Web 开发一些注意事项
- 《C++ GUI Programming with Qt4》.1.Getting Started
- window 下安装配置Clojure的Emacs开发环境
- [UvaOJ - Getting Started] 10055 - Hashmat the Brave Warrior
- 用clojure解决euler problem 3
- Vuforia Getting Started
- clojure入门: hello world
- Clojure编程环境安装