Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(defn greet-me [] (print "hey programmer!" ))
(defn greet-stranger [] (print "hey stranger!" ))
(varfn greet [] (greet-me ))
(greet ) # prints "hey programmer!"
(varfn greet [] (greet-stranger ))
(greet ) # prints "hey stranger!"
# kind of analogous to (def greet (fn [] (some-thunk))), but with built-in
# sugar to automatically update 'greet' if varfn is called with a name
# already bound
(string/join @["alice" "bob" "eve" ] "\t" )
# => "alice\tbob\teve" (spit "/tmp/hello.sh" "#!/bin/bash\necho 'Hello from Bash!'\n" )
(os/chmod "/tmp/hello.sh" "rwx------" )
(os/setenv "PATH" (string (os/getenv "PATH" ) ":/tmp" ))
(os/shell "hello.sh" )
(drop 1 "smile" )
# => "mile"
(one? :dude ) # => false (take-while number? @[1 2 3 "4" 5 6 7 8 9 "10" 11 "12" ]) # => (1 2 3)
(seq [v :in (coro
(yield :hi )
(yield :bye ))]
v )
# => @[:hi :bye] (map |($ {:a 7 :b 8 } ) [ keys values kvs pairs ])
# => @[ @[:a :b] @[7 8] @[:a 7 :b 8] @[(:a 7) (:b 8)] ]
(map |($ [4 5 6 ] ) [ keys values kvs pairs ])
# => @[ @[0 1 2] @[4 5 6] @[0 4 1 5 2 6] @[(0 4) (1 5) (2 6)] ]
(map |($ 'ab ) [ keys values kvs pairs ])
# => @[ @[0 1] @[97 98] @[0 97 1 98] @[(0 97) (1 98)] ]
(map |($ :ab ) [ keys values kvs pairs ])
# => @[ @[0 1] @[97 98] @[0 97 1 98] @[(0 97) (1 98)] ]
(map |($ "ab" ) [ keys values kvs pairs ])
# => @[ @[0 1] @[97 98] @[0 97 1 98] @[(0 97) (1 98)] ]
#!/usr/bin/env janet
# echo stdin to stdout.
(file/write stdout (file/read stdin :all ))
(empty? [])
# => true
(os/cwd ) # => "/Users/cell/tmp"
(os/getenv "PWD" ) # => "/Users/cell/tmp"
(get (os/environ ) "PWD" ) # => "/Users/cell/tmp"
(dyn :pretty-format )
# => "%.20Q" (last [1 1 2 3 5 8 ])
# => 8
$ # 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
Math. Seedrandom (3206 )