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

(neg? -42)  # => true
(map neg? [-1 0 1])  # => @[true false false]
neg?cellularmitosisPlayground
(cmp 0.0 0)
# => 0
cmpsogaiuPlayground
# janet 1.10.1

(=       [1 1]   [1 1])  # => true
(=       [1 1]   [2 3])  # => false
(=       [1 1]  @[1 1])  # => false
(=       [1 1]  @[2 3])  # => false
(=      @[1 1]  @[1 1])  # => false
(=      @[1 1]  @[2 3])  # => false

(deep=   [1 1]   [1 1])  # => true
(deep=   [1 1]   [2 3])  # => false
(deep=   [1 1]  @[1 1])  # => false
(deep=   [1 1]  @[2 3])  # => false
(deep=  @[1 1]  @[1 1])  # => true
(deep=  @[1 1]  @[2 3])  # => false
=cellularmitosisPlayground
(var a 0)
(assert (pos? a) "A is definitely not positive")
# error: A is definitely not positive
#  in assert [boot.janet] on line 149, column 11
#  in _thunk [repl] (tailcall) on line 3, column 1
assertpepePlayground
path/delim # => ":" on Unix and Linux, ";" on Windows
spork/path/delimclementiPlayground
(def a @[1 2])
(array/concat a 3 [4 5] @[6 7] [] @[] 8)
a  # => @[1 2 3 4 5 6 7 8]
array/concatcellularmitosisPlayground
(->
  {:a [1 2 3] :b [4 5 6]}
  (get :a)
  (sum)
  (string " is the result"))
# -> "6 is the result"

# same as:
(string (sum (get {:a [1 2 3] :b [4 5 6]} :a))" is the result")
->felixrPlayground
(def request {:params {:id 1}}) # => {:params {:id 1}}

(get-in request [:params :id]) # => 1

(get-in request [:params :name]) # => nil

(get-in request [:params :name] "N/A") # => "N/A"
get-ininchingforwardPlayground
(filter (fn [x] (> x 2)) [1 2 3 4 5])  # @[3 4 5]
filterbtbytesPlayground
(math/ceil 1.1)  # => 2
(map math/ceil [1.1 1.2 1.3])  # => @[2 2 2]
math/ceilcellularmitosisPlayground
(<= 1 2 3) # => true
(<= 1 2 1) # => false
<=pepePlayground
(eachk k {:a "a val" :b "b val" :c "c val"} (print k))
# prints c
# prints a
# prints b
eachkpepePlayground
(in :yo 0)
# => 121
insogaiuPlayground
(map number? [nil   true  42   :a    "a"   []    {}    (fn []) ])
# =>        @[false false true false false false false false   ]
number?cellularmitosisPlayground
(map bytes?      [ 'ab   :ab   "ab"   @"ab"  [97 98]  @[97 98]  {0 97 1 98}  @{0 97 1 98}  ])
# =>            @[ true  true  true   true   false    false     false        false         ]

(map symbol?     [ 'ab   :ab   "ab"   @"ab"  [97 98]  @[97 98]  {0 97 1 98}  @{0 97 1 98}  ])
# =>            @[ true  false false  false  false    false     false        false         ]

(map keyword?    [ 'ab   :ab   "ab"   @"ab"  [97 98]  @[97 98]  {0 97 1 98}  @{0 97 1 98}  ])
# =>            @[ false true  false  false  false    false     false        false         ]

(map string?     [ 'ab   :ab   "ab"   @"ab"  [97 98]  @[97 98]  {0 97 1 98}  @{0 97 1 98}  ])
# =>            @[ false false true   false  false    false     false        false         ]

(map buffer?     [ 'ab   :ab   "ab"   @"ab"  [97 98]  @[97 98]  {0 97 1 98}  @{0 97 1 98}  ])
# =>            @[ false false false  true   false    false     false        false         ]
symbol?cellularmitosisPlayground