Clojure is an open source programming language created in 2007 by Rich Hickey.
#27on PLDB | 17Years Old | 82kRepos |
git clone https://github.com/clojure/clojure
Clojure ( , like "closure") is a dialect of the Lisp programming language. Clojure is a general-purpose programming language with an emphasis on functional programming. It runs on the Java virtual machine and the Common Language Runtime. Read more on Wikipedia...
(println "Hello, world!")
(println "Hello World")
; Hello world in Clojure
(defn hello []
(println "Hello world!"))
(hello)
(defn rand
"Returns a random floating point number between 0 (inclusive) and
n (default 1) (exclusive)."
([] (scm* [n] (random-real)))
([n] (* (rand) n)))
;; A typical entry point of a Clojure program:
;; `-main` function
(defn -main ; name
[& args] ; (variable) parameters
(println "Hello, World!")) ; body
Feature | Supported | Example | Token |
---|---|---|---|
Standard Library | ✓ | (println "Hello, World!") | |
Integers | ✓ | ; -?\d+ | |
Floats | ✓ | ; -?\d+\.\d+ | |
Hexadecimals | ✓ | ; 0x-?[abcdef\d]+ | |
MultiLine Comments | ✓ | (comment A comment ) | (comment ) |
Print() Debugging | ✓ | println | |
Homoiconicity | ✓ | ||
Line Comments | ✓ | ; A comment | ; |
Operator Overloading | ✓ | ||
Macros | ✓ | ; https://www.braveclojure.com/writing-macros/ ; https://clojure.org/reference/macros (defmacro and "Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true." {:added "1.0"} ([] true) ([x] x) ([x & next] `(let [and# ~x] (if and# (and ~@next) and#)))) | |
File Imports | ✓ | (load "fun") (load "files/fun") (load-file "./files/fun.clj") (defproject project-a :dependencies [[org.clojure/clojure "1.5.1"] [project-b "0.1.0"]]) (require '[clojure.string :as string]) (use '[clojure.string :only [split]]) (import 'java.util.Date) (java.util.Date.) (require 'clojure.contrib.def 'clojure.contrib.except 'clojure.contrib.sql) (require '(clojure.contrib def except sql)) | |
Comments | ✓ | ||
Partial Application | ✓ | (defn fun-full [x y] (+ x y)) (fun-full 2 3) (def fun-half (partial fun-full 2)) (fun-half 3) | |
Strings | ✓ | "hello world" | " |
Case Insensitive Identifiers | X | ||
Semantic Indentation | X |