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

(map cfunction? [ even?  (fn [])  |($)   file/read  ->    ])
# =>           @[ false  false    false  true       false ]
cfunction?cellularmitosisPlayground
math/int32-max # => 2147483647
math/int32-maxjgartePlayground
(string/find-all "duck" "duck duck duck goose!") # => @[0 5 10]
string/find-allsogaiuPlayground
(os/time)  # => 1593837535
os/timecellularmitosisPlayground
(cmp 0.0 0)
# => 0
cmpsogaiuPlayground
# Note: the numbers may appear the same, but this is only due to printing truncation.
1                             # => 1
(math/next 1 math/inf)        # => 1
(< 1 1)                       # => false
(< 1 (math/next 1 math/inf))  # => true
math/nextcellularmitosisPlayground
(assert :dude :what?) # => :dude

(assert :dude :dude) # => :dude

(assert (= :dude :what?) "Where's my car?")
# => error: Where's my car?
# =>  in _thunk [repl] (tailcall) on line 84, column 1

(assert (= :dude :dude) "Where's my car?") # => true

assertjgartePlayground
(string/bytes "hello") # => (104 101 108 108 111)
string/bytesswlkrPlayground
(defn to-double-digit-string [digit]
  (string/slice (string "0" digit) -3))

(defn get-date-time-string [time]
  (let [date (os/date time)
        year (get date :year)
        month (to-double-digit-string (get date :month))
        day (to-double-digit-string (get date :month-day))
        hours (to-double-digit-string (get date :hours))
        minutes (to-double-digit-string (get date :minutes))
        seconds (to-double-digit-string (get date :seconds))]
    (string year "-" month "-" day "__" hours ":" minutes ":" seconds)))

(defn get-current-date-time-string []
  (get-date-time-string (os/time)))


### USAGE

(get-current-date-time-string)
# => "2020-09-23__17:20:00"
os/dateharryvederciPlayground
(string/reverse "hello") # => "olleh"
string/reverseswlkrPlayground
(update-in @{:a @{:b 1}} [:a :b] (fn [x] (+ 1 x)))
# @{:a @{:b 2}}
update-insbjaverPlayground
(invert "yo")
# => @{111 1 121 0}
invertsogaiuPlayground
(print :hi ` ` "there" @`` `` @"mate")
# => nil
printsogaiuPlayground
(freeze @"Ho") #=> "Ho"
(freeze ["Ho"]) #=> ("Ho")
(freeze @["Ho"]) #=> ("Ho")
(freeze @{"Ho" "Ho"}) #=> {"Ho" "Ho"}
freezepepePlayground
(array/pop @[]) # => nil
array/popjgartePlayground