Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(nan? 1 ) # => false
(nan? (/ 0 0 )) # => true
(nan? (sqrt -1 )) # => true (get (os/environ ) "HOME" ) # => "/Users/cell"
(os/getenv "HOME" ) # => "/Users/cell"
Math. Seedrandom (3206 )(def a @[1 2 3 ])
(array/fill a 17 ) # => @[17 17 17]
(array/fill a "n" ) # => @["b" "b" "b"]
(array/fill a ) # => @[nil nil nil]
a # => @[nil nil nil]
(last 'hello )
# => 111
(def a @[1 2 ])
(array/concat a 3 [4 5 ] @[6 7 ] [] @[] 8 )
a # => @[1 2 3 4 5 6 7 8]
(defn return-nil [x ] nil )
(-?> 1 inc ) # -> 2
(-?> 1 inc inc ) # -> 3
(-?> 1 inc inc return-nil ) # -> nil
(-?> 1 inc inc return-nil inc ) # -> nil
# create a channel without buffer, default is 0
(def channel (ev/chan ))
(ev/spawn
(ev/sleep 5 )
(ev/give channel "Hard work is done!" ))
(print "do anything" )
(for i 0 5
(print i )
(ev/sleep 0.5 ))
(print (ev/take channel )) # blocks here, until there is a result in the channel
(print "done" )
(compare> 1 0 ) # => true
(compare> 10 9.9 ) # => true
(compare> :a :b ) # => false
(compare> :b :a ) # => true # There is a list of formatters here: https://janet-lang.org/capi/writing-c-functions.html
(string/format "With terminal colors: %M" [:array {:key-in "struct" }]) # => "With terminal colors: (\e[33m:array\e[0m {\e[33m:key-in\e[0m \e[35m\"struct\"\e[0m})"
(invert [:ant :bee :elephant :fox :penguin ])
# => @{:bee 1 :fox 3 :elephant 2 :ant 0 :penguin 4} (bor 1 2 4 ) # => 7
(bor 7 12 ) # => 15
# 0111 (7)
# or 1100 (12)
# -------
# 1111 (15)
# janet 1.10.1
# non-numeric values appear to always be greater than numeric values
(< math/inf nil ) # -> true
(< math/inf true ) # -> true
(< math/inf false ) # -> true
(< math/inf "hello" ) # -> true
(< math/inf :heyo ) # -> true
(< math/inf (fn [])) # -> true
(< math/inf {:a 1 }) # -> true
# non-numeric values also follow an ordering.
# rearranging any of these values turns the result false:
(< nil false true "a" "b" :a :b [] [1 ] [1 1 ] [2 ] {} {:a 1 } (fn [])) # -> true
(buffer/bit (buffer/new-filled 1 (chr "0" )) 4 )
# => true
(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)] ]