JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

Community documentation for Janet

Supported Modules

Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!

Loading...

Random Examples

> (eprin "there is a boo-boo on line " 33 "\n")
there is a boo-boo on line 33
nil
eprincellularmitosisPlayground
(empty? {})
# => true
empty?sogaiuPlayground
(let [c (ev/chan 1)
      before (ev/count c)]
  (ev/give c :hi)
  [before (ev/count c)])
# =>
'(0 1)
ev/countsogaiuPlayground
(->> (range 10) (map (fn [arg] (* arg arg))))

# => @[0 1 4 9 16 25 36 49 64 81]
mapGeo-7Playground
(from-pairs [[:hello "world"] [:foo "bar"]]) 

# => @{:foo "bar" :hello "world"}
from-pairsjgartePlayground
(var x 5)
(%= x 3)
(pp x) # 2
%=skuzzymigletPlayground
(math/exp 1)  # => 2.71828
math/e        # => 2.71828
math/expcellularmitosisPlayground
(apply * [1 2 3])     # -> 6
(* (splice [1 2 3]))  # -> 6
(* ;[1 2 3])          # -> 6
(* 1 2 3)             # -> 6
applycellularmitosisPlayground
(<)        # -> true
(< 1)      # -> true
(< 1 2)    # -> true
(< 2 1)    # -> false
(< 1 2 3)  # -> true
(< 1 3 2)  # -> false
<cellularmitosisPlayground
(if-let [x true 
         y (not (not x))]
  :a
  :b)
# => :a
if-letsogaiuPlayground
(array 1 2.3 :a "foo" true nil [] {} (fn []))
# => @[1 2.3 :a "foo" true nil () {} <function 0x7FB2A3F02170>]
arraycellularmitosisPlayground
(update @{:data @[:cherry :orange]} :data (comp sorted |(array/push $ :apple)))
# => {:data @[:apple :cherry :orange]}


# note that all data structures must be mutable with @
(def c @{:size :small :roast :dark :add-ins @[:soy :almond :soy]})
(defn add! [coffee extra]
  (update coffee :extras (comp sort |(array/push $ extra))))
(add! c :chocolate)
updateveqqqPlayground
(drop 1 [1 1 2 3 5 8])
# => '(1 2 3 5 8)
dropsogaiuPlayground
(doc doc) # works
(doc* doc) # symbol <function doc> not found
(doc* "doc") # same as (doc doc)
doc*skuzzymigletPlayground
(seq [i :range [0 3]
      j :range [0 3]
      :let [c (string/format "%c" (+ 97 i))]]
  [(keyword c) j])
# => '@[(:a 0) (:a 1) (:a 2) (:b 0) (:b 1) (:b 2) (:c 0) (:c 1) (:c 2)]
seqsogaiuPlayground