Add more complex example of (read) usage
This commit is contained in:
parent
cf7e5ed3c0
commit
8d893ead07
@ -930,6 +930,24 @@ parsed.
|
||||
=> (eval (apply read [] {"from_file" buffer}))
|
||||
1
|
||||
|
||||
=> ; assuming "example.hy" contains:
|
||||
=> ; (print "hello")
|
||||
=> ; (print "hyfriends!")
|
||||
=> (with [[f (open "example.hy")]]
|
||||
... (try
|
||||
... (while true
|
||||
... (let [[exp (read f)]]
|
||||
... (do
|
||||
... (print "OHY" exp)
|
||||
... (eval exp))))
|
||||
... (catch [e EOFError]
|
||||
... (print "EOF!"))))
|
||||
OHY ('print' 'hello')
|
||||
hello
|
||||
OHY ('print' 'hyfriends!')
|
||||
hyfriends!
|
||||
EOF!
|
||||
|
||||
|
||||
.. _remove-fn:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user