Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(comment this is a
multiline line comment.
It won 't do anything )(map indexed? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ false false false false true true false false ]
(map tuple? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ false false false false true false false false ]
(map array? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ false false false false false true false false ] (get [4 5 6 ] -1 ) # => nil
(in [4 5 6 ] -1 42 ) # error
(get-in [4 5 6 ] [-1 ] 42 ) # => 42
(get {:a 1 } -1 ) # => nil
(in {:a 1 } -1 42 ) # => 42
(get-in {:a 1 } [-1 ] 42 ) # => 42
# Print out the current time in Last-Modified header-compliant
# form. (reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified)
(def weekdayMap [ "Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" ])
(def monthMap ["Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" ])
(def dt (os/date (os/time ) true ))
(string/format "%s, %02d %s %04d %02d:%02d:%02d"
(weekdayMap (dt :week-day ))
(dt :month-day )
(monthMap (dt :month ))
(dt :year )
(dt :hours )
(dt :minutes )
(dt :seconds ))
(->> (range 10 ) (map (fn [arg ] (* arg arg ))))
# => @[0 1 4 9 16 25 36 49 64 81] (buffer/bit-set @"hahaha" 3 ) # => @"hahaha"
(buffer/bit-set @"what" 3 ) # => @"\x7Fhat"
(net/address "0.0.0.0" 80 ) # => <core/socket-address 0x55CABA438E90>
(net/address "0.0.0.0" 8989 ) # => <core/socket-address 0x55CABA439980>
(type (fiber/new (fn [])))
# =>
:fiber (apply * [1 2 3 ]) # -> 6
(* (splice [1 2 3 ])) # -> 6
(* ;[1 2 3 ]) # -> 6
(* 1 2 3 ) # -> 6 (def a @[1 2 3 ])
(def b (array/slice a ))
#=> good way to clone array, a and b are different arrays (map math/abs [-2.9 -2.1 2.1 2.9 ]) # => @[ 2.9 2.1 2.1 2.9 ]
(map math/floor [-2.9 -2.1 2.1 2.9 ]) # => @[ -3 -3 2 2 ]
(map math/ceil [-2.9 -2.1 2.1 2.9 ]) # => @[ -2 -2 3 3 ]
(map math/round [-2.9 -2.1 2.1 2.9 ]) # => @[ -3 -2 2 3 ]
(map math/trunc [-2.9 -2.1 2.1 2.9 ]) # => @[ -2 -2 2 2 ]
# in the file ex.janet
(main [_ & args ]
(print "write something and I'll echo it" )
(def x (getline ))
(print x ))
# in the terminal:
# $ janet ex.janet
# write something and I'll echo it
# bla <- you wrote this
# bla (buffer/bit (buffer/new-filled 1 (chr "0" )) 4 )
# => true
(-> 1 (+ 2 ) (+ 3 )) # -> 6 (def b @"" )
(def v (* 1000 (math/random )))
# => 912.753 can differ for you
(xprintf b "Value reached level %f" v )
# => nil
b
# => @"Value reached level 912.752790\n"