Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(count even? [1 2 3 4 5 ]) # => 2
(count (fn [x ] (> x 3 )) [1 2 3 4 5 ]) # => 2
(count |(> $ 3 ) [1 2 3 4 5 ]) # => 2
(count (fn [x ] (truthy? x )) [nil false true 42 :a "foo" ]) # => 4
(count |(truthy? $ ) [nil false true 42 :a "foo" ]) # => 4
(var f even? )
(count f [1 2 3 4 5 ]) # => 2
(set f odd? )
(count f [1 2 3 4 5 ]) # => 3
(map (fn [f ] (count f [1 2 3 4 5 ])) [even? odd? ]) # => @[2 3]
(map |(count $ [1 2 3 4 5 ]) [even? odd? ]) # => @[2 3]
(buffer/bit-set @"hahaha" 3 ) # => @"hahaha"
(buffer/bit-set @"what" 3 ) # => @"\x7Fhat"
(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 (in "yo" 0 )
# => 121
(mean [1 10 100 ]) # => 37
(mean []) # => nan (pp (all-bindings ))
# => prints @[% %= * ... yield zero? zipcoll]
(def a "A" )
(pp (all-bindings (curenv ) true ))
# => prints @[_ a] - only local bindings are listed # 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 )))(def a @[1 2 ])
(def b @[1 2 ])
(= a b ) # => false
(def a @[1 2 ])
(def b (array/concat a 3 ))
a # => @[1 2 3]
b # => @[1 2 3]
(= a b ) # => true
(get default-peg-grammar :h )
# => '(range "09" "af" "AF") (cmp [1 2 ] [1 2 3 ])
# => -1
(var x 1 )
(loop [n :range-to [1 5 ]]
(*= x n ))
x # => 120 (import joy )
# given a handler
(defn handle-func [request ]
(joy/text/plain (string "Hi " ((request :params ) :name ))))
# joy/routes will make handlers
(def r (joy/routes [:get "/hi/:name" :handle-func ]))
# which you can pass to joy/app
(joy/server (joy/app {:routes r }) 9002 )
# visit at localhost:9002/hi/bob (pairs {:a 1 :b 2 :c 3 })
# =>
@[(:c 3 ) (:a 1 ) (:b 2 )]## Quadratic Formula
(defn qform
"Use the quadratic formula to solve for x. Returns all real solutions."
[a b c ]
(def det (- (* b b ) (* 4 a c )))
(def factor (/ 0.5 a ))
(cond
(neg? det ) []
(zero? det ) [(* factor (- b ))]
(let [root-det (math/sqrt det )]
[(* factor (- (- b ) root-det )) (* factor (+ (- b ) root-det ))])))
(qform 1 4 3 ) # -> (-3 -1)
(< ) # -> true
(< 1 ) # -> true
(< 1 2 ) # -> true
(< 2 1 ) # -> false
(< 1 2 3 ) # -> true
(< 1 3 2 ) # -> false