Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(os/shell "touch foo" )
(os/stat "foo" :modified ) # => 1593836002
(os/touch "foo" )
(os/stat "foo" :modified ) # => 1593836013 (let [c0 (ev/chan )
c1 (ev/chan 1 )]
[(ev/capacity c0 ) (ev/capacity c1 )])
# => '(0 1) (math/exp2 8 ) # => 256
(def a @[1 2 ])
(def b @[1 2 ])
(= a b ) # => false
(def a @[1 2 ])
(def b (array/concat a 3 ))
a # => @[1 2 3]
b # => @[1 2 3]
(= a b ) # => true
# sorted allocates the full memory of its input
(def d2 (range 10000000 0 -1 )) # 87mb
(sorted d2 ) # now 167 mb # wrap short-fn / |
(-> 10
(|(/ $ 2 )))
# =>
5
# also wrap fn
(-> 10
((fn [n ] (/ n 2 ))))
# =>
5 (peg/match ~{:main (capture (some :S ))}
"hello world" )
# => @["hello"] (type print )
# =>
:cfunction (map |($ {:a 7 :b 8 } ) [ keys values kvs pairs ])
# => @[ @[:a :b] @[7 8] @[:a 7 :b 8] @[(:a 7) (:b 8)] ]
(map |($ [4 5 6 ] ) [ keys values kvs pairs ])
# => @[ @[0 1 2] @[4 5 6] @[0 4 1 5 2 6] @[(0 4) (1 5) (2 6)] ]
(map |($ 'ab ) [ keys values kvs pairs ])
# => @[ @[0 1] @[97 98] @[0 97 1 98] @[(0 97) (1 98)] ]
(map |($ :ab ) [ keys values kvs pairs ])
# => @[ @[0 1] @[97 98] @[0 97 1 98] @[(0 97) (1 98)] ]
(map |($ "ab" ) [ keys values kvs pairs ])
# => @[ @[0 1] @[97 98] @[0 97 1 98] @[(0 97) (1 98)] ]
(drop-while |(> 3 $ ) [0 1 2 3 4 5 6 7 8 ])
# => (3 4 5 6 7 8) (update-in @{:a @{:b 1 }} [:a :b ] (fn [x ] (+ 1 x )))
# @{:a @{:b 2}}
(let [buf @"hello" ]
(buffer/blit buf " there" -1 ))
# =>
@"hello there" @[1 2 3] # -> @[1 2 3]
(array 1 2 3) # -> @[1 2 3]
(array (splice [1 2 3]) # -> @[1 2 3]
(array ;[1 2 3]) # -> @[1 2 3]
# more at https://github.com/sogaiu/margaret/tree/master/examples
(peg/match ~{:main (replace (some :header-line )
,(fn [& captures ]
(table ;captures )))
:header-line (sequence (capture :header-name ) ":"
:s+
(capture :header-value ) :crlf )
:header-name (to ":" )
:header-value (to :crlf )
:crlf "\r\n" }
(string "Content-Type: text/plain\r\n"
"Content-Length: 1024\r\n" ))
# => @[@{"Content-Length" "1024" "Content-Type" "text/plain"}]
(< ) # -> true
(< 1 ) # -> true
(< 1 2 ) # -> true
(< 2 1 ) # -> false
(< 1 2 3 ) # -> true
(< 1 3 2 ) # -> false