Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(some even? [1 3 5 7 11 18 ])
# =>
true
(any? "" )
# => nil
(any? "Hello" )
# => 72
(any? @"Hello" )
# => 72
(any? @[])
# => nil
(any? [])
# => nil
(any? {})
# => nil
(any? @{})
# => nil
(any? @[1 2 3 4 ])
# => 1
(any? @{:a 2 :b 3 })
# => 2
(def add17 (partial + 17 ))
(add17 3 ) # -> 20
(add17 3 4 ) # -> 24
(map add17 [1 2 3 ]) # -> @[18 19 20]
(math/floor 1.1 ) # => 1
(map math/floor [1.1 1.2 1.3 ]) # => @[1 1 1]
(def b @"" )
(xprin b "HOHOHO" )
# => nil
b
# => "HOHOHO" (scan-number "111" 2 )
# => 7
(/ 0 )
# => inf
(seq [i :range [0 3 ]
j :range [0 3 ]]
[(keyword (string/format "%c" (+ 97 i )))
j ])
# => '@[(:a 0) (:a 1) (:a 2) (:b 0) (:b 1) (:b 2) (:c 0) (:c 1) (:c 2)] (if-let [x true
y (not x )]
:a
:b )
# => :b
(last "hello" )
# => 111
(defn eval-string
``Evaluates a string in the current environment. If more control over the
environment is needed, use `run-context`.``
[str ]
(var state (string str ))
(defn chunks [buf _ ]
(def ret state )
(set state nil )
(when ret
(buffer/push-string buf str )
(buffer/push-string buf "\n" )))
(var returnval nil )
(run-context {:chunks chunks
:on-compile-error (fn compile-error [msg errf & ]
(error (string "compile error: " msg )))
:on-parse-error (fn parse-error [p x ]
(error (string "parse error: " (:error p ))))
:fiber-flags :i
:on-status (fn on-status [f val ]
(if-not (= (fiber/status f ) :dead )
(error val ))
(set returnval val ))
:source :eval-string })
returnval )
(- ;(range 10 ))
# => -45 (->>
(string/split " " "this is an example yes, an example" )
(filter (complement empty? ))
(frequencies ))
# -> @{"is" 1 "example" 2 "yes," 1 "an" 2 "this" 1}
# same as:
(frequencies
(filter
(complement empty? )
(string/split " " "this is an example yes, an example" )))(defn get-time-str []
(let [{:hours h :minutes m :seconds s } (os/date )]
(string h ":" m ":" s )))
(get-time-str ) => "23:18:16" # :when modifier argument example
(let [even-numbers @[]]
(loop [i :range [0 50 ] :when (even? i )]
(array/push even-numbers i ))
even-numbers )
# => @[0 2 4 6 8 10 12 14 16 1.....]