Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(let [x 10 ]
(unless (= x 10 )
(print "x is not 10!" )
)
)
# => nil
(let [x 5 ]
(unless (= x 10 )
(print "x is not 10!" )
)
)
# => "x is not 10!" (inc 42 ) # => 43
(map inc [1 2 3 ]) # => @[2 3 4]
(net/address "0.0.0.0" 80 ) # => <core/socket-address 0x55CABA438E90>
(net/address "0.0.0.0" 8989 ) # => <core/socket-address 0x55CABA439980>
(put-in @{:a @{:aa 5 } :b @{:bb 6 }} [:c ] 9 ) # => @{:a @{:aa 5} :b @{:bb 6} :c 9}
(put-in @{:a @{:aa 5 } :b @{:bb 6 }} [:a :aa ] 9 ) # => @{:a @{:aa 9} :b @{:bb 6}}
(put-in @{:a @{:aa 5 } :b @{:bb 6 }} [:a :cc :ddd ] 9 ) # => @{:a @{:cc @{:ddd 9} :aa 5} :b @{:bb 6}}
(put-in @[:a :b @[:aa :bb :cc ]] [2 1 ] :zz ) # => @[:a :b @[:aa :zz :cc]]
(put-in @[:a :b @[:aa :bb :cc ]] [5 ] :z ) # => @[:a :b @[:aa :bb :cc] nil nil :z]
(put-in @[:a :b @[:aa :bb :cc ]] [4 0 ] :zz ) # => @[:a :b @[:aa :bb :cc] nil @{0 :zz}]
(put-in @[:a :b @[:aa :bb :cc ]] [4 :yy ] :zz ) # => @[:a :b @[:aa :bb :cc] nil @{:yy :zz}]
(math/pow 10 3 ) # => 1000
(math/cbrt 1000 ) # => 10 # janet 1.10.1
(all pos? [1 2 3 ]) # => true
(all pos? [1 2 3 -4 ]) # => false
(all pos? [1 2 3 0 ]) # => false
(all (partial string/has-prefix? "a" ) ["aa" "ab" ]) # => true
(all (partial string/has-prefix? "a" ) ["aa" "ab" "bb" ]) # => false
(all truthy? [1 2 ]) # => true
(all truthy? [1 2 3 ]) # => true
(all truthy? [1 2 nil 3 ]) # => false
(all truthy? [1 false 2 nil 3 ]) # => false
(all (fn [x ] x ) [1 2 ]) # => 2
(all (fn [x ] x ) [1 2 3 ]) # => 3
(all (fn [x ] x ) [1 2 nil 3 ]) # => nil
(all (fn [x ] x ) [1 false 2 nil 3 ]) # => false
(array/slice @[1 2 3 ] 0 0 ) # => @[]
(array/slice @[1 2 3 ] 0 1 ) # => @[1]
(array/slice @[1 2 3 ] 0 2 ) # => @[1 2]
(array/slice @[1 2 3 ] 0 3 ) # => @[1 2 3]
(array/slice @[1 2 3 ] 0 4 ) # error: index out of range
(array/slice @[1 2 3 ] 1 1 ) # => @[]
(array/slice @[1 2 3 ] 1 2 ) # => @[2]
(array/slice @[1 2 3 ] 0 -1 ) # => @[1 2 3]
(array/slice @[1 2 3 ] 0 -2 ) # => @[1 2]
(array/slice @[1 2 3 ] 0 -3 ) # => @[1]
(array/slice @[1 2 3 ] 0 -4 ) # => @[]
(array/slice @[1 2 3 ] 0 -5 ) # error: index out of range
(defn slurp-lines [path ]
(string/split "\n" (slurp path )))(keyword "" )
# => : # slice with strings
(slice "Hello" 1 ) # => "ello"
(slice "Playing" 0 -4 ) # => "Play"
(slice "Playing" -4 ) # => "ing"
# slice with keyword
(slice :hello 1 ) # => "ello" (map idempotent? [ nil true 97 'a :a "a" ])
# => @[ true true true true true true ]
(map idempotent? [ [97 ] @[97 ] {0 97 } @{0 97 } ])
# => @[ false false false false ]
(map idempotent? [ (fn []) even? loop file/open ])
# => @[ true true true true ]
(map idempotent? [ (file/temp ) (fiber/new (fn [])) ])
# => @[ true true ]
(os/perm-string 420 ) # => "rw-r--r--"
(os/perm-string 8r644 ) # => "rw-r--r--"
(os/perm-string 493 ) # => "rwxr-xr-x"
(os/perm-string 8r755 ) # => "rwxr-xr-x"
(string/bytes "foo" ) # => (102 111 111)
(string/from-bytes 102 111 111 ) # => "foo"
(string/from-bytes (splice (string/bytes "foo" ))) # => "foo"
(map (fn [x ] x ) "foo" ) # => @[102 111 111]
(map string/from-bytes "foo" ) # => @["f" "o" "o"]
(defn string/explode [s ] (map string/from-bytes s ))
(string/explode "foo" ) # => @["f" "o" "o"]
(map number? [nil true 42 :a "a" [] {} (fn []) ])
# => @[false false true false false false false false ]
(invert [(chr "y" ) (chr "o" )])
# => @{111 1 121 0}