A set of batteries for Janet for programming terminals and the like.
|
1 year ago | |
---|---|---|
collider | 1 year ago | |
LICENSE | 1 year ago | |
README.md | 1 year ago | |
colors.janet | 1 year ago | |
common.janet | 1 year ago | |
example_guess.janet | 1 year ago | |
example_tictactoe.janet | 1 year ago | |
netfunc.janet | 1 year ago | |
patterns.janet | 1 year ago | |
project.janet | 1 year ago |
is a general library for helping with user-oriented programming (ie. scripting) in Janet.
(use collider)
#Server:
(defn serve (s)
(string "Greetings, " s "!"))
#Another way of putting it:
(def serve2 (/. string "Hello, ") #/. is shorthand for partial (currying)
(netfunc/netfn serve2 "localhost" 9556 )
(forever (ev/sleep 3600)) #Halt main fiber
#Client:
(defn get-served (s)
(netfunc/netcall "localhost" 9556 s))
#Or,
(def get-served2 (/. netfunc/netcall "localhost" 9556))
(get-served2 "Alice")
(get-served2 :Bob) #Netfunc can pass any marshallable (≃serializable) data.
(get-served2 @{}) #Even tables and arrays.
(print
(color/RGB1 0 1 0) #The color library can be used to produce ANSI sequences.
(pattern/move-at 2 0) #The pattern library can be used to produce various patterns on an ANSI-capable terminal display.
(get-served2 "Eve"))