Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(loop [x :range [1 10 ]
:let [square (* x x )]
:until (> square 9 )
:before (print "before" )
:after (print "after" )
:repeat 2 ]
(print (string "square: " square )))
# before
# square: 1
# square: 1
# after
# before
# square: 4
# square: 4
# after
# before
# square: 9
# square: 9
# after
(def a @[1 2 ])
(def b @[1 2 ])
(= a b ) # => false
(def a @[1 2 ])
(def b (array/concat a 3 ))
a # => @[1 2 3]
b # => @[1 2 3]
(= a b ) # => true
(repeat 3 (print "HO" ))
# => prints
# HO
# HO
# HO
# removes a file in the current directory
(os/rm "hello.txt" )(forever
(print "and then?" )
(ev/sleep 1 )
(print "no and then!" ))
# => and then?
# sleeps for one second
# => no and then!
# => and then?
# sleeps for one second
# => no and then!
# ... (let [buf @"hello" ]
(buffer/blit buf " there" -1 ))
# =>
@"hello there" # convert a string to an integer
(peg/match '(number :d+ ) "123" )
#=> @[123]
(first (peg/match '(number :d+ ) "123" ))
#=> 123 (apply * [1 2 3 ]) # -> 6
(* (splice [1 2 3 ])) # -> 6
(* ;[1 2 3 ]) # -> 6
(* 1 2 3 ) # -> 6 (mean [1 10 100 ]) # => 37
(mean []) # => nan (buffer ;(interpose " " [:ant 'bee "cat" ``dog`` @`ewe` ]))
# => @"ant bee cat dog ewe" (or true ) # => true
(or true true ) # => true
(or true false ) # => true
(or false 1 2 ) # => 1
(or false 2 1 ) # => 2
(or false nil ) # => nil
(or nil false ) # => false
# note that `or` does not behave as you might expect
# when used with `apply` and `splice`:
(or 1 2 3 ) # => 1
(or (splice [1 2 3 ])) # => (1 2 3)
(apply or [1 2 3 ]) # => (if 1 1 (if 2 2 3))
(last 'hello )
# => 111
(string? "hello" ) # => true
(string? @"hello" ) # => false
(string? :hello ) # => false
(def [pipe-r pipe-w ] (os/pipe ))
(ev/spawn
# write to the pipe in a separate fiber
(for i 0 32000
(def str (string "Hello Janet " i "\n" ))
(:write pipe-w str ))
(:close pipe-w ))
(forever
(def text (:read pipe-r 4096 ))
(when (nil? text ) (break ))
(pp text ))
# read a series of strings from the pipe in parallel
# to writing to the other side, to avoid the program
# from hanging if the pipe is "full"
#
# see https://github.com/janet-lang/janet/issues/1265 (os/which ) # => :macos