| CARVIEW |
Select Language
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Tue, 30 Dec 2025 03:49:51 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
X-XSS-Protection: 1; mode=block
X-Download-Options: noopen
Referrer-Policy: strict-origin-when-cross-origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
Set-Cookie: id=b7633ab8bc5c1db3f064096f6794bb8784c3da185c44f228713fdfda291e06f94f3f16affe386fafeae56766f0dd675c0f025ff37b99811db8f4d2c020f5ac9c43f6149e5c51f3ed3116332dd5638cf90d74a29a; HttpOnly; SameSite=Lax; Path=/
Content-Encoding: gzip
JanetDocs JanetDocsSource PlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in find-indexAlecTroemelPlayground letjgartePlayground stringjgartePlayground commentsogaiuPlayground peg/replacesogaiuPlayground defmacro-jgartePlayground +=btbytesPlayground xprintpepePlayground insogaiuPlayground =cellularmitosisPlayground ->>felixrPlayground partialcellularmitosisPlayground take-untilleobmPlayground mapGeo-7Playground os/clockveqqqPlayground
Community documentation for Janet
Supported Modules
- sqlite3
- primesieve
- jurl
- eleanor
- rlrepl
- marble
- manisha
- jdn-loader
- pq
- shawn
- set
- process
- args
- uri
- fugue
- tsort
- mendoza
- stringx
- trevor
- trolley
- jpm
- temple
- redis
- gapbuffer
- jhydro
- bonzer
- chidi
- j3blocks
- judge
- tester
- base16
- flock
- openssl-hash
- testament
- circlet
- filesystem
- jaylib
- argparse
- base64
- nanoid
- pkgs
- spork
- joy
- miniz
- utf8
- michael
- repl-tools
- bearimy
- date
- kamilah
- hemple
- cmd
- csv
- sh
Loading...
Random examples
(find-index |(= $ "b" ) ["a" "b" "c" "d" ]) #=> 1 (let [sweet "what does mine say?" ]
(let [dude sweet ]
(let [what-does-mine-say? dude ]
what-does-mine-say? ))) # => "what does mine say?"
(string ;(range 12 )) # => "01234567891011" (comment
# the content actually has to parse as janet
# this is ok
(+ 1 1 )
# => 2
# if there is something with missing delimiters though...
)(peg/replace ~(sequence :s (thru "t" ))
" duck"
"smiling cat sleeps" )
# => @"smiling duck sleeps" (defmacro- =dude
"sets any symbolic expression to the atom :what?"
[a ]
~(var a :what? )) # => <function =dude>
(=dude 2 ) # => :what?
(=dude :2 ) # => :what?
(=dude 2 ) # => :what?
(=dude "2" ) # => :what?
(=dude @"2" ) # => :what?
(=dude @[2 ]) # => :what?
(=dude (2 )) # => :what?
(=dude [2 ]) # => :what?
(=dude @{2 3 }) # => :what?
(doc =dude )
# => macro
# => repl on line 59, column 1
# =>
# => (=dude a)
# => nil
# Macro expanding the =dude macro:
(macex (=dude 2 )) # => :what?
(macex1 (=dude 2 )) # => :what?
# Macros have to be quoted in order to expand
(macex ~(=dude 2 )) # => (var a :what?)
(macex1 ~(=dude 2 )) # => (var a :what?)
(macex ~(=dude @{2 3 })) # => (var a :what?)
(do
(var a 88 )
(+= a 12 )) # 100
(def b @"" )
(xprint b "HOHOHO" )
# => nil
b
# => @"HOHOHO\n" (in :yo 0 )
# => 121
# janet 1.10.1
(= :a :a ) # => true
(= :a "a" ) # => false
(= :a ":a" ) # => false
(= "a" "a" ) # => true
(= "a" @"a" ) # => false
(= @"a" @"a" ) # => false
(= [1 2 ] [1 2 ]) # => true
(= [1 2 ] @[1 2 ]) # => false
(= @[1 2 ] @[1 2 ]) # => false
(= {:a 1 } {:a 1 }) # => true
(= {:a 1 } @{:a 1 }) # => false
(= @{:a 1 } @{:a 1 }) # => false
(= (fn []) (fn [])) # => false
(->>
(string/split " " "this is an example yes, an example" )
(filter (complement empty? ))
(frequencies ))
# -> @{"is" 1 "example" 2 "yes," 1 "an" 2 "this" 1}
# same as:
(frequencies
(filter
(complement empty? )
(string/split " " "this is an example yes, an example" )))(def add17 (partial + 17 ))
(add17 3 ) # -> 20
(add17 3 4 ) # -> 24
(map add17 [1 2 3 ]) # -> @[18 19 20]
# uses the fn shorthand
(take-until |(< 3 $ ) [0 1 2 3 4 5 6 7 8 ])
# (0 1 2 3)
# uses partial
(take-until (partial < 3 ) [0 1 2 3 4 5 6 7 8 ])
# (0 1 2 3) (->> (range 10 ) (map (fn [arg ] (* arg arg ))))
# => @[0 1 4 9 16 25 36 49 64 81] (defn bench `Feed bench a wrapped func and int, receive int for time in ns`
[thunk times ]
(def start (os/clock :cputime :tuple ))
(loop [_ :range [times ]]
(thunk ))
(def end (os/clock :cputime :tuple ))
(/ (+ (* (- (end 0 ) (start 0 )) 1e9 )
(- (end 1 ) (start 1 )))
times ))
# it turns out os/clock is pretty darn fast (comparatively)
(def iterations 2000000 )
(bench |(os/clock :cputime :tuple ) iterations ) # 1283.30053 ns
(bench |(slurp "/proc/self/schedstat" ) iterations ) # 7881.451760 ns
# these basically benchmark slurp
(bench |(do (def f (file/open "/proc/self/schedstat" :r ))
(def content (file/read f :all ))
(file/close f ))
iterations ) # 4894.832760 ns
# even without opening and closing the file, reading in Janet's slower than os/clock
(def f (file/open "/proc/self/schedstat" :r ))
(bench |(do (file/seek f :set 0 )
(def content (file/read f :all ))) iterations ) # 1802.511470 ns
(file/close f )
# Of course bench has some overhead, but it's amortized across iterations anyway
(bench (fn []) 10000000 ) # 42.030338 ns