foo, foo#bar
"foo", "\"foo\tbar\n\""
1, -2, 2.5
true, false
:foo
(foo bar)
[foo bar]
{:key1 value1 :key2 value2 "key3" value3}
'(foo bar)
; comment
#:0 ; index accessor
#:"key" ; key accessor
#::key ; key accessor
#!"foo"
#[body ^{:attr "value"}]
^{:key value}
`(foo bar)
`(foo ~bar)
`(foo ~@bar)
(list 'a 'b 'c) ;=> '(a b c)
(car '(a b c)) ;=> 'a
(cdr '(a b c)) ;=> '(b c)
(cons 'a '(b c)) ;=> '(a b c)
(#::a {:a 'a :b 'a}) ;=> 'a
(keys {:a 'a :b 'b}) ;=> (:a :b)
(#:1 ['a 'b 'c]) ;=> 'b
(#:"foo" ['a 'b 'c]) ;=> (foo ['a 'b 'c])
#[html ^{:class "markdown"} #[body "helleworld"]]
(length '(a b c)) ;=> 3
(length ['a 'b 'c]) ;=> 3
(length "abc") ;=> 3
(append '(a b) '(c d)) ;=> '(a b c d)
(append ['a 'b] ['c 'd]) ;=> ['a 'b 'c 'd]
(append "ab" "cd") ;=> "abcd"
(type "abc") ;=> "string"
(type :abc) ;=> "keyword"
(type {}) ;=> "map"
(meta foo ^{:m 'b})
(meta foo) ;=> {:m 'b}
(fn [arg & args]
(println 'a))
(apply list '(a b c)) ;=> '(a b c)
(eval "(+ 1 2)")
(require "core")
(def foo "bar")
(def ^{:k v} foo "bar")
(set! foo "bar")
(let [a 1
b a]
(println b))
(defmacro foo [arg & args]
`(println ~arg)
`(list ~@args))
(if (> 1 0)
(println true)
(println false))
(if true
(println true))
(while true
(println true))
(begin
(println 'foo)
(println 'bar))
(! true) ;=> false
A meta can be specifed to control what type of value should be passed into perl function.
type : "scalar" "array" "hash" "ref" "nil"
^{:return type
:arguments [type ...]}
(.CljPerl print "foo")
(.CljPerl print ^{:return "nil" :arguments ["scalar"]} "foo") ; return nil and pass first argument as a scalar
Like '.', but this will pass perl namespace as first argument to perl method.
(println {:a 'a})
(trace-vars)
(use-lib "path")
(ns "foo"
(println "bar"))
(defn foo [arg & args]
(println arg))
(file#open ">file"
(fn [fh]
(file#>> fn "foo")))
(file#<< fh)
(file#>> fh "foo")