cfunction
src/core/corelib.c on line 397 , column 1
(tuple & items )
Creates a new tuple that contains items. Returns the new tuple.
# access tuple values
(def t [:a :b :c ]) # test tuple
(first t )
# => :a
(last t )
# => :c
(slice t 0 2 )
# => (:a :b)
# Index as function
(0 t )
# => :a
# Tuple as function
(t 0 )
# => :a
# With destructuring
(let [[_ b _ ] t ]
b )
# => :b
# With pattern matching
(match t
[:a _ :d ] (print "does not match" )
[:a b :c ] (print b )
_ (print "anything" ))
# => :b
[1 2 3] # => (1 2 3)
(tuple 1 2 3) # => (1 2 3)
(tuple (splice [1 2 3]) # => (1 2 3)
(tuple ;[1 2 3]) # => (1 2 3)
(tuple 1 2.3 :a "foo" true nil [] {} (fn []))
# => (1 2.3 :a "foo" true nil () {} <function 0x7FB2A3D030B0>)