Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(string/slice "hello" ) # => "hello"
(string/slice "hello" 0 ) # => "hello"
(string/slice "hello" 1 ) # => "ello"
(string/slice "hello" 4 ) # => "o"
(string/slice "hello" 5 ) # => ""
(string/slice "hello" -1 ) # => ""
(string/slice "hello" -2 ) # => "o"
(string/slice "hello" -5 ) # => "ello"
(string/slice "hello" -6 ) # => "hello"
(string/slice "hello" 1 1 ) # => ""
(string/slice "hello" 1 2 ) # => "e"
(string/slice "hello" 1 5 ) # => "ello"
(string/slice "hello" -5 -4 ) # => "e"
(string/slice "hello" -6 -4 ) # => "he"
(string/slice "hello" 2 1 ) # => ""
(string/slice "hello" -1 -2 ) # => ""
(if-let [x true
y (not x )]
:a
:b )
# => :b
(math/pow 10 3 ) # => 1000
(math/cbrt 1000 ) # => 10 (assert :dude :what? ) # => :dude
(assert :dude :dude ) # => :dude
(assert (= :dude :what? ) "Where's my car?" )
# => error: Where's my car?
# => in _thunk [repl] (tailcall) on line 84, column 1
(assert (= :dude :dude ) "Where's my car?" ) # => true
(array/slice [1 2 3 ])
#=> @[1 2 3]
# good way to convert tuple to array (flatten-into @[1 2 3 ] @[[4 5 6 ] @[7 8 9 ] @[10 11 12 ]]) # => @[1 2 3 4 5 6 7 8 9 10 11 12]
(defmacro- =dude
"sets any symbolic expression to the atom :what?"
[a ]
~(var a :what? )) # => <function =dude>
(=dude 2 ) # => :what?
(=dude :2 ) # => :what?
(=dude 2 ) # => :what?
(=dude "2" ) # => :what?
(=dude @"2" ) # => :what?
(=dude @[2 ]) # => :what?
(=dude (2 )) # => :what?
(=dude [2 ]) # => :what?
(=dude @{2 3 }) # => :what?
(doc =dude )
# => macro
# => repl on line 59, column 1
# =>
# => (=dude a)
# => nil
# Macro expanding the =dude macro:
(macex (=dude 2 )) # => :what?
(macex1 (=dude 2 )) # => :what?
# Macros have to be quoted in order to expand
(macex ~(=dude 2 )) # => (var a :what?)
(macex1 ~(=dude 2 )) # => (var a :what?)
(macex ~(=dude @{2 3 })) # => (var a :what?)
(int/u64 "18446744073709551615" )
# => <core/u64 18446744073709551615> (defn dataframe
``Create an empty dataframe with the given columns``
[& columns ]
(tabseq [c :in columns ] c @[]))(def b @"" )
(xprin b "HOHOHO" )
# => nil
b
# => "HOHOHO" (let [sweet "what does mine say?" ]
(let [dude sweet ]
(let [what-does-mine-say? dude ]
what-does-mine-say? ))) # => "what does mine say?"
(map cfunction? [ even? (fn []) |($ ) file/read -> ])
# => @[ false false false true false ]
# foo.txt is a file with contents "hello\nworld\n".
(slurp "foo.txt" ) # => @"hello\nworld\n"
(string/split "\n" (slurp "foo.txt" )) # => @["hello" "world" ""]
(defn slurp-lines [path ]
(string/split "\n" (slurp path )))
(slurp-lines "foo.txt" ) # => @["hello" "world" ""]
(string/join @["hello" "world" "" ] "\n" ) # => "hello\nworld\n"
(spit "foo2.txt" (string/join @["hello" "world" "" ] "\n" ))
# The contents of foo.txt and foo2.txt are now identical.
(defn spit-lines [path lines ]
(spit path (string/join lines "\n" )))
(spit-lines "foo3.txt" (slurp-lines "foo.txt" ))
# The contents of foo.txt and foo3.txt are now identical.
(string/split "," "bruce,scott,tiger,woods" )
# => @["bruce" "scott" "tiger" "woods"] (math/round 1.1 ) # => 1
(map math/round [1.49 1.50 1.51 ]) # => @[1 2 2]