Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
# sorted allocates the full memory of its input
(def d2 (range 10000000 0 -1 )) # 87mb
(sorted d2 ) # now 167 mb (mean [1 10 100 ]) # => 37
(mean []) # => nan (distinct [1 1 2 3 ]) # => @[1 2 3]
(distinct "hello" ) # => @[104 101 108 111]
(string/from-bytes (splice (distinct "hello" ))) # => "helo"
(get (os/environ ) "HOME" ) # => "/Users/cell"
(os/getenv "HOME" ) # => "/Users/cell"
(find-index |(= $ "b" ) ["a" "b" "c" "d" ]) #=> 1 (defn read-from-file [file-path ]
(let [f (file/open file-path :r )
content (file/read f :all )]
(file/close f )
content ))
### USAGE
(read-from-file "/path/to/file-read-example.janet" )
# => @"(defn read-from-file [file-path]\n (let [f (file/open file-path :r)\n content (file/read f :all)]\n (file/close f)\n content))\n" (take-while number?
(fiber/new
|(each x [1 2 3 :hi ]
(yield x ))))
# => @[1 2 3] (last [1 1 2 3 5 8 ])
# => 8
(get [4 5 6 ] -1 ) # => nil
(in [4 5 6 ] -1 42 ) # error
(get-in [4 5 6 ] [-1 ] 42 ) # => 42
(get {:a 1 } -1 ) # => nil
(in {:a 1 } -1 42 ) # => 42
(get-in {:a 1 } [-1 ] 42 ) # => 42 (math/hypot 1 1 ) # => 1.41421
(math/sqrt 2 ) # => 1.41421
(> 12 11 10 9 8 7 6 5 4 3 2 1 ) # => true
(> 12 11 10 9 8 7 6 5 4 3 2 9 ) # => false # due to 0 indexing, you will often want to add 1 to things:
(defn short-date [d ]
(let [{:year y :month mon :month-day d } d ]
(string y "-" (+ 1 mon ) "-" (+ 1 d ))))
# Makes os/date like 2025-12-25
(short-date (os//date ))
# From: https://codeberg.org/veqq/deforester/src/branch/master/deforester.janet
(defn- time-string
``Gives current time as ISO 8601 string: 2025-10-12T11:43:14 https://en.wikipedia.org/wiki/ISO_8601
This accounts for `os/date` 0-indexing month and days which are 1-indexed in ISO 8601.``
[]
(let [{:year y :month mon :month-day d :hours h :minutes min :seconds s } (os/date )]
(string y "-" (+ 1 mon ) "-" (+ 1 d ) "T" h ":" min ":" s )))(if-let [x true
y (not x )]
:a
:b )
# => :b
(math/log (* math/e math/e )) # => 2
(math/log2 256 ) # => 8
(math/log10 1000 ) # => 3
(chr "a" ) # => 97