Clojure介绍

来源:互联网 发布:怎样下载python 编辑:程序博客网 时间:2024/04/28 14:34

What is Clojure?

Clojure is a dynamic,LISP-like programming language that runs on the JVm.

 

Homoiconic

Code is Data

Data is Code

Everything is list


Fairly functional

Runtime polymorphism

Jvm language

Software transactional memory

Agent-based asynchronous concurrency



Numbers -1234

Ratios -22/7

Strings -"foo"

Characters- \a

Symbols -foo

Keywords- :foo

Bollean -true/false

Null -nil

 

Lists -(1 2 3 4)

Vectors -[1 2 3 4]

Maps -{:a 1 :b 2 :c 3} or {:a 1, :b 2, :c 3}

Sets -#{foo bar baz}

 

(class "foo") => java.lang.String

(rest '("foo" "bar" "baz")) => ("bar" "baz")

The ' tells the reader not toevaluate the first element as a function

'(1 2 3) is shorthand for (quote (1 2 3))

 

Collections are the main datastructure in clojure

A collection can be a list,a vector, amap or a set

 

参考资料

http://www.slideshare.net/thnetos/clojure-intro