Read more:
To ignore the next form, we could define a comment
macro like Clojure:
(defmacro comment args '(progn))
Returns a progn because progns are allowed at top-level.
Read more:
- https://stackoverflow.com/questions/29849954/common-lisp-what-does-nil
- https://clojure.org/guides/weird_characters#_discard
In top-level progns, only valid top-level forms are allowed.
See repl help with (help)
:
LFE shell built-in functions
(c file) -- compile and load code in <file>
(cd dir) -- change working directory to <dir>
(clear) -- clear the REPL output
(doc mod) -- documentation of a module
(doc mod:mac) -- documentation of a macro
(doc m:f/a) -- documentation of a function
(ec file) -- compile and load code in erlang <file>
(ep expr) -- print a term in erlang form
(epp expr) -- pretty print a term in erlang form
(exit) -- quit - an alias for (q)
(flush) -- flush any messages sent to the shell
(h) -- an alias for (help)
(help) -- help info
(i) -- information about the system
(i pids) -- information about a list of pids
(l module) -- load or reload <module>
(ls) -- list files in the current directory
(ls dir) -- list files in directory <dir>
(m) -- which modules are loaded
(m mod) -- information about module <mod>
(p expr) -- print a term
(pp expr) -- pretty print a term
(pid x y z) -- convert <x>, <y> and <z> to a pid
(pwd) -- print working directory
(q) -- quit - shorthand for init:stop/0
(regs) -- information about registered processes
LFE shell built-in commands
(reset-environment) -- reset the environment to its initial state
(run file) -- execute all the shell commands in a <file>
(set pattern expr)
(set pattern (when guard) expr) -- evaluate <expr> and match the result with
pattern binding
(slurp file) -- slurp in a LFE source <file> and makes
everything available in the shell
(unslurp) -- revert back to the state before the last
slurp
LFE shell built-in variables
+/++/+++ -- the tree previous expressions
*/**/*** -- the values of the previous expressions
- -- the current expression output
$ENV -- the current LFE environment
Common Lisp:
(defparameter my-plist (list 'foo "foo" 'bar "bar"))
LFE:
(set options '(#(debug true) #(default 42)))
Read more:
- https://lfe.io/books/tutorial/sequential/propmaps.html
- https://erlang.org/doc/man/proplists.html
- https://lispcookbook.github.io/cl-cookbook/data-structures.html
lfe> (map "key" 42)
#M("key" 42)
Read more:
For the list processing, see lists:map/2
and her great many friends:
There are four ways to go about string formatting.
lfe_io:format/2
andio:format/2
(the Erlang counterpart) print to stdout:
lfe> (lfe_io:format "hello world~n" ())
hello world
ok
lfe> (lfe_io:format "this outputs one LFE term: ~w~n" '(hello))
this outputs one LFE term: hello
ok
- http://erlang.org/doc/man/io.html#format-2
- https://lfe.io/books/tutorial/sequential/output.html
- https://lfe.io/books/tutorial/sequential/example.html#2 -- On the difference between
lfe_io:format
andio:format
lfe_io:format/3
andio:format/3
print to IoDevice:
io_lib:format/2
prints to string:
- https://noss.github.io/2009/03/29/erlang-io-format-to-string.html
- http://erlang.org/doc/man/io_lib.html#format-2
lfe_io
functions that return strings end in 1:print1
,prettyprint1
,format1
andfwrite1
lfe> (lfe_io:print1 "hello")
(40 ("104" 32 "101" 32 "108" 32 "108" 32 "111") 41)
lfe> (lfe_io:prettyprint1 "hello")
(34 "hello\"")
lfe> (lfe_io:format1 "hello ~n" '())
(104 101 108 108 111 32 "\n")
lfe> (lfe_io:format1 "hello ~n" '())
(104 101 108 108 111 32 "\n")
lfe> (lists:flatten (lfe_io:format1 "hello ~n" '()))
"hello \n"
Read more: