Input
Primarily, input from the keyboard is done using "read" and "line" commands.Read
Reads data from keyboard:: (setq aq (read))
hello
-> hello
: aq
-> hello
: print aq
-> hello
: (print aq)
hello-> hello
Line.
Reads data from keyboard and return them as a list:: (setq aq0 (line))
hello world
-> ("h" "e" "l" "l" "o" " " "w" "o" "r" "l" "d")
: (print aq0)
("h" "e" "l" "l" "o" " " "w" "o" "r" "l" "d")-> ("h" "e" "l" "l" "o" " " "w" "o" "r" "l" "d")
If we want to return it as a whole line we use (line T) instead of (line) :
: (setq aq0 (line T))
hello world
-> "hello world"
: (print aq0)
"hello world"-> "hello world"
PicoLisp Functions Used On This Page.
The description of the picolisp functions used taken from official PicoLisp documentation (https://software-lab.de/doc/index.html) follows:
(read ['sym1 ['sym2]]) -> any
NIL
is returned upon end of file. When called without arguments, an arbitrary Lisp expression is read. Otherwise, a token (a number, an internal symbol, a transient symbol (for punctuation), or a list of symbols (for a string)) is read. In that case, sym1
specifies which set of characters to accept for continuous symbol names (in addition to the standard alphanumerical characters), and sym2
an optional comment character. See also any
, str
, line
, skip
and eof
.
: (list (read) (read) (read)) # Read three things from console
123 # a number
abcd # a symbol
(def # and a list
ghi
jkl
)
-> (123 abcd (def ghi jkl))
: (make (while (read "_" "#") (link @)))
abc = def_ghi("xyz"+-123) # Comment
NIL
-> (abc "=" def_ghi "(" ("x" "y" "z") "+" "-" 123 ")")
(line 'flg ['cnt ..]) -> lst|sym
flg
is NIL
, a list of single-character transient symbols is returned. When cnt
arguments are given, subsequent characters of the input line are grouped into sublists, to allow parsing of fixed field length records. If flg
is non-NIL
, strings are returned instead of single-character lists. NIL
is returned upon end of file. See also char
, read
, till
and eof
.
: (line)
abcdefghijkl
-> ("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l")
: (line T)
abcdefghijkl
-> "abcdefghijkl"
: (line NIL 1 2 3)
abcdefghijkl
-> (("a") ("b" "c") ("d" "e" "f") "g" "h" "i" "j" "k" "l")
: (line T 1 2 3)
abcdefghijkl
-> ("a" "bc" "def" "g" "h" "i" "j" "k" "l")