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

(filter (fn [x] (> x 2)) [1 2 3 4 5])  # @[3 4 5]
filterbtbytesPlayground
math/int32-max # => 2147483647
math/int32-maxjgartePlayground
(nan? 1)  # => false
(nan? (/ 0 0))  # => true
(nan? (sqrt -1))  # => true
nan?cellularmitosisPlayground
(os/time)  # => 1593837535
os/timecellularmitosisPlayground
(def a @[1 6])                     # => @[1 6]
(array/insert a 1 (splice [2 3]))  # => @[1 2 3 6]
(array/insert a 3 ;[4 5])          # => @[1 2 3 4 5 6]
array/insertcellularmitosisPlayground
(merge {:a 1 :b 2} 
       {:c 3 :a 4})
# -> @{:c 3 :a 4 :b 2}
mergeKrasjetPlayground
# build own map-indexed with map

(defn map-indexed [f ds]
    (map f (range 0 (length ds)) ds))

(map-indexed (fn [i v] [i v] ) ["a" "b" "c" "d"])

# => @[(0 "a") (1 "b") (2 "c") (3 "d")]
mapleobmPlayground
# removes a file in the current directory
(os/rm "hello.txt")
os/rmswlkrPlayground
(string/replace-all "e" "o" "feed")
# =>
"food"
string/replace-allsogaiuPlayground
(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         ]
string?cellularmitosisPlayground
(type (fiber/new (fn [])))
# =>
:fiber
typesogaiuPlayground
(let [seed 0]
  (= (math/rng-uniform (math/rng seed))
     (math/rng-uniform (math/rng seed))))
# => true
math/rng-uniformsogaiuPlayground
# :as sets a /

(import /deeper/inside :prefix "" :export true)
# @{_ @{:value <cycle 0>} cat @{:private false}}
(import /deeper/inside :as "" :export true)
# @{/cat @{:private false} _ @{:value <cycle 0>} cat @{:private false}}

importveqqqPlayground
(mapcat
  |[$0 $1 (* $0 $1)]
  [1 2 3]
  [100 200 300])
# => @[1 100 100 2 200 400 3 300 900]
mapcattaoeffectPlayground
(when-let [root   (math/sqrt 64) 
           unused (even? root)] 
         (printf "%d is even" root))
# -> "8 is even"
when-letfelixrPlayground