Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(var x 1 )
(+= x 2 3 4 )
# x = 10 (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" (import spork/misc )
(def d (misc/capout (doc misc/capout )))
d # returns:
@"\n\n macro\n /usr/local/lib/janet/spork/misc.janet on
line 340, column 1\n\n \e[97m(capout & body)\e[39m\n\n
Captures the standard output of the variadic \e[97mbody\e[39m
and returns it as \n a buffer.\n\n\n"
(defn dataframe
``Create an empty dataframe with the given columns``
[& columns ]
(tabseq [c :in columns ] c @[]))(string/find-all "duck" "duck duck duck goose!" ) # => @[0 5 10] # This turns the current REPL session (environment) with all bindings, including synced closures,
# into a loadable or compilable image.
# It is the same as e.g.: `janet -c test.janet test.jimage` after (spit "test.janet" (currenv))
(spit "test.jimage" (make-image (curenv )))(put (table ) :a 1 ) # => @{:a 1}
(def add17 (partial + 17 ))
(add17 3 ) # -> 20
(add17 3 4 ) # -> 24
(map add17 [1 2 3 ]) # -> @[18 19 20]
(math/atan2 0 0 )
# => 0
(find |(string/has-prefix? "a" $ ) ["be" "cat" "art" "apple" ])
# => "art"
(cmp 1.0 2 )
# => -1
(map hash [nil true false -1 0 3.14 :a "foo" [1 2 3 ] {:a 1 } (fn [])])
# => @[0 1 0 -1074790400 0 1244950043 -2107123988 -1254832049 -2021739803 -1395744911 53378043] (def [pipe-r pipe-w ] (os/pipe ))
(:write pipe-w "hello" )
(:read pipe-r 5 )
# => @"hello"
# send the string "hello" into the writable stream
# part and read it back from the readable one
(buffer ;(interpose " " [:ant 'bee "cat" ``dog`` @`ewe` ]))
# => @"ant bee cat dog ewe" (peg/find-all ~(capture :d )
"hi 0 bye 1" )
# => @[3 9]