Helloooooooo!
This blog will cover:
-Three interesting features of Lisp.
-Plans for future blog posts.
Math:
Lisp was invented at a time when computers were mainly used to make big math problems easier and to do them much faster than people. They still are used for this today, but at the time Lisp's ability to deal with large numbers in an efficient way was more significant. So one interesting feature of Lisp is it's mathematical capabilities.
Here are some examples:
-First is exponents - we can calculate 10^10 and 10^10^10^10 is similar amounts of time and with equal precision.
-Next is exact rational number calculations with a couple examples.
-Finally is an example of a complex number. The #c(10 5) represents 10 + 5i.
Format:
Another interesting feature of Lisp is something that I have avoided using in my past examples and blog posts. It is a format function that is used for output. It seems elementary, and I didn't understand why a programmer would prefer it over a simple print statement. Further research uncovers its power:
the format function, which syntactically looks like so:
(format destination control-string arguments)
generally the destination is t which prints to the Standard Output stream, if the destination is nil, then the format returns a string and returns it.
In the control-string we decide what we want to see, but there are also directives that we can give the function to control what is printed, which makes it more than just a print function.
These symbols are built-in to the lisp environment, similar to regular expression symbols in Java.
Different symbols are used to represent broad categories for example:
~A - the following argument is an ASCII character
~S - the following argument is an S-expression
~D - the following argument is a decimal
~% - is used to add a new line to the print statement.
Thanks for reading,
The next blog post will be up soon. It will be a program that utilizes the features discussed in this post.
Peter Short, CS 270, Blog 7
No comments:
Post a Comment