Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(var n 5 ) # n = 5
(-= n 1 ) # n -= 1
(print n ) # 4 (let [buf @"hello" ]
(buffer/blit buf " there" -1 ))
# =>
@"hello there" (update @{:a 1 } :a inc )
# => @{:a 2}
(slice [:a :b :c :d ]) # => (:a :b :c :d)
(slice [:a :b :c :d ] 0 ) # => (:a :b :c :d)
(slice [:a :b :c :d ] 1 ) # => (:b :c :d)
(slice [:a :b :c :d ] 3 ) # => (:d)
(slice [:a :b :c :d ] 4 ) # => ()
(slice [:a :b :c :d ] 5 ) # error: index out of range
(slice [:a :b :c :d ] -1 ) # => ()
(slice [:a :b :c :d ] -2 ) # => (:d)
(slice [:a :b :c :d ] -4 ) # => (:b :c :d)
(slice [:a :b :c :d ] -5 ) # => (:a :b :c :d)
(slice [:a :b :c :d ] -6 ) # error: index out of range
(slice [:a :b :c :d ] 0 0 ) # => ()
(slice [:a :b :c :d ] 0 1 ) # => (:a)
(slice [:a :b :c :d ] 0 4 ) # => (:a :b :c :d)
(slice [:a :b :c :d ] -1 -1 ) # => ()
(slice [:a :b :c :d ] -2 -1 ) # => (:d)
(slice [:a :b :c :d ] -5 -1 ) # => (:a :b :c :d)
(slice [:a :b :c :d ] 1 0 ) # => ()
(slice [:a :b :c :d ] 4 0 ) # => ()
(slice [:a :b :c :d ] -1 -2 ) # => ()
(slice [:a :b :c :d ] -1 -5 ) # => ()
(<= 1 2 3 ) # => true
(<= 1 2 1 ) # => false (def f (ev/go (coro "world" ))) # coro is great for fast fiber creating
(ev/sleep 0.0001 ) # give ev a chance in the REPL, remove in file
(fiber/last-value f ) # "world"
(string/join @["1" "2" "3" ]) # => "123"
# The esp argument is optional, and defaults to empty string (map tuple ["a" "b" "c" "d" ] [1 2 3 4 ] "abcd" )
# => @[("a" 1 97) ("b" 2 98) ("c" 3 99) ("d" 4 100)] # Get a new and different random number each time you run your program.
(math/seedrandom (os/cryptorand 8 ))
(math/random )(defn f1 [s ] (string "-" s "-" ))
(defn f2 [s ] (string "=" s "=" ))
(defn f3 [s ] (string "#" s "#" ))
(def f (juxt f1 f2 f3 ))
(f "x" ) # => ("-x-" "=x=" "#x#") (peg/replace ~(sequence :s (thru "t" ))
" duck"
"smiling cat sleeps" )
# => @"smiling duck sleeps" (defn recent-mods
"List the files in the current directory which have changed within the last hour."
[]
(filter
(fn [fname ]
(<
(- (os/time ) 3600 )
(os/stat fname :modified )))
(os/dir "." )))
(min 1 2 3 ) # => 1
(min (splice [1 2 3 ])) # => 1
(min ;[1 2 3 ]) # => 1
(apply min [1 2 3 ]) # => 1 (let [c0 (ev/chan )
c1 (ev/chan 1 )]
[(ev/capacity c0 ) (ev/capacity c1 )])
# => '(0 1) (symbol "foo" ) # => foo
(def a "foo" )
(symbol a ) # => foo
(symbol a 42 nil ) # => foo42nil