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

(last "hello")
# => 111
lastsogaiuPlayground
(map type [nil true 42 [] @[] {} @{} "a" @"b" 'c :d identity (fn [])])
# => @[:nil :boolean :number :tuple :array :struct :table :string :buffer :symbol :keyword :function :function]
typecellularmitosisPlayground
(fiber? (fiber/new (fn [])))
# => true
fiber?sogaiuPlayground
(os/shell "uptime > /tmp/uptime.txt")  # => 0
(slurp "/tmp/uptime.txt")
# => @"22:33  up 5 days,  9:34, 15 users, load averages: 1.93 1.74 1.59\n"
(os/rm "/tmp/uptime.txt")  # => nil
os/readlinkcellularmitosisPlayground
(put (table) :a 1) # => @{:a 1}
putsogaiuPlayground
(map boolean? [true false nil   0     1    ])
# =>         @[true true  false false false]
boolean?cellularmitosisPlayground
# Note that the earlier sort func is executed later

(update @{:data @[:cherry :orange]} :data (comp sort |(array/push $ :apple)))
# => @{:data @[:apple :cherry :orange]}
compveqqqPlayground
# https://en.wikipedia.org/wiki/Error_function
(math/erf 1)
# => 0.842701
math/erfsogaiuPlayground
(net/address "0.0.0.0" 80) # => <core/socket-address 0x55CABA438E90>

(net/address "0.0.0.0" 8989) # => <core/socket-address 0x55CABA439980>

net/addressjgartePlayground
(let [a 1 b 2 c 3] (+ a b c))  # => 6

(let
  [a 1
   b (+ a 1)
   c (+ b 1)]
  (+ a b c))  # => 6
letcellularmitosisPlayground
In order to use :fresh, write:
(import path :fresh true)
importSaikyunPlayground
(math/atan 1)    # 0.785398
(math/atan 0.5)  # 0.463648
math/atanbtbytesPlayground
(take 2 [1 -2 2 3 9 -10])  # (1 -2)
takebtbytesPlayground
(freeze @{:a @[1 2] 
          :b @{:x @[8 9] 
               :y :smile}})
# => {:a (1 2) :b {:x (8 9) :y :smile}}
freezesogaiuPlayground
(int/u64 42)    # => <core/u64 42>
(int/u64 42.1)  # => <core/u64 42>
(int/u64 "42")  # => <core/u64 42>
int/u64cellularmitosisPlayground