Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(peg/find ':d "Battery temperature: 40 °C" )
# => 21 index of the first number (string/ascii-upper "hello" ) # => "HELLO" (def a @[])
(array/insert a 1 :a ) # error: index out of range
(array/insert a -2 :a ) # error: index out of range
# janet 1.10.1
# note that os/cd does not appear to update PWD in the shell's environment.
(os/cwd ) # => "/Users/cell/tmp"
(os/getenv "PWD" ) # => "/Users/cell/tmp"
(os/cd "/tmp" ) # => nil
(os/cwd ) # => "/private/tmp" (on Apple, /tmp is actually /private/tmp)
(os/getenv "PWD" ) # => "/Users/cell/tmp"
(defn unix->date-label
``Format a unix timestamp as date or datetime string``
[ts ]
(let [d (os/date ts )]
(if (or (pos? (d :hours )) (pos? (d :minutes )))
(string/format "%d-%02d-%02d %02d:%02d"
(d :year ) (d :month ) (d :month-day )
(d :hours ) (d :minutes ))
(string/format "%d-%02d-%02d"
(d :year ) (d :month ) (d :month-day )))))(one? (math/next 1 math/inf )) # => false (array/pop @[]) # => nil (defn walker
`Simple walker function, that prints non-sequential
members of the form or prints "Sequence" and walks
recursively sequential members of the tree.`
[form ]
(if (or (indexed? form ) (dictionary? form ))
(do (print "Sequence" )
(walk walker form ))
(print form )))
(walk walker [[[[0 1 3 ]] 16 7 [3 [3 5 ]] 3 4 ] 1 [3 4 ]])
# Prints
# Sequence
# Sequence
# Sequence
# 0
# 1
# 3
# 16
# 7
# Sequence
# 3
# Sequence
# 3
# 5
# 3
# 4
# 1
# Sequence
# 3
# 4
(freeze @{:a @[1 2 ]
:b @{:x @[8 9 ]
:y :smile }})
# => {:a (1 2) :b {:x (8 9) :y :smile}} (forever
(print (os/time ))
(ev/sleep 1 ))
# => epoch clocks, prints epoch timestamp every second (def b @"" )
(def v (* 1000 (math/random )))
# => 487.181 your number can differ
(xprinf b "Value reached level %f" v )
# => nil
b
# => @"Value reached level 487.181188" (find |(= 2 $ ) {:a 1 :b 2 :c 3 })
# => 2
(get @"Hello" 1 )
# => 101
(find |(= 101 $ ) @"Hello" )
# => 101
(find |(> $ 3 ) {:a 1 :b 2 :c 3 })
# => nil (os/shell "uptime > /tmp/uptime.txt" ) # => 0
(slurp "/tmp/uptime.txt" )
# => @"22:33 up 5 days, 9:34, 15 users, load averages: 1.93 1.74 1.59\n"
(os/rm "/tmp/uptime.txt" ) # => nil (string/format "%f" (os/clock )) # => "1627746483.991000" (any? [false false nil ]) => nil
(any? [false false nil 1 ]) => 1
(any? [false false nil true ]) => true