Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
math/e
# => 2.71828 # Gathers all of the calls of "declare-" into a table from the project.janet file at path
(defn capture-declares [path ]
(def *capture* @{})
(defn append-capture [name & arg ]
(update *capture* name (fn [val ] (array/push (or val @[]) ;arg ))))
(defn only-captures [form ]
(when (string/has-prefix? "declare-" (string (form 0 )))
(append-capture (form 0 ) (slice form 1 ))
form )
nil )
(dofile path :expander only-captures )
*capture* )
(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 ]
(describe {:a 1 }) # => "<struct 0x5564AF1BD6C0>" (filter (fn [x ] (> x 2 )) [1 2 3 4 5 ]) # @[3 4 5] $ # trivial server which echo's to the console.
$ cat > srv.janet << EOF
#!/usr/bin/env janet
(defn handle-conn [conn ]
(print "new connection" )
(while true
(def data (net/read conn 4096 ))
(if (not data ) (break ))
(prin data ))
(net/close conn )
(print "connection closed" ))
(print "starting server on 0.0.0.0:1234" )
(net/server "0.0.0.0" 1234 handle-conn )
EOF
$ chmod +x srv.janet
$ ./srv.janet
----
$ # in another terminal:
$ echo hello | nc 0.0.0.0 1234
(peg/find-all ':d "hi 1 bye 2" ) # => @[3 9]
(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
(peg/find-all ~(capture (range "09" ))
"hi 0 bye 1" )
# => @[3 9] (* 2 3 ) # -> 6
(* 2 3.3 ) # -> 6.6
(* 2.2 3.3 ) # -> 7.26
(def pi 3.14159 )
(* 2 pi ) # -> 6.28318
(* 2 ) # -> 2
(* ) # -> 1
(* 2 3 4 ) # -> 24
(apply * [2 3 4 ]) # -> 24
(* (splice [2 3 4 ])) # -> 24
(* ;[2 3 4 ]) # -> 24
(def a [2 3 4 ])
(* ;a ) # -> 24
(last "hello" )
# => 111
(from-pairs [[:hello "world" ] [:foo "bar" ]])
# => @{:foo "bar" :hello "world"} (def kvpairs [[:x 1 ] [:y 2 ]])
(table ;(flatten kvpairs )) # => @{:x 1 :y 2} (os/sleep 1 ) # => nil
(os/sleep 0.1 ) # => nil
(os/sleep 0 ) # => nil
(table/new 2 )
# => @{}