Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
# `parse` can decode arbitrary JDN (Janet Data Notation) encoded by `string/format`
(def encoded (string/format "%j" @{:a 123 :b "foo" :c @{1 [1.2 2.3 3.4 ]}}))
# => "@{:a 123 :b \"foo\" :c @{1 @[1.2 2.2999999999999998 3.3999999999999999]}}"
(parse encoded )
# => @{:a 123 :b "foo" :c @{1 @[1.2 2.3 3.4]}} (def f (generate [i :range [0 5 ]] (+ i i )))
(print (fiber/status f ))
(print (resume f ))
(print (resume f ))
(print (resume f ))
(print (resume f ))
(print (resume f ))
(print (fiber/status f )) # -> :pending
(print (resume f ))
(print (fiber/status f )) # -> :dead
# :new
# 0
# 2
# 4
# 6
# 8
# :pending
#
# :dead (def b @"" )
(xprint b "HOHOHO" )
# => nil
b
# => @"HOHOHO\n" (map truthy? [ nil false true 0 1 'a :a "a" [] {} (fn []) ])
# => @[ false false true true true true true true true true true ]
# note that 'not' works as an implementation of 'falsey?'
(map not [ nil false true 0 1 'a :a "a" [] {} (fn []) ])
# => @[ true true false false false false false false false false false ]
(os/mkdir "templates" )
# => creates ./templates directory (sort (keys default-peg-grammar ))
# => @[:A :D :H :S :W :a :a* :a+ :d :d* :d+ :h :h* :h+ :s :s* :s+ :w :w* :w+] (protect
(if (> (math/random ) 0.42 )
(error "Good luck" )
"Bad luck" ))
# => randomly returns:
# (false "Good luck")
# or
# (true "Bad luck") # demo of (@ <sym>) feature
(let [content "# => label" ]
(match [:comment @{} "# => label" ]
[:comment _ (@ content )]
:found
nil ))
# => :found (try
(error :fun )
([e ]
(= e :fun )))
# => true
(string/replace "+" "-" "ctrl+c" )
# => "ctrl-c" (do
(def before (dyn :expression ))
(setdyn :expression :smile )
[before (dyn :expression )])
# => '(nil :smile) (def name "Joe" )
(when (= name "Joe" ) "Hello Joe" )
# "Hello Joe"
(when (not= 1 2 ) "not-equal" )
# "not-equal"
(os/shell "echo bar > /tmp/foo" )
(with
[file-handle
(file/open "/tmp/foo" )
(fn [fd ] (file/close fd ))]
(file/read file-handle :all )) # => @"bar\n"
(def a @[1 2 3 ])
(def b (array/slice a ))
#=> good way to clone array, a and b are different arrays (buffer/bit @"0" 4 )
# => true