Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(interpose 0 [1 2 3 ])
# -> @[1 0 2 0 3] (map type [nil true 42 [] @[] {} @{} "a" @"b" 'c :d identity (fn [])])
# => @[:nil :boolean :number :tuple :array :struct :table :string :buffer :symbol :keyword :function :function]
janet:2:> (all true? [true true false ])
false
janet:3:> (all even? [2 4 6 7 ])
false
janet:5:> (all even? [2 4 6 ])
true (defn capitalize [str ]
(string (string/ascii-upper (string/slice str 0 1 )) (string/slice str 1 )))(os/time ) # => 1593837535 (all-dynamics )
# => @[:args :err-color :executable :peg-grammar :pretty-format :syspath]
(setdyn :fixed true )
(all-dynamics )
# => @[:args :err-color :executable :fixed :peg-grammar :pretty-format :syspath] (os/shell "seq 12 | head -n 1" ) # => 1 (empty? : )
# => true (spit "/tmp/hello.sh" "#!/bin/bash\necho 'Hello from Bash!'\n" )
(os/chmod "/tmp/hello.sh" "rwx------" )
(os/setenv "PATH" (string (os/getenv "PATH" ) ":/tmp" ))
(os/shell "hello.sh" )You can see janet datastructure values by typing:
(string/format "%q" {:a 1 :b 2 }) # => {:a 1 :b 2} (bxor 3 6 ) # => 5
# 011 (3)
# xor 110 (6)
# -------
# 101 (5)
(string/join @["alice" "bob" "eve" ] "\t" )
# => "alice\tbob\teve" (math/log (* math/e math/e )) # => 2
(math/log2 256 ) # => 8
(math/log10 1000 ) # => 3
(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)] ]
(map length [ 'a :a "a" [97 ] @[97 ] {0 97 } @{0 97 } ])
# => @[ 1 1 1 1 1 1 1 ]