<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2668244871531886674</id><updated>2026-04-24T17:27:16.069-07:00</updated><category term="Cricket"/><category term="Income tax"/><category term="Programming"/><category term="Telangana"/><category term="Top Technology News"/><category term="Agda"/><category term="C"/><category term="CAT 2013"/><category term="Car of the Decade"/><category term="Company"/><category term="Developer platform"/><category term="DuckDuckGo"/><category term="Emacs Lisp"/><category term="Enables any web page to become a rich object in a social graph"/><category term="Frequently Asked Questions"/><category term="Friendship"/><category term="Google:Products"/><category term="Income Tax Return"/><category term="Incometax"/><category term="Jagdish Raj"/><category term="Management."/><category term="Microsoft Office 365"/><category term="Moto X"/><category term="NSEL"/><category term="Nokia 808 PureView"/><category term="PSG announced"/><category term="Technology and Science Current News."/><category term="TextBlob: Simplified Text Processing"/><category term="The Importance of Realism in Startups"/><category term="The algorithm for a perfectly balanced photo gallery"/><category term="deadline"/><category term="haskell"/><category term="html"/><category term="income tax returns"/><category term="mpv"/><category term="open source release"/><category term="parser"/><title type='text'>Web Expert</title><subtitle type='html'>Get the best facts of Technology and Web world in exact form.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>56</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-7379902698098590472</id><published>2013-08-13T20:15:00.003-07:00</published><updated>2013-08-13T20:22:30.651-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="html"/><category scheme="http://www.blogger.com/atom/ns#" term="open source release"/><category scheme="http://www.blogger.com/atom/ns#" term="parser"/><title type='text'>Gumbo - A pure-C HTML5 parser</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;http://bit.ly/1eInBtE&quot; target=&quot;_blank&quot;&gt;Gumbo&lt;/a&gt; is an implementation of the &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/#auto-toc-12&quot;&gt;HTML5 parsing
algorithm&lt;/a&gt;
implemented as a pure C99 library with no outside dependencies.  It&#39;s designed
to serve as a building block for other tools and libraries such as linters,
validators, templating languages, and refactoring and analysis tools.&lt;br /&gt;
Goals &amp;amp; features:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Fully conformant with the &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/&quot;&gt;HTML5 spec&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Robust and resilient to bad input.&lt;/li&gt;
&lt;li&gt;Simple API that can be easily wrapped by other languages.&lt;/li&gt;
&lt;li&gt;Support for source locations and pointers back to the original text.&lt;/li&gt;
&lt;li&gt;Relatively lightweight, with no outside dependencies.&lt;/li&gt;
&lt;li&gt;Passes all &lt;a href=&quot;https://github.com/html5lib/html5lib-tests&quot;&gt;html5lib-0.95 tests&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;Tested on over 2.5 billion pages from Google&#39;s index.&lt;/li&gt;
&lt;/ul&gt;
Non-goals:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Execution speed.  Gumbo gains some of this by virtue of being written in C,
but it is not an important consideration for the intended use-case, and was
not a major design factor.&lt;/li&gt;
&lt;li&gt;C89 support.  Most major compilers support C99 by now; the major exception
(Microsoft Visual Studio) should be able to compile this in C++ mode with
relatively few changes.  (Bug reports welcome.)&lt;/li&gt;
&lt;/ul&gt;
Wishlist (aka &quot;We couldn&#39;t get these into the original release, but are hoping
to add them soon):&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Support for recent HTML5 spec changes to support the template tag.&lt;/li&gt;
&lt;li&gt;Support for fragment parsing.&lt;/li&gt;
&lt;li&gt;Full-featured error reporting.&lt;/li&gt;
&lt;li&gt;Bindings in other languages.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
&lt;a class=&quot;anchor&quot; href=&quot;https://github.com/google/gumbo-parser#installation&quot; name=&quot;installation&quot;&gt;&lt;/a&gt;Installation&lt;/h1&gt;
To build and install the library, issue the standard UNIX incantation from the root of the distribution:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;$ ./configure
$ make
$ sudo make install
&lt;/code&gt;&lt;/pre&gt;
Gumbo comes with full pkg-config support, so you can use the 
pkg-config to print the flags needed to link your program against it:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;$ pkg-config --cflags gumbo         # print compiler flags
$ pkg-config --libs gumbo           # print linker flags
$ pkg-config --cflags --libs gumbo  # print both
&lt;/code&gt;&lt;/pre&gt;
For example:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;$ gcc my_program.c `pkg-config --cflags --libs gumbo`
&lt;/code&gt;&lt;/pre&gt;
See the pkg-config man page for more info.&lt;br /&gt;
There are a number of sample programs in the examples/ directory.  
They&#39;re built automatically by &#39;make&#39;, but can also be made individually
 with &#39;make &#39; (eg. &#39;make clean_text&#39;).&lt;br /&gt;
To run the unit tests, you&#39;ll need to have &lt;a href=&quot;https://code.google.com/p/googletest/&quot;&gt;googletest&lt;/a&gt;
 downloaded and unzipped.  The googletest maintainers recommend against 
using &#39;make install&#39;; instead, symlink the root googletest directory to 
&#39;gtest&#39; inside gumbo&#39;s root directory, and then &#39;make check&#39;:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;$ unzip gtest-1.6.0.zip
$ cd gumbo-*
$ ln -s ../gtest-1.6.0 gtest
$ make check
&lt;/code&gt;&lt;/pre&gt;
Gumbo&#39;s &#39;make check&#39; has code to automatically configure &amp;amp; build gtest and then link in the library.&lt;br /&gt;
&lt;h1&gt;
&lt;a class=&quot;anchor&quot; href=&quot;https://github.com/google/gumbo-parser#basic-usage&quot; name=&quot;basic-usage&quot;&gt;&lt;/a&gt;Basic Usage&lt;/h1&gt;
Within your program, you need to include &quot;gumbo.h&quot; and then issue a call to gumbo_parse:&lt;br /&gt;
&lt;div class=&quot;highlight&quot;&gt;
&lt;pre&gt;&lt;span class=&quot;cp&quot;&gt;#include &quot;gumbo.h&quot;&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;GumboOutput&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gumbo_parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Do stuff with output-&amp;gt;root&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gumbo_destroy_output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kGumboDefaultOptions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
See the API documentation and sample programs for more details.&lt;br /&gt;
&lt;h1&gt;
&lt;a class=&quot;anchor&quot; href=&quot;https://github.com/google/gumbo-parser#a-note-on-apiabi-compatibility&quot; name=&quot;a-note-on-apiabi-compatibility&quot;&gt;&lt;/a&gt;A note on API/ABI compatibility&lt;/h1&gt;
We&#39;ll make a best effort to preserve API compatibility between 
releases.  The initial release is a 0.9 (beta) release to solicit 
comments from early adopters, but if no major problems are found with 
the API, a 1.0 release will follow shortly, and the API of that should 
be considered stable.  If changes are necessary, we follow &lt;a href=&quot;http://semver.org/&quot;&gt;semantic versioning&lt;/a&gt;.&lt;br /&gt;
We make no such guarantees about the ABI, and it&#39;s very likely that 
subsequent versions may require a recompile of client code.  For this 
reason, we recommend NOT using Gumbo data structures throughout a 
program, and instead limiting them to a translation layer that picks out
 whatever data is needed from the parse tree and then converts that to 
persistent data structures more appropriate for the application.  The 
API is structured to encourage this use, with a single delete function 
for the whole parse tree, and is not designed with mutation in mind.&lt;br /&gt;
&lt;h1&gt;
&lt;a class=&quot;anchor&quot; href=&quot;https://github.com/google/gumbo-parser#python-usage&quot; name=&quot;python-usage&quot;&gt;&lt;span class=&quot;octicon octicon-link&quot;&gt;&lt;/span&gt;&lt;/a&gt;Python usage&lt;/h1&gt;
To install the python bindings, make sure that the C library is 
installed first, and then &quot;sudo python setup.py install&quot; from the root 
of the distro.  This install a &#39;gumbo&#39; module; &#39;pydoc gumbo&#39; should tell
 you about them.&lt;br /&gt;
Recommended best-practice for Python usage is to use one of the 
adapters to an existing API (personally, I prefer BeautifulSoup) and 
write your program in terms of those.  The raw CTypes bindings should be
 considered building blocks for higher-level libraries and rarely 
referenced directly.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Source: &lt;link&gt;&lt;/link&gt;&lt;a href=&quot;https://github.com/google/gumbo-parser.git&quot; target=&quot;_blank&quot;&gt;https://github.com/google/gumbo-parser.git &lt;/a&gt;&lt;/u&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/7379902698098590472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/gumbo-pure-c-html5-parser.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/7379902698098590472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/7379902698098590472'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/gumbo-pure-c-html5-parser.html' title='Gumbo - A pure-C HTML5 parser'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-1438459100881199243</id><published>2013-08-13T20:02:00.000-07:00</published><updated>2013-08-13T20:09:06.792-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Emacs Lisp"/><title type='text'>An Introduction to Programming in Emacs Lisp</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The homepage for GNU Emacs is at
&lt;a href=&quot;http://www.gnu.org/software/emacs/&quot;&gt;http://www.gnu.org/software/emacs/&lt;/a&gt;. 
&lt;br /&gt;
&lt;br /&gt;
To view this manual in other formats, click
&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/eintr.html&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
This is an &lt;cite&gt;Introduction to Programming in Emacs Lisp&lt;/cite&gt;, for
people who are not programmers.
   &lt;br /&gt;
Edition 3.10, 28 October 2009
   
Copyright © 1990–1995, 1997, 2001–2013 Free Software
Foundation, Inc.&lt;br /&gt;
&lt;br /&gt;
Published by the:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;example&quot;&gt;     GNU Press,                        http://www.fsf.org/campaigns/gnu-press/
     a division of the                 email: sales@fsf.org
     Free Software Foundation, Inc.    Tel: +1 (617) 542-5942
     51 Franklin Street, Fifth Floor   Fax: +1 (617) 542-2652
     Boston, MA 02110-1301 USA&lt;/pre&gt;
&lt;pre class=&quot;example&quot;&gt;&amp;nbsp;&lt;/pre&gt;
ISBN 1-882114-43-4

   Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; there
being no Invariant Section, with the Front-Cover Texts being “A GNU
Manual”, and with the Back-Cover Texts as in (a) below.  A copy of
the license is included in the section entitled “GNU Free
Documentation License”.

   &lt;br /&gt;
(a) The FSF&#39;s Back-Cover Text is: “You have the freedom to
copy and modify this GNU manual.  Buying copies from the FSF
supports it in developing GNU and promoting software freedom.”

   &lt;br /&gt;
This master menu first lists each chapter and index; then it lists
every node in every chapter.









&lt;br /&gt;
&lt;table style=&quot;float: left; width: 100%px;&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Preface&quot;&gt;Preface&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;What to look for.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot;&gt;List Processing&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;What is Lisp?&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Practicing-Evaluation&quot;&gt;Practicing Evaluation&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Running several programs.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot;&gt;Writing Defuns&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to write function definitions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Walk-Through&quot;&gt;Buffer Walk Through&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Exploring a few buffer-related functions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#More-Complex&quot;&gt;More Complex&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A few, even more complex functions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a accesskey=&quot;7&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot;&gt;Narrowing &amp;amp; Widening&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Restricting your and Emacs attention to
                                    a region.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a accesskey=&quot;8&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Fundamental functions in Lisp.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a accesskey=&quot;9&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Removing text and saving it.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Implementation&quot;&gt;List Implementation&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How lists are implemented in the computer.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Yanking&quot;&gt;Yanking&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Pasting stored text.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loops-_0026-Recursion&quot;&gt;Loops &amp;amp; Recursion&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to repeat a process.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Regexp-Search&quot;&gt;Regexp Search&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Regular expression searches.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Counting-Words&quot;&gt;Counting Words&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A review of repetition and regexps.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Words-in-a-defun&quot;&gt;Words in a defun&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Counting words in a &lt;code&gt;defun&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Readying-a-Graph&quot;&gt;Readying a Graph&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A prototype graph printing function.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Emacs-Initialization&quot;&gt;Emacs Initialization&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to write a &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.emacs&lt;/span&gt;&lt;/samp&gt; file.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Debugging&quot;&gt;Debugging&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to run the Emacs Lisp debuggers.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Now you have the basics.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#the_002dthe&quot;&gt;the-the&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;An appendix: how to find reduplicated words.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Kill-Ring&quot;&gt;Kill Ring&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;An appendix: how the kill ring works.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Full-Graph&quot;&gt;Full Graph&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to create a graph with labeled axes.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Free-Software-and-Free-Manuals&quot;&gt;Free Software and Free Manuals&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#GNU-Free-Documentation-License&quot;&gt;GNU Free Documentation License&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Index&quot;&gt;Index&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#About-the-Author&quot;&gt;About the Author&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3&gt;
Detailed Node Listing&lt;/h3&gt;
Preface

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Why&quot;&gt;Why&lt;/a&gt;:                          Why learn Emacs Lisp? 
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#On-Reading-this-Text&quot;&gt;On Reading this Text&lt;/a&gt;:         Read, gain familiarity, pick up habits.... 
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Who-You-Are&quot;&gt;Who You Are&lt;/a&gt;:                  For whom this is written. 
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-History&quot;&gt;Lisp History&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Note-for-Novices&quot;&gt;Note for Novices&lt;/a&gt;:             You can read this as a novice. 
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Thank-You&quot;&gt;Thank You&lt;/a&gt;

&lt;/li&gt;
&lt;/ul&gt;
&lt;table style=&quot;float: left; width: 100%px;&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;List Processing

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Lists&quot;&gt;Lisp Lists&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;What are lists?&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Run-a-Program&quot;&gt;Run a Program&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Any list in Lisp is a program ready to run.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Making-Errors&quot;&gt;Making Errors&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Generating an error message.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Names-_0026-Definitions&quot;&gt;Names &amp;amp; Definitions&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Names of symbols and function definitions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Interpreter&quot;&gt;Lisp Interpreter&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;What the Lisp interpreter does.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluation&quot;&gt;Evaluation&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Running a program.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot;&gt;Variables&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Returning a value from a variable.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Arguments&quot;&gt;Arguments&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Passing information to a function.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#set-_0026-setq&quot;&gt;set &amp;amp; setq&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Setting the value of a variable.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Summary&quot;&gt;Summary&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The major points.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Error-Message-Exercises&quot;&gt;Error Message Exercises&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Lisp Lists

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Numbers-Lists&quot;&gt;Numbers Lists&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;List have numbers, other lists, in them.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Atoms&quot;&gt;Lisp Atoms&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Elemental entities.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Whitespace-in-Lists&quot;&gt;Whitespace in Lists&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Formatting lists to be readable.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Typing-Lists&quot;&gt;Typing Lists&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How GNU Emacs helps you type lists.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The Lisp Interpreter

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complications&quot;&gt;Complications&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Variables, Special forms, Lists within.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Byte-Compiling&quot;&gt;Byte Compiling&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Specially processing code for speed.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Evaluation

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#How-the-Interpreter-Acts&quot;&gt;How the Interpreter Acts&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Returns and Side Effects...&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluating-Inner-Lists&quot;&gt;Evaluating Inner Lists&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Lists within lists...

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Variables

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fill_002dcolumn-Example&quot;&gt;fill-column Example&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Void-Function&quot;&gt;Void Function&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The error message for a symbol
                                  without a function.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Void-Variable&quot;&gt;Void Variable&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The error message for a symbol without a value.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Arguments

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Data-types&quot;&gt;Data types&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Types of data passed to a function.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Args-as-Variable-or-List&quot;&gt;Args as Variable or List&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;An argument can be the value
                                  of a variable or list.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variable-Number-of-Arguments&quot;&gt;Variable Number of Arguments&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Some functions may take a
                                  variable number of arguments.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Wrong-Type-of-Argument&quot;&gt;Wrong Type of Argument&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Passing an argument of the wrong type
                                  to a function.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#message&quot;&gt;message&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A useful function for sending messages.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Setting the Value of a Variable

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Using-set&quot;&gt;Using set&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Setting values.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Using-setq&quot;&gt;Using setq&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Setting a quoted value.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Counting&quot;&gt;Counting&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Using &lt;code&gt;setq&lt;/code&gt; to count.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Practicing Evaluation

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#How-to-Evaluate&quot;&gt;How to Evaluate&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Typing editing commands or &lt;kbd&gt;C-x C-e&lt;/kbd&gt;
                                 causes evaluation.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Names&quot;&gt;Buffer Names&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Buffers and files are different.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Getting-Buffers&quot;&gt;Getting Buffers&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Getting a buffer itself, not merely its name.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Switching-Buffers&quot;&gt;Switching Buffers&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to change to another buffer.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Size-_0026-Locations&quot;&gt;Buffer Size &amp;amp; Locations&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Where point is located and the size of
                               the buffer.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluation-Exercise&quot;&gt;Evaluation Exercise&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;How To Write Function Definitions

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Primitive-Functions&quot;&gt;Primitive Functions&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defun&quot;&gt;defun&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The &lt;code&gt;defun&lt;/code&gt; special form.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Install&quot;&gt;Install&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Install a function definition.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive&quot;&gt;Interactive&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Making a function interactive.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive-Options&quot;&gt;Interactive Options&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Different options for &lt;code&gt;interactive&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Permanent-Installation&quot;&gt;Permanent Installation&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Installing code permanently.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot;&gt;let&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Creating and initializing local variables.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if&quot;&gt;if&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;What if?&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#else&quot;&gt;else&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;If--then--else expressions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Truth-_0026-Falsehood&quot;&gt;Truth &amp;amp; Falsehood&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;What Lisp considers false and true.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002dexcursion&quot;&gt;save-excursion&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Keeping track of point, mark, and buffer.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Review&quot;&gt;Review&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defun-Exercises&quot;&gt;defun Exercises&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Install a Function Definition

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Effect-of-installation&quot;&gt;Effect of installation&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Change-a-defun&quot;&gt;Change a defun&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to change a function definition.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Make a Function Interactive

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive-multiply_002dby_002dseven&quot;&gt;Interactive multiply-by-seven&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;An overview.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#multiply_002dby_002dseven-in-detail&quot;&gt;multiply-by-seven in detail&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The interactive version.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;let&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Prevent-confusion&quot;&gt;Prevent confusion&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Parts-of-let-Expression&quot;&gt;Parts of let Expression&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Sample-let-Expression&quot;&gt;Sample let Expression&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Uninitialized-let-Variables&quot;&gt;Uninitialized let Variables&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The &lt;code&gt;if&lt;/code&gt; Special Form

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if-in-more-detail&quot;&gt;if in more detail&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#type_002dof_002danimal-in-detail&quot;&gt;type-of-animal in detail&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;An example of an &lt;code&gt;if&lt;/code&gt; expression.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Truth and Falsehood in Emacs Lisp

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nil-explained&quot;&gt;nil explained&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;nil&lt;/code&gt; has two meanings.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;save-excursion&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Point-and-mark&quot;&gt;Point and mark&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A review of various locations.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Template-for-save_002dexcursion&quot;&gt;Template for save-excursion&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;A Few Buffer--Related Functions

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Finding-More&quot;&gt;Finding More&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to find more information.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#simplified_002dbeginning_002dof_002dbuffer&quot;&gt;simplified-beginning-of-buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Shows &lt;code&gt;goto-char&lt;/code&gt;,
                                &lt;code&gt;point-min&lt;/code&gt;, and &lt;code&gt;push-mark&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mark_002dwhole_002dbuffer&quot;&gt;mark-whole-buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Almost the same as &lt;code&gt;beginning-of-buffer&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot;&gt;append-to-buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Uses &lt;code&gt;save-excursion&lt;/code&gt; and
                                &lt;code&gt;insert-buffer-substring&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Related-Review&quot;&gt;Buffer Related Review&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Review.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Exercises&quot;&gt;Buffer Exercises&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The Definition of &lt;code&gt;mark-whole-buffer&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mark_002dwhole_002dbuffer-overview&quot;&gt;mark-whole-buffer overview&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Body-of-mark_002dwhole_002dbuffer&quot;&gt;Body of mark-whole-buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Only three lines of code.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The Definition of &lt;code&gt;append-to-buffer&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer-overview&quot;&gt;append-to-buffer overview&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append-interactive&quot;&gt;append interactive&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A two part interactive expression.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer-body&quot;&gt;append-to-buffer body&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Incorporates a &lt;code&gt;let&lt;/code&gt; expression.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append-save_002dexcursion&quot;&gt;append save-excursion&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How the &lt;code&gt;save-excursion&lt;/code&gt; works.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;A Few More Complex Functions

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dto_002dbuffer&quot;&gt;copy-to-buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;With &lt;code&gt;set-buffer&lt;/code&gt;, &lt;code&gt;get-buffer-create&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot;&gt;insert-buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Read-only, and with &lt;code&gt;or&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer&quot;&gt;beginning-of-buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Shows &lt;code&gt;goto-char&lt;/code&gt;,
                                &lt;code&gt;point-min&lt;/code&gt;, and &lt;code&gt;push-mark&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Second-Buffer-Related-Review&quot;&gt;Second Buffer Related Review&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#optional-Exercise&quot;&gt;optional Exercise&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The Definition of &lt;code&gt;insert-buffer&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-code&quot;&gt;insert-buffer code&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-interactive&quot;&gt;insert-buffer interactive&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;When you can read, but not write.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-body&quot;&gt;insert-buffer body&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The body has an &lt;code&gt;or&lt;/code&gt; and a &lt;code&gt;let&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if-_0026-or&quot;&gt;if &amp;amp; or&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Using an &lt;code&gt;if&lt;/code&gt; instead of an &lt;code&gt;or&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Insert-or&quot;&gt;Insert or&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How the &lt;code&gt;or&lt;/code&gt; expression works.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Insert-let&quot;&gt;Insert let&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Two &lt;code&gt;save-excursion&lt;/code&gt; expressions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#New-insert_002dbuffer&quot;&gt;New insert-buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The Interactive Expression in &lt;code&gt;insert-buffer&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Read_002donly-buffer&quot;&gt;Read-only buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;When a buffer cannot be modified.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#b-for-interactive&quot;&gt;b for interactive&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;An existing buffer or else its name.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Complete Definition of &lt;code&gt;beginning-of-buffer&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Optional-Arguments&quot;&gt;Optional Arguments&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-opt-arg&quot;&gt;beginning-of-buffer opt arg&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Example with optional argument.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-complete&quot;&gt;beginning-of-buffer complete&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;beginning-of-buffer&lt;/code&gt; with an Argument

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Disentangle-beginning_002dof_002dbuffer&quot;&gt;Disentangle beginning-of-buffer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Large-buffer-case&quot;&gt;Large buffer case&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Small-buffer-case&quot;&gt;Small buffer case&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Narrowing and Widening

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-advantages&quot;&gt;Narrowing advantages&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The advantages of narrowing&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002drestriction&quot;&gt;save-restriction&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The &lt;code&gt;save-restriction&lt;/code&gt; special form.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#what_002dline&quot;&gt;what-line&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The number of the line that point is on.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#narrow-Exercise&quot;&gt;narrow Exercise&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;car&lt;/code&gt;, &lt;code&gt;cdr&lt;/code&gt;, &lt;code&gt;cons&lt;/code&gt;: Fundamental Functions

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Strange-Names&quot;&gt;Strange Names&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;An historical aside: why the strange names?&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-_0026-cdr&quot;&gt;car &amp;amp; cdr&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Functions for extracting part of a list.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons&quot;&gt;cons&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Constructing a list.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nthcdr&quot;&gt;nthcdr&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Calling &lt;code&gt;cdr&lt;/code&gt; repeatedly.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nth&quot;&gt;nth&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcar&quot;&gt;setcar&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Changing the first element of a list.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcdr&quot;&gt;setcdr&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Changing the rest of a list.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons-Exercise&quot;&gt;cons Exercise&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;cons&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Build-a-list&quot;&gt;Build a list&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#length&quot;&gt;length&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to find the length of a list.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Cutting and Storing Text

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Storing-Text&quot;&gt;Storing Text&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Text is stored in a list.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot;&gt;zap-to-char&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Cutting out text up to a character.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dregion&quot;&gt;kill-region&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Cutting text out of a region.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill&quot;&gt;copy-region-as-kill&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A definition for copying text.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Digression-into-C&quot;&gt;Digression into C&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Minor note on C programming language macros.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defvar&quot;&gt;defvar&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to give a variable an initial value.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons-_0026-search_002dfwd-Review&quot;&gt;cons &amp;amp; search-fwd Review&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#search-Exercises&quot;&gt;search Exercises&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;zap-to-char&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-zap_002dto_002dchar&quot;&gt;Complete zap-to-char&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The complete implementation.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar-interactive&quot;&gt;zap-to-char interactive&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A three part interactive expression.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar-body&quot;&gt;zap-to-char body&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A short overview.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#search_002dforward&quot;&gt;search-forward&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to search for a string.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#progn&quot;&gt;progn&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The &lt;code&gt;progn&lt;/code&gt; special form.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Summing-up-zap_002dto_002dchar&quot;&gt;Summing up zap-to-char&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Using &lt;code&gt;point&lt;/code&gt; and &lt;code&gt;search-forward&lt;/code&gt;.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;kill-region&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-kill_002dregion&quot;&gt;Complete kill-region&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The function definition.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#condition_002dcase&quot;&gt;condition-case&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Dealing with a problem.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-macro&quot;&gt;Lisp macro&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;copy-region-as-kill&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-copy_002dregion_002das_002dkill&quot;&gt;Complete copy-region-as-kill&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The complete function definition.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill-body&quot;&gt;copy-region-as-kill body&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The body of &lt;code&gt;copy-region-as-kill&lt;/code&gt;.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The Body of &lt;code&gt;copy-region-as-kill&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#last_002dcommand-_0026-this_002dcommand&quot;&gt;last-command &amp;amp; this-command&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dappend-function&quot;&gt;kill-append function&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dnew-function&quot;&gt;kill-new function&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Initializing a Variable with &lt;code&gt;defvar&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#See-variable-current-value&quot;&gt;See variable current value&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defvar-and-asterisk&quot;&gt;defvar and asterisk&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;How Lists are Implemented

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lists-diagrammed&quot;&gt;Lists diagrammed&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Symbols-as-Chest&quot;&gt;Symbols as Chest&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Exploring a powerful metaphor.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Exercise&quot;&gt;List Exercise&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Yanking Text Back

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Kill-Ring-Overview&quot;&gt;Kill Ring Overview&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dring_002dyank_002dpointer&quot;&gt;kill-ring-yank-pointer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The kill ring is a list.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#yank-nthcdr-Exercises&quot;&gt;yank nthcdr Exercises&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; variable.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Loops and Recursion

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#while&quot;&gt;while&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Causing a stretch of code to repeat.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#dolist-dotimes&quot;&gt;dolist dotimes&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursion&quot;&gt;Recursion&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Causing a function to call itself.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Looping-exercise&quot;&gt;Looping exercise&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;while&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Looping-with-while&quot;&gt;Looping with while&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Repeat so long as test returns true.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loop-Example&quot;&gt;Loop Example&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A &lt;code&gt;while&lt;/code&gt; loop that uses a list.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#print_002delements_002dof_002dlist&quot;&gt;print-elements-of-list&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Uses &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;car&lt;/code&gt;, &lt;code&gt;cdr&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop&quot;&gt;Incrementing Loop&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A loop with an incrementing counter.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop-Details&quot;&gt;Incrementing Loop Details&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Decrementing-Loop&quot;&gt;Decrementing Loop&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A loop with a decrementing counter.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Details of an Incrementing Loop

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Example&quot;&gt;Incrementing Example&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Counting pebbles in a triangle.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Inc-Example-parts&quot;&gt;Inc Example parts&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The parts of the function definition.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Inc-Example-altogether&quot;&gt;Inc Example altogether&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Putting the function definition together.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Loop with a Decrementing Counter

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Decrementing-Example&quot;&gt;Decrementing Example&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;More pebbles on the beach.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Dec-Example-parts&quot;&gt;Dec Example parts&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The parts of the function definition.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Dec-Example-altogether&quot;&gt;Dec Example altogether&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Putting the function definition together.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Save your time: &lt;code&gt;dolist&lt;/code&gt; and &lt;code&gt;dotimes&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#dolist&quot;&gt;dolist&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#dotimes&quot;&gt;dotimes&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Recursion

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Building-Robots&quot;&gt;Building Robots&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Same model, different serial number ...&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursive-Definition-Parts&quot;&gt;Recursive Definition Parts&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Walk until you stop ...&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursion-with-list&quot;&gt;Recursion with list&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Using a list as the test whether to recurse.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursive-triangle-function&quot;&gt;Recursive triangle function&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursion-with-cond&quot;&gt;Recursion with cond&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursive-Patterns&quot;&gt;Recursive Patterns&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Often used templates.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#No-Deferment&quot;&gt;No Deferment&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Don&#39;t store up work ...&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#No-deferment-solution&quot;&gt;No deferment solution&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Recursion in Place of a Counter

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursive-Example-arg-of-1-or-2&quot;&gt;Recursive Example arg of 1 or 2&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursive-Example-arg-of-3-or-4&quot;&gt;Recursive Example arg of 3 or 4&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Recursive Patterns

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Every&quot;&gt;Every&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Accumulate&quot;&gt;Accumulate&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Keep&quot;&gt;Keep&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Regular Expression Searches

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#sentence_002dend&quot;&gt;sentence-end&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The regular expression for &lt;code&gt;sentence-end&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#re_002dsearch_002dforward&quot;&gt;re-search-forward&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Very similar to &lt;code&gt;search-forward&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#forward_002dsentence&quot;&gt;forward-sentence&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A straightforward example of regexp search.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#forward_002dparagraph&quot;&gt;forward-paragraph&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A somewhat complex example.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#etags&quot;&gt;etags&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to create your own &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;TAGS&lt;/span&gt;&lt;/samp&gt; table.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Regexp-Review&quot;&gt;Regexp Review&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#re_002dsearch-Exercises&quot;&gt;re-search Exercises&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;forward-sentence&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-forward_002dsentence&quot;&gt;Complete forward-sentence&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fwd_002dsentence-while-loops&quot;&gt;fwd-sentence while loops&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Two &lt;code&gt;while&lt;/code&gt; loops.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fwd_002dsentence-re_002dsearch&quot;&gt;fwd-sentence re-search&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A regular expression search.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;forward-paragraph&lt;/code&gt;: a Goldmine of Functions

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#forward_002dparagraph-in-brief&quot;&gt;forward-paragraph in brief&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Key parts of the function definition.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fwd_002dpara-let&quot;&gt;fwd-para let&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The &lt;code&gt;let*&lt;/code&gt; expression.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fwd_002dpara-while&quot;&gt;fwd-para while&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The forward motion &lt;code&gt;while&lt;/code&gt; loop.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Counting: Repetition and Regexps

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Why-Count-Words&quot;&gt;Why Count Words&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#count_002dwords_002dexample&quot;&gt;count-words-example&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Use a regexp, but find a problem.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#recursive_002dcount_002dwords&quot;&gt;recursive-count-words&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Start with case of no words in region.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Counting-Exercise&quot;&gt;Counting Exercise&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The &lt;code&gt;count-words-example&lt;/code&gt; Function

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Design-count_002dwords_002dexample&quot;&gt;Design count-words-example&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The definition using a &lt;code&gt;while&lt;/code&gt; loop.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Whitespace-Bug&quot;&gt;Whitespace Bug&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The Whitespace Bug in &lt;code&gt;count-words-example&lt;/code&gt;.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Counting Words in a &lt;code&gt;defun&lt;/code&gt;

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Divide-and-Conquer&quot;&gt;Divide and Conquer&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Words-and-Symbols&quot;&gt;Words and Symbols&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;What to count?&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Syntax&quot;&gt;Syntax&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;What constitutes a word or symbol?&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#count_002dwords_002din_002ddefun&quot;&gt;count-words-in-defun&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Very like &lt;code&gt;count-words-example&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Several-defuns&quot;&gt;Several defuns&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Counting several defuns in a file.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Find-a-File&quot;&gt;Find a File&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Do you want to look at a file?&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#lengths_002dlist_002dfile&quot;&gt;lengths-list-file&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A list of the lengths of many definitions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Several-files&quot;&gt;Several files&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Counting in definitions in different files.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Several-files-recursively&quot;&gt;Several files recursively&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Recursively counting in different files.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Prepare-the-data&quot;&gt;Prepare the data&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Prepare the data for display in a graph.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Count Words in &lt;code&gt;defuns&lt;/code&gt; in Different Files

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#lengths_002dlist_002dmany_002dfiles&quot;&gt;lengths-list-many-files&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Return a list of the lengths of defuns.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append&quot;&gt;append&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Attach one list to another.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Prepare the Data for Display in a Graph

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Data-for-Display-in-Detail&quot;&gt;Data for Display in Detail&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Sorting&quot;&gt;Sorting&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Sorting lists.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Files-List&quot;&gt;Files List&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Making a list of files.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Counting-function-definitions&quot;&gt;Counting function definitions&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Readying a Graph

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Columns-of-a-graph&quot;&gt;Columns of a graph&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#graph_002dbody_002dprint&quot;&gt;graph-body-print&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to print the body of a graph.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#recursive_002dgraph_002dbody_002dprint&quot;&gt;recursive-graph-body-print&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Printed-Axes&quot;&gt;Printed Axes&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Line-Graph-Exercise&quot;&gt;Line Graph Exercise&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Your &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.emacs&lt;/span&gt;&lt;/samp&gt; File

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Default-Configuration&quot;&gt;Default Configuration&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Site_002dwide-Init&quot;&gt;Site-wide Init&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;You can write site-wide init files.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defcustom&quot;&gt;defcustom&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Emacs will write code for you.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Beginning-a-_002eemacs-File&quot;&gt;Beginning a .emacs File&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to write a &lt;code&gt;.emacs file&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Text-and-Auto_002dfill&quot;&gt;Text and Auto-fill&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Automatically wrap lines.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Mail-Aliases&quot;&gt;Mail Aliases&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Use abbreviations for email addresses.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Indent-Tabs-Mode&quot;&gt;Indent Tabs Mode&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Don&#39;t use tabs with TeX&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Keybindings&quot;&gt;Keybindings&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Create some personal keybindings.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Keymaps&quot;&gt;Keymaps&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;More about key binding.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loading-Files&quot;&gt;Loading Files&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Load (i.e., evaluate) files automatically.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Autoload&quot;&gt;Autoload&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Make functions available.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Simple-Extension&quot;&gt;Simple Extension&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Define a function; bind it to a key.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#X11-Colors&quot;&gt;X11 Colors&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Colors in X.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Miscellaneous&quot;&gt;Miscellaneous&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Mode-Line&quot;&gt;Mode Line&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to customize your mode line.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Debugging

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#debug&quot;&gt;debug&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to use the built-in debugger.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#debug_002don_002dentry&quot;&gt;debug-on-entry&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Start debugging when you call a function.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#debug_002don_002dquit&quot;&gt;debug-on-quit&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Start debugging when you quit with &lt;kbd&gt;C-g&lt;/kbd&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#edebug&quot;&gt;edebug&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to use Edebug, a source level debugger.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Debugging-Exercises&quot;&gt;Debugging Exercises&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Handling the Kill Ring

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#What-the-Kill-Ring-Does&quot;&gt;What the Kill Ring Does&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#current_002dkill&quot;&gt;current-kill&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#yank&quot;&gt;yank&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Paste a copy of a clipped element.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#yank_002dpop&quot;&gt;yank-pop&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Insert element pointed to.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#ring-file&quot;&gt;ring file&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The &lt;code&gt;current-kill&lt;/code&gt; Function

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Code-for-current_002dkill&quot;&gt;Code for current-kill&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Understanding-current_002dkill&quot;&gt;Understanding current-kill&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;&lt;code&gt;current-kill&lt;/code&gt; in Outline

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Body-of-current_002dkill&quot;&gt;Body of current-kill&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Digression-concerning-error&quot;&gt;Digression concerning error&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to mislead humans, but not computers.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Determining-the-Element&quot;&gt;Determining the Element&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;A Graph with Labeled Axes

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Labeled-Example&quot;&gt;Labeled Example&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#print_002dgraph-Varlist&quot;&gt;print-graph Varlist&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;let&lt;/code&gt; expression in &lt;code&gt;print-graph&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#print_002dY_002daxis&quot;&gt;print-Y-axis&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Print a label for the vertical axis.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#print_002dX_002daxis&quot;&gt;print-X-axis&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Print a horizontal label.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Print-Whole-Graph&quot;&gt;Print Whole Graph&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The function to print a complete graph.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The &lt;code&gt;print-Y-axis&lt;/code&gt; Function

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#print_002dY_002daxis-in-Detail&quot;&gt;print-Y-axis in Detail&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Height-of-label&quot;&gt;Height of label&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;What height for the Y axis?&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Compute-a-Remainder&quot;&gt;Compute a Remainder&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to compute the remainder of a division.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Y-Axis-Element&quot;&gt;Y Axis Element&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Construct a line for the Y axis.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Y_002daxis_002dcolumn&quot;&gt;Y-axis-column&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Generate a list of Y axis labels.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#print_002dY_002daxis-Penultimate&quot;&gt;print-Y-axis Penultimate&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A not quite final version.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;The &lt;code&gt;print-X-axis&lt;/code&gt; Function

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Similarities-differences&quot;&gt;Similarities differences&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Much like &lt;code&gt;print-Y-axis&lt;/code&gt;, but not exactly.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#X-Axis-Tic-Marks&quot;&gt;X Axis Tic Marks&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Create tic marks for the horizontal axis.

  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; colspan=&quot;2&quot; style=&quot;text-align: left;&quot;&gt;Printing the Whole Graph

  &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#The-final-version&quot;&gt;The final version&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;A few changes.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Test-print_002dgraph&quot;&gt;Test print-graph&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Run a short test.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Graphing-words-in-defuns&quot;&gt;Graphing words in defuns&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Executing the final code.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#lambda&quot;&gt;lambda&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;How to write an anonymous function.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mapcar&quot;&gt;mapcar&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Apply a function to elements of a list.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Another-Bug&quot;&gt;Another Bug&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;Yet another bug ... most insidious.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td bgcolor=&quot;white&quot;&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Final-printed-graph&quot;&gt;Final printed graph&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;The graph itself!
  &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Preface&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;next&quot;&gt;List Processing&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;previous&quot;&gt;Top&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;unnumbered&quot;&gt;
Preface&lt;/h2&gt;
Most of the GNU Emacs integrated environment is written in the programming
language called Emacs Lisp.  The code written in this programming
language is the software—the sets of instructions—that tell the
computer what to do when you give it commands.  Emacs is designed so
that you can write new code in Emacs Lisp and easily install it as an
extension to the editor.

   &lt;br /&gt;
(GNU Emacs is sometimes called an “extensible editor”, but it does
much more than provide editing capabilities.  It is better to refer to
Emacs as an “extensible computing environment”.  However, that
phrase is quite a mouthful.  It is easier to refer to Emacs simply as
an editor.  Moreover, everything you do in Emacs—find the Mayan date
and phases of the moon, simplify polynomials, debug code, manage
files, read letters, write books—all these activities are kinds of
editing in the most general sense of the word.)

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Why&quot;&gt;Why&lt;/a&gt;:                          Why learn Emacs Lisp? 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#On-Reading-this-Text&quot;&gt;On Reading this Text&lt;/a&gt;:         Read, gain familiarity, pick up habits.... 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Who-You-Are&quot;&gt;Who You Are&lt;/a&gt;:                  For whom this is written. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-History&quot;&gt;Lisp History&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Note-for-Novices&quot;&gt;Note for Novices&lt;/a&gt;:             You can read this as a novice. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Thank-You&quot;&gt;Thank You&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Why&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#On-Reading-this-Text&quot; rel=&quot;next&quot;&gt;On Reading this Text&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Preface&quot; rel=&quot;up&quot;&gt;Preface&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
Why Study Emacs Lisp?&lt;/h3&gt;
Although Emacs Lisp is usually thought of in association only with Emacs,
it is a full computer programming language.  You can use Emacs Lisp as
you would any other programming language.

   &lt;br /&gt;
Perhaps you want to understand programming; perhaps you want to extend
Emacs; or perhaps you want to become a programmer.  This introduction to
Emacs Lisp is designed to get you started: to guide you in learning the
fundamentals of programming, and more importantly, to show you how you
can teach yourself to go further.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;On-Reading-this-Text&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Who-You-Are&quot; rel=&quot;next&quot;&gt;Who You Are&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Why&quot; rel=&quot;previous&quot;&gt;Why&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Preface&quot; rel=&quot;up&quot;&gt;Preface&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
On Reading this Text&lt;/h3&gt;
All through this document, you will see little sample programs you can
run inside of Emacs.  If you read this document in Info inside of GNU
Emacs, you can run the programs as they appear.  (This is easy to do and
is explained when the examples are presented.)  Alternatively, you can
read this introduction as a printed book while sitting beside a computer
running Emacs.  (This is what I like to do; I like printed books.)  If
you don&#39;t have a running Emacs beside you, you can still read this book,
but in this case, it is best to treat it as a novel or as a travel guide
to a country not yet visited: interesting, but not the same as being
there.

   &lt;br /&gt;
Much of this introduction is dedicated to walkthroughs or guided tours
of code used in GNU Emacs.  These tours are designed for two purposes:
first, to give you familiarity with real, working code (code you use
every day); and, second, to give you familiarity with the way Emacs
works.  It is interesting to see how a working environment is
implemented. 
Also, I
hope that you will pick up the habit of browsing through source code. 
You can learn from it and mine it for ideas.  Having GNU Emacs is like
having a dragon&#39;s cave of treasures.

   &lt;br /&gt;
In addition to learning about Emacs as an editor and Emacs Lisp as a
programming language, the examples and guided tours will give you an
opportunity to get acquainted with Emacs as a Lisp programming
environment.  GNU Emacs supports programming and provides tools that
you will want to become comfortable using, such as &lt;kbd&gt;M-.&lt;/kbd&gt; (the key
which invokes the &lt;code&gt;find-tag&lt;/code&gt; command).  You will also learn about
buffers and other objects that are part of the environment. 
Learning about these features of Emacs is like learning new routes
around your home town.

   &lt;br /&gt;
Finally, I hope to convey some of the skills for using Emacs to
learn aspects of programming that you don&#39;t know.  You can often use
Emacs to help you understand what puzzles you or to find out how to do
something new.  This self-reliance is not only a pleasure, but an
advantage.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Who-You-Are&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-History&quot; rel=&quot;next&quot;&gt;Lisp History&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#On-Reading-this-Text&quot; rel=&quot;previous&quot;&gt;On Reading this Text&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Preface&quot; rel=&quot;up&quot;&gt;Preface&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
For Whom This is Written&lt;/h3&gt;
This text is written as an elementary introduction for people who are
not programmers.  If you are a programmer, you may not be satisfied with
this primer.  The reason is that you may have become expert at reading
reference manuals and be put off by the way this text is organized.

   &lt;br /&gt;
An expert programmer who reviewed this text said to me:

   &lt;br /&gt;
&lt;blockquote&gt;
&lt;i&gt;I prefer to learn from reference manuals.  I “dive into” each
paragraph, and “come up for air” between paragraphs.&lt;/i&gt;

   &lt;i&gt;When I get to the end of a paragraph, I assume that that subject is
done, finished, that I know everything I need (with the
possible exception of the case when the next paragraph starts talking
about it in more detail).  I expect that a well written reference manual
will not have a lot of redundancy, and that it will have excellent
pointers to the (one) place where the information I want is.&lt;/i&gt;
&lt;/blockquote&gt;
This introduction is not written for this person!

   &lt;br /&gt;
Firstly, I try to say everything at least three times: first, to
introduce it; second, to show it in context; and third, to show it in a
different context, or to review it.

   &lt;br /&gt;
Secondly, I hardly ever put all the information about a subject in one
place, much less in one paragraph.  To my way of thinking, that imposes
too heavy a burden on the reader.  Instead I try to explain only what
you need to know at the time.  (Sometimes I include a little extra
information so you won&#39;t be surprised later when the additional
information is formally introduced.)

   &lt;br /&gt;
When you read this text, you are not expected to learn everything the
first time.  Frequently, you need only make, as it were, a `nodding
acquaintance&#39; with some of the items mentioned.  My hope is that I have
structured the text and given you enough hints that you will be alert to
what is important, and concentrate on it.

   &lt;br /&gt;
You will need to “dive into” some paragraphs; there is no other way
to read them.  But I have tried to keep down the number of such
paragraphs.  This book is intended as an approachable hill, rather than
as a daunting mountain.

   &lt;br /&gt;
This introduction to &lt;cite&gt;Programming in Emacs Lisp&lt;/cite&gt; has a companion
document,
&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Top&quot;&gt;The GNU Emacs Lisp Reference Manual&lt;/a&gt;. 
The reference manual has more detail than this introduction.  In the
reference manual, all the information about one topic is concentrated
in one place.  You should turn to it if you are like the programmer
quoted above.  And, of course, after you have read this
&lt;cite&gt;Introduction&lt;/cite&gt;, you will find the &lt;cite&gt;Reference Manual&lt;/cite&gt; useful
when you are writing your own programs.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Lisp-History&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Note-for-Novices&quot; rel=&quot;next&quot;&gt;Note for Novices&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Who-You-Are&quot; rel=&quot;previous&quot;&gt;Who You Are&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Preface&quot; rel=&quot;up&quot;&gt;Preface&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
Lisp History&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Lisp-history-1&quot;&gt;&lt;/a&gt;
Lisp was first developed in the late 1950s at the Massachusetts
Institute of Technology for research in artificial intelligence.  The
great power of the Lisp language makes it superior for other purposes as
well, such as writing editor commands and integrated environments.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Maclisp-2&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Common-Lisp-3&quot;&gt;&lt;/a&gt;GNU Emacs Lisp is largely inspired by Maclisp, which was written at MIT
in the 1960s.  It is somewhat inspired by Common Lisp, which became a
standard in the 1980s.  However, Emacs Lisp is much simpler than Common
Lisp.  (The standard Emacs distribution contains an optional extensions
file, &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;cl.el&lt;/span&gt;&lt;/samp&gt;, that adds many Common Lisp features to Emacs Lisp.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Note-for-Novices&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Thank-You&quot; rel=&quot;next&quot;&gt;Thank You&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-History&quot; rel=&quot;previous&quot;&gt;Lisp History&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Preface&quot; rel=&quot;up&quot;&gt;Preface&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
A Note for Novices&lt;/h3&gt;
If you don&#39;t know GNU Emacs, you can still read this document
profitably.  However, I recommend you learn Emacs, if only to learn to
move around your computer screen.  You can teach yourself how to use
Emacs with the on-line tutorial.  To use it, type &lt;kbd&gt;C-h t&lt;/kbd&gt;.  (This
means you press and release the &amp;lt;CTRL&amp;gt; key and the &lt;kbd&gt;h&lt;/kbd&gt; at the
same time, and then press and release &lt;kbd&gt;t&lt;/kbd&gt;.)

   &lt;br /&gt;
Also, I often refer to one of Emacs&#39;s standard commands by listing the
keys which you press to invoke the command and then giving the name of
the command in parentheses, like this: &lt;kbd&gt;M-C-\&lt;/kbd&gt;
(&lt;code&gt;indent-region&lt;/code&gt;).  What this means is that the
&lt;code&gt;indent-region&lt;/code&gt; command is customarily invoked by typing
&lt;kbd&gt;M-C-\&lt;/kbd&gt;.  (You can, if you wish, change the keys that are typed to
invoke the command; this is called &lt;dfn&gt;rebinding&lt;/dfn&gt;.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Keymaps&quot;&gt;Keymaps&lt;/a&gt;.)  The abbreviation &lt;kbd&gt;M-C-\&lt;/kbd&gt; means that you type your
&amp;lt;META&amp;gt; key, &amp;lt;CTRL&amp;gt; key and &amp;lt;\&amp;gt; key all at the same time. 
(On many modern keyboards the &amp;lt;META&amp;gt; key is labeled
&amp;lt;ALT&amp;gt;.) 
Sometimes a combination like this is called a keychord, since it is
similar to the way you play a chord on a piano.  If your keyboard does
not have a &amp;lt;META&amp;gt; key, the &amp;lt;ESC&amp;gt; key prefix is used in place
of it.  In this case, &lt;kbd&gt;M-C-\&lt;/kbd&gt; means that you press and release your
&amp;lt;ESC&amp;gt; key and then type the &amp;lt;CTRL&amp;gt; key and the &amp;lt;\&amp;gt; key at
the same time.  But usually &lt;kbd&gt;M-C-\&lt;/kbd&gt; means press the &amp;lt;CTRL&amp;gt; key
along with the key that is labeled &amp;lt;ALT&amp;gt; and, at the same time,
press the &amp;lt;\&amp;gt; key.

   &lt;br /&gt;
In addition to typing a lone keychord, you can prefix what you type
with &lt;kbd&gt;C-u&lt;/kbd&gt;, which is called the `universal argument&#39;.  The
&lt;kbd&gt;C-u&lt;/kbd&gt; keychord passes an argument to the subsequent command. 
Thus, to indent a region of plain text by 6 spaces, mark the region,
and then type &lt;kbd&gt;C-u&amp;nbsp;6&amp;nbsp;M-C-\&lt;/kbd&gt;.  (If you do not specify a number,
Emacs either passes the number 4 to the command or otherwise runs the
command differently than it would otherwise.)  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Arguments&quot;&gt;Numeric Arguments&lt;/a&gt;.

   &lt;br /&gt;
If you are reading this in Info using GNU Emacs, you can read through
this whole document just by pressing the space bar, &amp;lt;SPC&amp;gt;. 
(To learn about Info, type &lt;kbd&gt;C-h i&lt;/kbd&gt; and then select Info.)

   &lt;br /&gt;
A note on terminology:  when I use the word Lisp alone, I often am
referring to the various dialects of Lisp in general, but when I speak
of Emacs Lisp, I am referring to GNU Emacs Lisp in particular.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Thank-You&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Note-for-Novices&quot; rel=&quot;previous&quot;&gt;Note for Novices&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Preface&quot; rel=&quot;up&quot;&gt;Preface&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
Thank You&lt;/h3&gt;
My thanks to all who helped me with this book.  My especial thanks to
&lt;span class=&quot;roman&quot;&gt;Jim Blandy&lt;/span&gt;, &lt;span class=&quot;roman&quot;&gt;Noah Friedman&lt;/span&gt;, Jim&amp;nbsp;Kingdon, &lt;span class=&quot;roman&quot;&gt;Roland
McGrath&lt;/span&gt;, Frank&amp;nbsp;Ritter, Randy&amp;nbsp;Smith, Richard&amp;nbsp;M.&amp;nbsp;Stallman, and Melissa&amp;nbsp;Weisshaus.  My thanks also go to both
Philip&amp;nbsp;Johnson and David&amp;nbsp;Stampe for their patient
encouragement.  My mistakes are my own.

                                  &lt;br /&gt;
&lt;div align=&quot;right&quot;&gt;
Robert J. Chassell
                        &lt;a href=&quot;mailto:bob@gnu.org&quot;&gt;bob@gnu.org&lt;/a&gt;
   &lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;List-Processing&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Practicing-Evaluation&quot; rel=&quot;next&quot;&gt;Practicing Evaluation&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Preface&quot; rel=&quot;previous&quot;&gt;Preface&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
1 List Processing&lt;/h2&gt;
To the untutored eye, Lisp is a strange programming language.  In Lisp
code there are parentheses everywhere.  Some people even claim that
the name stands for `Lots of Isolated Silly Parentheses&#39;.  But the
claim is unwarranted.  Lisp stands for LISt Processing, and the
programming language handles &lt;i&gt;lists&lt;/i&gt; (and lists of lists) by
putting them between parentheses.  The parentheses mark the boundaries
of the list.  Sometimes a list is preceded by a single apostrophe or
quotation mark, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;&#39;&lt;/span&gt;&lt;/samp&gt;’&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-1&quot; name=&quot;fnd-1&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;  Lists are the basis of Lisp.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Lists&quot;&gt;Lisp Lists&lt;/a&gt;:                   What are lists? 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Run-a-Program&quot;&gt;Run a Program&lt;/a&gt;:                Any list in Lisp is a program ready to run. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Making-Errors&quot;&gt;Making Errors&lt;/a&gt;:                Generating an error message. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Names-_0026-Definitions&quot;&gt;Names &amp;amp; Definitions&lt;/a&gt;:          Names of symbols and function definitions. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Interpreter&quot;&gt;Lisp Interpreter&lt;/a&gt;:             What the Lisp interpreter does. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluation&quot;&gt;Evaluation&lt;/a&gt;:                   Running a program. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;7&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot;&gt;Variables&lt;/a&gt;:                    Returning a value from a variable. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;8&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Arguments&quot;&gt;Arguments&lt;/a&gt;:                    Passing information to a function. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;9&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#set-_0026-setq&quot;&gt;set &amp;amp; setq&lt;/a&gt;:                   Setting the value of a variable. 
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Summary&quot;&gt;Summary&lt;/a&gt;:                      The major points. 
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Error-Message-Exercises&quot;&gt;Error Message Exercises&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Lisp-Lists&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Run-a-Program&quot; rel=&quot;next&quot;&gt;Run a Program&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3&gt;
&amp;nbsp;
&lt;/h3&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.1 Lisp Lists&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Lisp-Lists-4&quot;&gt;&lt;/a&gt;
In Lisp, a list looks like this: &lt;code&gt;&#39;(rose violet daisy buttercup)&lt;/code&gt;. 
This list is preceded by a single apostrophe.  It could just as well be
written as follows, which looks more like the kind of list you are likely
to be familiar with:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &#39;(rose
       violet
       daisy
       buttercup)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The elements of this list are the names of the four different flowers,
separated from each other by whitespace and surrounded by parentheses,
like flowers in a field with a stone wall around them. 
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Flowers-in-a-field-5&quot;&gt;&lt;/a&gt;

&lt;/div&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Numbers-Lists&quot;&gt;Numbers Lists&lt;/a&gt;:                List have numbers, other lists, in them. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Atoms&quot;&gt;Lisp Atoms&lt;/a&gt;:                   Elemental entities. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Whitespace-in-Lists&quot;&gt;Whitespace in Lists&lt;/a&gt;:          Formatting lists to be readable. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Typing-Lists&quot;&gt;Typing Lists&lt;/a&gt;:                 How GNU Emacs helps you type lists. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Numbers-Lists&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Atoms&quot; rel=&quot;next&quot;&gt;Lisp Atoms&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Lists&quot; rel=&quot;up&quot;&gt;Lisp Lists&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
Numbers, Lists inside of Lists&lt;/h4&gt;
Lists can also have numbers in them, as in this list: &lt;code&gt;(+ 2 2)&lt;/code&gt;. 
This list has a plus-sign, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;+&lt;/span&gt;&lt;/samp&gt;’, followed by two ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;2&lt;/span&gt;&lt;/samp&gt;’s, each
separated by whitespace.

   &lt;br /&gt;
In Lisp, both data and programs are represented the same way; that is,
they are both lists of words, numbers, or other lists, separated by
whitespace and surrounded by parentheses.  (Since a program looks like
data, one program may easily serve as data for another; this is a very
powerful feature of Lisp.)  (Incidentally, these two parenthetical
remarks are &lt;em&gt;not&lt;/em&gt; Lisp lists, because they contain ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;;&lt;/span&gt;&lt;/samp&gt;’ and
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;.&lt;/span&gt;&lt;/samp&gt;’ as punctuation marks.)

   &lt;br /&gt;
Here is another list, this time with a list inside of it:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &#39;(this list has (a list inside of it))
&lt;/pre&gt;
The components of this list are the words ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;this&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;list&lt;/span&gt;&lt;/samp&gt;’,
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;has&lt;/span&gt;&lt;/samp&gt;’, and the list ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;(a list inside of it)&lt;/span&gt;&lt;/samp&gt;’.  The interior
list is made up of the words ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;a&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;list&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;inside&lt;/span&gt;&lt;/samp&gt;’,
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;of&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;it&lt;/span&gt;&lt;/samp&gt;’.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Lisp-Atoms&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Whitespace-in-Lists&quot; rel=&quot;next&quot;&gt;Whitespace in Lists&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Numbers-Lists&quot; rel=&quot;previous&quot;&gt;Numbers Lists&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Lists&quot; rel=&quot;up&quot;&gt;Lisp Lists&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.1.1 Lisp Atoms&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Lisp-Atoms-6&quot;&gt;&lt;/a&gt;
In Lisp, what we have been calling words are called &lt;dfn&gt;atoms&lt;/dfn&gt;.  This
term comes from the historical meaning of the word atom, which means
`indivisible&#39;.  As far as Lisp is concerned, the words we have been
using in the lists cannot be divided into any smaller parts and still
mean the same thing as part of a program; likewise with numbers and
single character symbols like ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;+&lt;/span&gt;&lt;/samp&gt;’.  On the other hand, unlike an
ancient atom, a list can be split into parts.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot;&gt;&lt;code&gt;car&lt;/code&gt; &lt;code&gt;cdr&lt;/code&gt; &amp;amp; &lt;code&gt;cons&lt;/code&gt; Fundamental Functions&lt;/a&gt;.)

   &lt;br /&gt;
In a list, atoms are separated from each other by whitespace.  They can be
right next to a parenthesis.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bempty-list_007d-defined-7&quot;&gt;&lt;/a&gt;Technically speaking, a list in Lisp consists of parentheses surrounding
atoms separated by whitespace or surrounding other lists or surrounding
both atoms and other lists.  A list can have just one atom in it or
have nothing in it at all.  A list with nothing in it looks like this:
&lt;code&gt;()&lt;/code&gt;, and is called the &lt;dfn&gt;empty list&lt;/dfn&gt;.  Unlike anything else, an
empty list is considered both an atom and a list at the same time.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Symbolic-expressions_002c-introduced-8&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bexpression_007d-defined-9&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bform_007d-defined-10&quot;&gt;&lt;/a&gt;The printed representation of both atoms and lists are called
&lt;dfn&gt;symbolic expressions&lt;/dfn&gt; or, more concisely, &lt;dfn&gt;s-expressions&lt;/dfn&gt;. 
The word &lt;dfn&gt;expression&lt;/dfn&gt; by itself can refer to either the printed
representation, or to the atom or list as it is held internally in the
computer.  Often, people use the term &lt;dfn&gt;expression&lt;/dfn&gt;
indiscriminately.  (Also, in many texts, the word &lt;dfn&gt;form&lt;/dfn&gt; is used
as a synonym for expression.)

   &lt;br /&gt;
Incidentally, the atoms that make up our universe were named such when
they were thought to be indivisible; but it has been found that physical
atoms are not indivisible.  Parts can split off an atom or it can
fission into two parts of roughly equal size.  Physical atoms were named
prematurely, before their truer nature was found.  In Lisp, certain
kinds of atom, such as an array, can be separated into parts; but the
mechanism for doing this is different from the mechanism for splitting a
list.  As far as list operations are concerned, the atoms of a list are
unsplittable.

   &lt;br /&gt;
As in English, the meanings of the component letters of a Lisp atom
are different from the meaning the letters make as a word.  For
example, the word for the South American sloth, the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;ai&lt;/span&gt;&lt;/samp&gt;’, is
completely different from the two words, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;a&lt;/span&gt;&lt;/samp&gt;’, and ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;i&lt;/span&gt;&lt;/samp&gt;’.

   &lt;br /&gt;
There are many kinds of atom in nature but only a few in Lisp: for
example, &lt;dfn&gt;numbers&lt;/dfn&gt;, such as 37, 511, or 1729, and &lt;dfn&gt;symbols&lt;/dfn&gt;, such
as ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;+&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;foo&lt;/span&gt;&lt;/samp&gt;’, or ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;forward-line&lt;/span&gt;&lt;/samp&gt;’.  The words we have
listed in the examples above are all symbols.  In everyday Lisp
conversation, the word “atom” is not often used, because programmers
usually try to be more specific about what kind of atom they are dealing
with.  Lisp programming is mostly about symbols (and sometimes numbers)
within lists.  (Incidentally, the preceding three word parenthetical
remark is a proper list in Lisp, since it consists of atoms, which in
this case are symbols, separated by whitespace and enclosed by
parentheses, without any non-Lisp punctuation.)

   &lt;br /&gt;
Text between double quotation marks—even sentences or
paragraphs—is also an atom.  Here is an example:
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Text-between-double-quotation-marks-11&quot;&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &#39;(this list includes &quot;text between quotation marks.&quot;)
&lt;/pre&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bstring_007d-defined-12&quot;&gt;&lt;/a&gt;In Lisp, all of the quoted text including the punctuation mark and the
blank spaces is a single atom.  This kind of atom is called a
&lt;dfn&gt;string&lt;/dfn&gt; (for `string of characters&#39;) and is the sort of thing that
is used for messages that a computer can print for a human to read. 
Strings are a different kind of atom than numbers or symbols and are
used differently.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Whitespace-in-Lists&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Typing-Lists&quot; rel=&quot;next&quot;&gt;Typing Lists&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Atoms&quot; rel=&quot;previous&quot;&gt;Lisp Atoms&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Lists&quot; rel=&quot;up&quot;&gt;Lisp Lists&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.1.2 Whitespace in Lists&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Whitespace-in-lists-13&quot;&gt;&lt;/a&gt;
The amount of whitespace in a list does not matter.  From the point of view
of the Lisp language,

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &#39;(this list
        looks like this)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
is exactly the same as this:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &#39;(this list looks like this)
&lt;/pre&gt;
Both examples show what to Lisp is the same list, the list made up of
the symbols ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;this&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;list&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;looks&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;like&lt;/span&gt;&lt;/samp&gt;’, and
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;this&lt;/span&gt;&lt;/samp&gt;’ in that order.

   &lt;br /&gt;
Extra whitespace and newlines are designed to make a list more readable
by humans.  When Lisp reads the expression, it gets rid of all the extra
whitespace (but it needs to have at least one space between atoms in
order to tell them apart.)

   &lt;br /&gt;
Odd as it seems, the examples we have seen cover almost all of what Lisp
lists look like!  Every other list in Lisp looks more or less like one
of these examples, except that the list may be longer and more complex. 
In brief, a list is between parentheses, a string is between quotation
marks, a symbol looks like a word, and a number looks like a number. 
(For certain situations, square brackets, dots and a few other special
characters may be used; however, we will go quite far without them.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Typing-Lists&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Whitespace-in-Lists&quot; rel=&quot;previous&quot;&gt;Whitespace in Lists&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Lists&quot; rel=&quot;up&quot;&gt;Lisp Lists&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.1.3 GNU Emacs Helps You Type Lists&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Help-typing-lists-14&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Formatting-help-15&quot;&gt;&lt;/a&gt;
When you type a Lisp expression in GNU Emacs using either Lisp
Interaction mode or Emacs Lisp mode, you have available to you several
commands to format the Lisp expression so it is easy to read.  For
example, pressing the &amp;lt;TAB&amp;gt; key automatically indents the line the
cursor is on by the right amount.  A command to properly indent the
code in a region is customarily bound to &lt;kbd&gt;M-C-\&lt;/kbd&gt;.  Indentation is
designed so that you can see which elements of a list belong to which
list—elements of a sub-list are indented more than the elements of
the enclosing list.

   &lt;br /&gt;
In addition, when you type a closing parenthesis, Emacs momentarily
jumps the cursor back to the matching opening parenthesis, so you can
see which one it is.  This is very useful, since every list you type
in Lisp must have its closing parenthesis match its opening
parenthesis.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Major-Modes&quot;&gt;Major Modes&lt;/a&gt;, for more information about Emacs&#39;s modes.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Run-a-Program&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Making-Errors&quot; rel=&quot;next&quot;&gt;Making Errors&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Lists&quot; rel=&quot;previous&quot;&gt;Lisp Lists&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.2 Run a Program&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Run-a-program-16&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Program_002c-running-one-17&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bevaluate_007d-defined-18&quot;&gt;&lt;/a&gt;A list in Lisp—any list—is a program ready to run.  If you run it
(for which the Lisp jargon is &lt;dfn&gt;evaluate&lt;/dfn&gt;), the computer will do one
of three things: do nothing except return to you the list itself; send
you an error message; or, treat the first symbol in the list as a
command to do something.  (Usually, of course, it is the last of these
three things that you really want!)


   &lt;br /&gt;
The single apostrophe, &lt;code&gt;&#39;&lt;/code&gt;, that I put in front of some of the
example lists in preceding sections is called a &lt;dfn&gt;quote&lt;/dfn&gt;; when it
precedes a list, it tells Lisp to do nothing with the list, other than
take it as it is written.  But if there is no quote preceding a list,
the first item of the list is special: it is a command for the computer
to obey.  (In Lisp, these commands are called &lt;em&gt;functions&lt;/em&gt;.)  The list
&lt;code&gt;(+ 2 2)&lt;/code&gt; shown above did not have a quote in front of it, so Lisp
understands that the &lt;code&gt;+&lt;/code&gt; is an instruction to do something with the
rest of the list: add the numbers that follow.

   &lt;br /&gt;
If you are reading this inside of GNU Emacs in Info, here is how you can
evaluate such a list:  place your cursor immediately after the right
hand parenthesis of the following list and then type &lt;kbd&gt;C-x C-e&lt;/kbd&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+ 2 2)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
You will see the number &lt;code&gt;4&lt;/code&gt; appear in the echo area.  (In the
jargon, what you have just done is “evaluate the list.”  The echo area
is the line at the bottom of the screen that displays or “echoes”
text.)  Now try the same thing with a quoted list:  place the cursor
right after the following list and type &lt;kbd&gt;C-x C-e&lt;/kbd&gt;:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &#39;(this is a quoted list)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
You will see &lt;code&gt;(this is a quoted list)&lt;/code&gt; appear in the echo area.

   &lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Lisp-interpreter_002c-explained-19&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Interpreter_002c-Lisp_002c-explained-20&quot;&gt;&lt;/a&gt;In both cases, what you are doing is giving a command to the program
inside of GNU Emacs called the &lt;dfn&gt;Lisp interpreter&lt;/dfn&gt;—giving the
interpreter a command to evaluate the expression.  The name of the Lisp
interpreter comes from the word for the task done by a human who comes
up with the meaning of an expression—who “interprets” it.

   &lt;br /&gt;
You can also evaluate an atom that is not part of a list—one that is
not surrounded by parentheses; again, the Lisp interpreter translates
from the humanly readable expression to the language of the computer. 
But before discussing this (see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot;&gt;Variables&lt;/a&gt;), we will discuss what the
Lisp interpreter does when you make an error.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Making-Errors&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Names-_0026-Definitions&quot; rel=&quot;next&quot;&gt;Names &amp;amp; Definitions&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Run-a-Program&quot; rel=&quot;previous&quot;&gt;Run a Program&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.3 Generate an Error Message&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Generate-an-error-message-21&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Error-message-generation-22&quot;&gt;&lt;/a&gt;
Partly so you won&#39;t worry if you do it accidentally, we will now give
a command to the Lisp interpreter that generates an error message. 
This is a harmless activity; and indeed, we will often try to generate
error messages intentionally.  Once you understand the jargon, error
messages can be informative.  Instead of being called “error”
messages, they should be called “help” messages.  They are like
signposts to a traveler in a strange country; deciphering them can be
hard, but once understood, they can point the way.

   &lt;br /&gt;
The error message is generated by a built-in GNU Emacs debugger.  We
will `enter the debugger&#39;.  You get out of the debugger by typing &lt;code&gt;q&lt;/code&gt;.

   &lt;br /&gt;
What we will do is evaluate a list that is not quoted and does not
have a meaningful command as its first element.  Here is a list almost
exactly the same as the one we just used, but without the single-quote
in front of it.  Position the cursor right after it and type &lt;kbd&gt;C-x
C-e&lt;/kbd&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (this is an unquoted list)
&lt;/pre&gt;
A &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Backtrace*&lt;/span&gt;&lt;/samp&gt; window will open up and you should see the
following in it:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     ---------- Buffer: *Backtrace* ----------
     Debugger entered--Lisp error: (void-function this)
       (this is an unquoted list)
       eval((this is an unquoted list))
       eval-last-sexp-1(nil)
       eval-last-sexp(nil)
       call-interactively(eval-last-sexp)
     ---------- Buffer: *Backtrace* ----------
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Your cursor will be in this window (you may have to wait a few seconds
before it becomes visible).  To quit the debugger and make the
debugger window go away, type:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     q
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Please type &lt;kbd&gt;q&lt;/kbd&gt; right now, so you become confident that you can
get out of the debugger.  Then, type &lt;kbd&gt;C-x C-e&lt;/kbd&gt; again to re-enter
it.

   &lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bfunction_007d-defined-23&quot;&gt;&lt;/a&gt;Based on what we already know, we can almost read this error message.

   &lt;br /&gt;
You read the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Backtrace*&lt;/span&gt;&lt;/samp&gt; buffer from the bottom up; it tells
you what Emacs did.  When you typed &lt;kbd&gt;C-x C-e&lt;/kbd&gt;, you made an
interactive call to the command &lt;code&gt;eval-last-sexp&lt;/code&gt;.  &lt;code&gt;eval&lt;/code&gt; is
an abbreviation for `evaluate&#39; and &lt;code&gt;sexp&lt;/code&gt; is an abbreviation for
`symbolic expression&#39;.  The command means `evaluate last symbolic
expression&#39;, which is the expression just before your cursor.

   &lt;br /&gt;
Each line above tells you what the Lisp interpreter evaluated next. 
The most recent action is at the top.  The buffer is called the
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Backtrace*&lt;/span&gt;&lt;/samp&gt; buffer because it enables you to track Emacs
backwards.

   &lt;br /&gt;
At the top of the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Backtrace*&lt;/span&gt;&lt;/samp&gt; buffer, you see the line:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     Debugger entered--Lisp error: (void-function this)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The Lisp interpreter tried to evaluate the first atom of the list, the
word ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;this&lt;/span&gt;&lt;/samp&gt;’.  It is this action that generated the error message
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;void-function this&lt;/span&gt;&lt;/samp&gt;’.

   &lt;/div&gt;
The message contains the words ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;void-function&lt;/span&gt;&lt;/samp&gt;’ and ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;this&lt;/span&gt;&lt;/samp&gt;’.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bfunction_007d-defined-24&quot;&gt;&lt;/a&gt;The word ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;function&lt;/span&gt;&lt;/samp&gt;’ was mentioned once before.  It is a very
important word.  For our purposes, we can define it by saying that a
&lt;dfn&gt;function&lt;/dfn&gt; is a set of instructions to the computer that tell the
computer to do something.

   &lt;br /&gt;
Now we can begin to understand the error message: ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;void-function
this&lt;/span&gt;&lt;/samp&gt;’.  The function (that is, the word ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;this&lt;/span&gt;&lt;/samp&gt;’) does not have a
definition of any set of instructions for the computer to carry out.

   &lt;br /&gt;
The slightly odd word, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;void-function&lt;/span&gt;&lt;/samp&gt;’, is designed to cover the
way Emacs Lisp is implemented, which is that when a symbol does not
have a function definition attached to it, the place that should
contain the instructions is `void&#39;.

   &lt;br /&gt;
On the other hand, since we were able to add 2 plus 2 successfully, by
evaluating &lt;code&gt;(+ 2 2)&lt;/code&gt;, we can infer that the symbol &lt;code&gt;+&lt;/code&gt; must
have a set of instructions for the computer to obey and those
instructions must be to add the numbers that follow the &lt;code&gt;+&lt;/code&gt;.

   &lt;br /&gt;
It is possible to prevent Emacs entering the debugger in cases like
this.  We do not explain how to do that here, but we will mention what
the result looks like, because you may encounter a similar situation
if there is a bug in some Emacs code that you are using.  In such
cases, you will see only one line of error message; it will appear in
the echo area and look like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     Symbol&#39;s function definition is void: this
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The message goes away as soon as you type a key, even just to
move the cursor.

   &lt;/div&gt;
We know the meaning of the word ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Symbol&lt;/span&gt;&lt;/samp&gt;’.  It refers to the first
atom of the list, the word ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;this&lt;/span&gt;&lt;/samp&gt;’.  The word ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;function&lt;/span&gt;&lt;/samp&gt;’
refers to the instructions that tell the computer what to do. 
(Technically, the symbol tells the computer where to find the
instructions, but this is a complication we can ignore for the
moment.)

   &lt;br /&gt;
The error message can be understood: ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Symbol&#39;s function
definition is void: this&lt;/span&gt;&lt;/samp&gt;’.  The symbol (that is, the word
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;this&lt;/span&gt;&lt;/samp&gt;’) lacks instructions for the computer to carry out.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Names-&amp;amp;-Definitions&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Names-_0026-Definitions&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Interpreter&quot; rel=&quot;next&quot;&gt;Lisp Interpreter&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Making-Errors&quot; rel=&quot;previous&quot;&gt;Making Errors&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.4 Symbol Names and Function Definitions&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Symbol-names-25&quot;&gt;&lt;/a&gt;
We can articulate another characteristic of Lisp based on what we have
discussed so far—an important characteristic: a symbol, like
&lt;code&gt;+&lt;/code&gt;, is not itself the set of instructions for the computer to
carry out.  Instead, the symbol is used, perhaps temporarily, as a way
of locating the definition or set of instructions.  What we see is the
name through which the instructions can be found.  Names of people
work the same way.  I can be referred to as ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Bob&lt;/span&gt;&lt;/samp&gt;’; however, I am
not the letters ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;B&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;o&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;b&lt;/span&gt;&lt;/samp&gt;’ but am, or was, the
consciousness consistently associated with a particular life-form. 
The name is not me, but it can be used to refer to me.

   &lt;br /&gt;
In Lisp, one set of instructions can be attached to several names. 
For example, the computer instructions for adding numbers can be
linked to the symbol &lt;code&gt;plus&lt;/code&gt; as well as to the symbol &lt;code&gt;+&lt;/code&gt;
(and are in some dialects of Lisp).  Among humans, I can be referred
to as ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Robert&lt;/span&gt;&lt;/samp&gt;’ as well as ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Bob&lt;/span&gt;&lt;/samp&gt;’ and by other words as well.

   &lt;br /&gt;
On the other hand, a symbol can have only one function definition
attached to it at a time.  Otherwise, the computer would be confused as
to which definition to use.  If this were the case among people, only
one person in the world could be named ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Bob&lt;/span&gt;&lt;/samp&gt;’.  However, the function
definition to which the name refers can be changed readily. 
(See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Install&quot;&gt;Install a Function Definition&lt;/a&gt;.)

   &lt;br /&gt;
Since Emacs Lisp is large, it is customary to name symbols in a way
that identifies the part of Emacs to which the function belongs. 
Thus, all the names for functions that deal with Texinfo start with
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;texinfo-&lt;/span&gt;&lt;/samp&gt;’ and those for functions that deal with reading mail
start with ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;rmail-&lt;/span&gt;&lt;/samp&gt;’.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Lisp-Interpreter&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluation&quot; rel=&quot;next&quot;&gt;Evaluation&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Names-_0026-Definitions&quot; rel=&quot;previous&quot;&gt;Names &amp;amp; Definitions&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.5 The Lisp Interpreter&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Lisp-interpreter_002c-what-it-does-26&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Interpreter_002c-what-it-does-27&quot;&gt;&lt;/a&gt;
Based on what we have seen, we can now start to figure out what the
Lisp interpreter does when we command it to evaluate a list. 
First, it looks to see whether there is a quote before the list; if
there is, the interpreter just gives us the list.  On the other
hand, if there is no quote, the interpreter looks at the first element
in the list and sees whether it has a function definition.  If it does,
the interpreter carries out the instructions in the function definition. 
Otherwise, the interpreter prints an error message.

   &lt;br /&gt;
This is how Lisp works.  Simple.  There are added complications which we
will get to in a minute, but these are the fundamentals.  Of course, to
write Lisp programs, you need to know how to write function definitions
and attach them to names, and how to do this without confusing either
yourself or the computer.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complications&quot;&gt;Complications&lt;/a&gt;:                Variables, Special forms, Lists within. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Byte-Compiling&quot;&gt;Byte Compiling&lt;/a&gt;:               Specially processing code for speed. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Complications&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Byte-Compiling&quot; rel=&quot;next&quot;&gt;Byte Compiling&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Interpreter&quot; rel=&quot;up&quot;&gt;Lisp Interpreter&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
Complications&lt;/h4&gt;
Now, for the first complication.  In addition to lists, the Lisp
interpreter can evaluate a symbol that is not quoted and does not have
parentheses around it.  The Lisp interpreter will attempt to determine
the symbol&#39;s value as a &lt;dfn&gt;variable&lt;/dfn&gt;.  This situation is described
in the section on variables.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot;&gt;Variables&lt;/a&gt;.)

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Special-form-28&quot;&gt;&lt;/a&gt;The second complication occurs because some functions are unusual and do
not work in the usual manner.  Those that don&#39;t are called &lt;dfn&gt;special
forms&lt;/dfn&gt;.  They are used for special jobs, like defining a function, and
there are not many of them.  In the next few chapters, you will be
introduced to several of the more important special forms.

   &lt;br /&gt;
The third and final complication is this: if the function that the
Lisp interpreter is looking at is not a special form, and if it is part
of a list, the Lisp interpreter looks to see whether the list has a list
inside of it.  If there is an inner list, the Lisp interpreter first
figures out what it should do with the inside list, and then it works on
the outside list.  If there is yet another list embedded inside the
inner list, it works on that one first, and so on.  It always works on
the innermost list first.  The interpreter works on the innermost list
first, to evaluate the result of that list.  The result may be
used by the enclosing expression.

   &lt;br /&gt;
Otherwise, the interpreter works left to right, from one expression to
the next.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Byte-Compiling&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complications&quot; rel=&quot;previous&quot;&gt;Complications&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Interpreter&quot; rel=&quot;up&quot;&gt;Lisp Interpreter&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.5.1 Byte Compiling&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Byte-compiling-29&quot;&gt;&lt;/a&gt;
One other aspect of interpreting: the Lisp interpreter is able to
interpret two kinds of entity: humanly readable code, on which we will
focus exclusively, and specially processed code, called &lt;dfn&gt;byte
compiled&lt;/dfn&gt; code, which is not humanly readable.  Byte compiled code
runs faster than humanly readable code.

   &lt;br /&gt;
You can transform humanly readable code into byte compiled code by
running one of the compile commands such as &lt;code&gt;byte-compile-file&lt;/code&gt;. 
Byte compiled code is usually stored in a file that ends with a
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.elc&lt;/span&gt;&lt;/samp&gt; extension rather than a &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.el&lt;/span&gt;&lt;/samp&gt; extension.  You will
see both kinds of file in the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;emacs/lisp&lt;/span&gt;&lt;/samp&gt; directory; the files
to read are those with &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.el&lt;/span&gt;&lt;/samp&gt; extensions.

   &lt;br /&gt;
As a practical matter, for most things you might do to customize or
extend Emacs, you do not need to byte compile; and I will not discuss
the topic here.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Byte-Compilation&quot;&gt;Byte Compilation&lt;/a&gt;, for a full description of byte
compilation.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Evaluation&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot; rel=&quot;next&quot;&gt;Variables&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Interpreter&quot; rel=&quot;previous&quot;&gt;Lisp Interpreter&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.6 Evaluation&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Evaluation-30&quot;&gt;&lt;/a&gt;
When the Lisp interpreter works on an expression, the term for the
activity is called &lt;dfn&gt;evaluation&lt;/dfn&gt;.  We say that the interpreter
`evaluates the expression&#39;.  I&#39;ve used this term several times before. 
The word comes from its use in everyday language, `to ascertain the
value or amount of; to appraise&#39;, according to &lt;cite&gt;Webster&#39;s New
Collegiate Dictionary&lt;/cite&gt;.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#How-the-Interpreter-Acts&quot;&gt;How the Interpreter Acts&lt;/a&gt;:     Returns and Side Effects... 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluating-Inner-Lists&quot;&gt;Evaluating Inner Lists&lt;/a&gt;:       Lists within lists... 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;How-the-Interpreter-Acts&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluating-Inner-Lists&quot; rel=&quot;next&quot;&gt;Evaluating Inner Lists&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluation&quot; rel=&quot;up&quot;&gt;Evaluation&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
How the Lisp Interpreter Acts&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007breturned-value_007d-explained-31&quot;&gt;&lt;/a&gt;After evaluating an expression, the Lisp interpreter will most likely
&lt;dfn&gt;return&lt;/dfn&gt; the value that the computer produces by carrying out the
instructions it found in the function definition, or perhaps it will
give up on that function and produce an error message.  (The interpreter
may also find itself tossed, so to speak, to a different function or it
may attempt to repeat continually what it is doing for ever and ever in
what is called an `infinite loop&#39;.  These actions are less common; and
we can ignore them.)  Most frequently, the interpreter returns a value.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bside-effect_007d-defined-32&quot;&gt;&lt;/a&gt;At the same time the interpreter returns a value, it may do something
else as well, such as move a cursor or copy a file; this other kind of
action is called a &lt;dfn&gt;side effect&lt;/dfn&gt;.  Actions that we humans think are
important, such as printing results, are often “side effects” to the
Lisp interpreter.  The jargon can sound peculiar, but it turns out that
it is fairly easy to learn to use side effects.

   &lt;br /&gt;
In summary, evaluating a symbolic expression most commonly causes the
Lisp interpreter to return a value and perhaps carry out a side effect;
or else produce an error.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Evaluating-Inner-Lists&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#How-the-Interpreter-Acts&quot; rel=&quot;previous&quot;&gt;How the Interpreter Acts&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluation&quot; rel=&quot;up&quot;&gt;Evaluation&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.6.1 Evaluating Inner Lists&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Inner-list-evaluation-33&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Evaluating-inner-lists-34&quot;&gt;&lt;/a&gt;
If evaluation applies to a list that is inside another list, the outer
list may use the value returned by the first evaluation as information
when the outer list is evaluated.  This explains why inner expressions
are evaluated first: the values they return are used by the outer
expressions.

   &lt;br /&gt;
We can investigate this process by evaluating another addition example. 
Place your cursor after the following expression and type &lt;kbd&gt;C-x C-e&lt;/kbd&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+ 2 (+ 3 3))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The number 8 will appear in the echo area.

   &lt;/div&gt;
What happens is that the Lisp interpreter first evaluates the inner
expression, &lt;code&gt;(+ 3 3)&lt;/code&gt;, for which the value 6 is returned; then it
evaluates the outer expression as if it were written &lt;code&gt;(+ 2 6)&lt;/code&gt;, which
returns the value 8.  Since there are no more enclosing expressions to
evaluate, the interpreter prints that value in the echo area.

   &lt;br /&gt;
Now it is easy to understand the name of the command invoked by the
keystrokes &lt;kbd&gt;C-x C-e&lt;/kbd&gt;: the name is &lt;code&gt;eval-last-sexp&lt;/code&gt;.  The
letters &lt;code&gt;sexp&lt;/code&gt; are an abbreviation for `symbolic expression&#39;, and
&lt;code&gt;eval&lt;/code&gt; is an abbreviation for `evaluate&#39;.  The command means
`evaluate last symbolic expression&#39;.

   &lt;br /&gt;
As an experiment, you can try evaluating the expression by putting the
cursor at the beginning of the next line immediately following the
expression, or inside the expression.

   &lt;br /&gt;
Here is another copy of the expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+ 2 (+ 3 3))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If you place the cursor at the beginning of the blank line that
immediately follows the expression and type &lt;kbd&gt;C-x C-e&lt;/kbd&gt;, you will
still get the value 8 printed in the echo area.  Now try putting the
cursor inside the expression.  If you put it right after the next to
last parenthesis (so it appears to sit on top of the last parenthesis),
you will get a 6 printed in the echo area!  This is because the command
evaluates the expression &lt;code&gt;(+ 3 3)&lt;/code&gt;.

   &lt;/div&gt;
Now put the cursor immediately after a number.  Type &lt;kbd&gt;C-x C-e&lt;/kbd&gt; and
you will get the number itself.  In Lisp, if you evaluate a number, you
get the number itself—this is how numbers differ from symbols.  If you
evaluate a list starting with a symbol like &lt;code&gt;+&lt;/code&gt;, you will get a
value returned that is the result of the computer carrying out the
instructions in the function definition attached to that name.  If a
symbol by itself is evaluated, something different happens, as we will
see in the next section.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Variables&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Arguments&quot; rel=&quot;next&quot;&gt;Arguments&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluation&quot; rel=&quot;previous&quot;&gt;Evaluation&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.7 Variables&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Variables-35&quot;&gt;&lt;/a&gt;
In Emacs Lisp, a symbol can have a value attached to it just as it can
have a function definition attached to it.  The two are different. 
The function definition is a set of instructions that a computer will
obey.  A value, on the other hand, is something, such as number or a
name, that can vary (which is why such a symbol is called a variable). 
The value of a symbol can be any expression in Lisp, such as a symbol,
number, list, or string.  A symbol that has a value is often called a
&lt;dfn&gt;variable&lt;/dfn&gt;.

   &lt;br /&gt;
A symbol can have both a function definition and a value attached to
it at the same time.  Or it can have just one or the other. 
The two are separate.  This is somewhat similar
to the way the name Cambridge can refer to the city in Massachusetts
and have some information attached to the name as well, such as
“great programming center”.

   &lt;br /&gt;
Another way to think about this is to imagine a symbol as being a chest
of drawers.  The function definition is put in one drawer, the value in
another, and so on.  What is put in the drawer holding the value can be
changed without affecting the contents of the drawer holding the
function definition, and vice-verse.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fill_002dcolumn-Example&quot;&gt;fill-column Example&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Void-Function&quot;&gt;Void Function&lt;/a&gt;:                The error message for a symbol
                                  without a function. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Void-Variable&quot;&gt;Void Variable&lt;/a&gt;:                The error message for a symbol without a value. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;fill-column-Example&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;fill_002dcolumn-Example&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Void-Function&quot; rel=&quot;next&quot;&gt;Void Function&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot; rel=&quot;up&quot;&gt;Variables&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
&lt;code&gt;fill-column&lt;/code&gt;, an Example Variable&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-fill_002dcolumn_002c-_0040r_007ban-example-variable_007d-36&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Example-variable_002c-_0040code_007bfill_002dcolumn_007d-37&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Variable_002c-example-of_002c-_0040code_007bfill_002dcolumn_007d-38&quot;&gt;&lt;/a&gt;The variable &lt;code&gt;fill-column&lt;/code&gt; illustrates a symbol with a value
attached to it: in every GNU Emacs buffer, this symbol is set to some
value, usually 72 or 70, but sometimes to some other value.  To find the
value of this symbol, evaluate it by itself.  If you are reading this in
Info inside of GNU Emacs, you can do this by putting the cursor after
the symbol and typing &lt;kbd&gt;C-x C-e&lt;/kbd&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     fill-column
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
After I typed &lt;kbd&gt;C-x C-e&lt;/kbd&gt;, Emacs printed the number 72 in my echo
area.  This is the value for which &lt;code&gt;fill-column&lt;/code&gt; is set for me as I
write this.  It may be different for you in your Info buffer.  Notice
that the value returned as a variable is printed in exactly the same way
as the value returned by a function carrying out its instructions.  From
the point of view of the Lisp interpreter, a value returned is a value
returned.  What kind of expression it came from ceases to matter once
the value is known.

   &lt;/div&gt;
A symbol can have any value attached to it or, to use the jargon, we can
&lt;dfn&gt;bind&lt;/dfn&gt; the variable to a value: to a number, such as 72; to a
string, &lt;code&gt;&quot;such as this&quot;&lt;/code&gt;; to a list, such as &lt;code&gt;(spruce pine
oak)&lt;/code&gt;; we can even bind a variable to a function definition.

   &lt;br /&gt;
A symbol can be bound to a value in several ways.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#set-_0026-setq&quot;&gt;Setting the Value of a Variable&lt;/a&gt;, for information about one way to do
this.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Void-Function&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Void-Variable&quot; rel=&quot;next&quot;&gt;Void Variable&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fill_002dcolumn-Example&quot; rel=&quot;previous&quot;&gt;fill-column Example&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot; rel=&quot;up&quot;&gt;Variables&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.7.1 Error Message for a Symbol Without a Function&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Symbol-without-function-error-39&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Error-for-symbol-without-function-40&quot;&gt;&lt;/a&gt;
When we evaluated &lt;code&gt;fill-column&lt;/code&gt; to find its value as a variable,
we did not place parentheses around the word.  This is because we did
not intend to use it as a function name.

   &lt;br /&gt;
If &lt;code&gt;fill-column&lt;/code&gt; were the first or only element of a list, the
Lisp interpreter would attempt to find the function definition
attached to it.  But &lt;code&gt;fill-column&lt;/code&gt; has no function definition. 
Try evaluating this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (fill-column)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
You will create a &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Backtrace*&lt;/span&gt;&lt;/samp&gt; buffer that says:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     ---------- Buffer: *Backtrace* ----------
     Debugger entered--Lisp error: (void-function fill-column)
       (fill-column)
       eval((fill-column))
       eval-last-sexp-1(nil)
       eval-last-sexp(nil)
       call-interactively(eval-last-sexp)
     ---------- Buffer: *Backtrace* ----------
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(Remember, to quit the debugger and make the debugger window go away,
type &lt;kbd&gt;q&lt;/kbd&gt; in the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Backtrace*&lt;/span&gt;&lt;/samp&gt; buffer.)

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Void-Variable&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Void-Function&quot; rel=&quot;previous&quot;&gt;Void Function&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot; rel=&quot;up&quot;&gt;Variables&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.7.2 Error Message for a Symbol Without a Value&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Symbol-without-value-error-41&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Error-for-symbol-without-value-42&quot;&gt;&lt;/a&gt;
If you attempt to evaluate a symbol that does not have a value bound to
it, you will receive an error message.  You can see this by
experimenting with our 2 plus 2 addition.  In the following expression,
put your cursor right after the &lt;code&gt;+&lt;/code&gt;, before the first number 2,
type &lt;kbd&gt;C-x C-e&lt;/kbd&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+ 2 2)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In GNU Emacs 22, you will create a &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Backtrace*&lt;/span&gt;&lt;/samp&gt; buffer that
says:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     ---------- Buffer: *Backtrace* ----------
     Debugger entered--Lisp error: (void-variable +)
       eval(+)
       eval-last-sexp-1(nil)
       eval-last-sexp(nil)
       call-interactively(eval-last-sexp)
     ---------- Buffer: *Backtrace* ----------
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(Again, you can quit the debugger by
typing &lt;kbd&gt;q&lt;/kbd&gt; in the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Backtrace*&lt;/span&gt;&lt;/samp&gt; buffer.)

   &lt;/div&gt;
This backtrace is different from the very first error message we saw,
which said, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Debugger entered--Lisp error: (void-function this)&lt;/span&gt;&lt;/samp&gt;’. 
In this case, the function does not have a value as a variable; while
in the other error message, the function (the word `this&#39;) did not
have a definition.

   &lt;br /&gt;
In this experiment with the &lt;code&gt;+&lt;/code&gt;, what we did was cause the Lisp
interpreter to evaluate the &lt;code&gt;+&lt;/code&gt; and look for the value of the
variable instead of the function definition.  We did this by placing the
cursor right after the symbol rather than after the parenthesis of the
enclosing list as we did before.  As a consequence, the Lisp interpreter
evaluated the preceding s-expression, which in this case was
&lt;code&gt;+&lt;/code&gt; by itself.

   &lt;br /&gt;
Since &lt;code&gt;+&lt;/code&gt; does not have a value bound to it, just the function
definition, the error message reported that the symbol&#39;s value as a
variable was void.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Arguments&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#set-_0026-setq&quot; rel=&quot;next&quot;&gt;set &amp;amp; setq&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot; rel=&quot;previous&quot;&gt;Variables&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.8 Arguments&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Arguments-43&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Passing-information-to-functions-44&quot;&gt;&lt;/a&gt;
To see how information is passed to functions, let&#39;s look again at
our old standby, the addition of two plus two.  In Lisp, this is written
as follows:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+ 2 2)
&lt;/pre&gt;
If you evaluate this expression, the number 4 will appear in your echo
area.  What the Lisp interpreter does is add the numbers that follow
the &lt;code&gt;+&lt;/code&gt;.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bargument_007d-defined-45&quot;&gt;&lt;/a&gt;The numbers added by &lt;code&gt;+&lt;/code&gt; are called the &lt;dfn&gt;arguments&lt;/dfn&gt; of the
function &lt;code&gt;+&lt;/code&gt;.  These numbers are the information that is given to
or &lt;dfn&gt;passed&lt;/dfn&gt; to the function.

   &lt;br /&gt;
The word `argument&#39; comes from the way it is used in mathematics and
does not refer to a disputation between two people; instead it refers to
the information presented to the function, in this case, to the
&lt;code&gt;+&lt;/code&gt;.  In Lisp, the arguments to a function are the atoms or lists
that follow the function.  The values returned by the evaluation of
these atoms or lists are passed to the function.  Different functions
require different numbers of arguments; some functions require none at
all.&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-2&quot; name=&quot;fnd-2&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Data-types&quot;&gt;Data types&lt;/a&gt;:                   Types of data passed to a function. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Args-as-Variable-or-List&quot;&gt;Args as Variable or List&lt;/a&gt;:     An argument can be the value
                                  of a variable or list. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variable-Number-of-Arguments&quot;&gt;Variable Number of Arguments&lt;/a&gt;:   Some functions may take a
                                  variable number of arguments. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Wrong-Type-of-Argument&quot;&gt;Wrong Type of Argument&lt;/a&gt;:       Passing an argument of the wrong type
                                  to a function. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#message&quot;&gt;message&lt;/a&gt;:                      A useful function for sending messages. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Data-types&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Args-as-Variable-or-List&quot; rel=&quot;next&quot;&gt;Args as Variable or List&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Arguments&quot; rel=&quot;up&quot;&gt;Arguments&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.8.1 Arguments&#39; Data Types&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Data-types-46&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Types-of-data-47&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Arguments_0027-data-types-48&quot;&gt;&lt;/a&gt;
The type of data that should be passed to a function depends on what
kind of information it uses.  The arguments to a function such as
&lt;code&gt;+&lt;/code&gt; must have values that are numbers, since &lt;code&gt;+&lt;/code&gt; adds numbers. 
Other functions use different kinds of data for their arguments.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-concat-49&quot;&gt;&lt;/a&gt;For example, the &lt;code&gt;concat&lt;/code&gt; function links together or unites two or
more strings of text to produce a string.  The arguments are strings. 
Concatenating the two character strings &lt;code&gt;abc&lt;/code&gt;, &lt;code&gt;def&lt;/code&gt; produces
the single string &lt;code&gt;abcdef&lt;/code&gt;.  This can be seen by evaluating the
following:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (concat &quot;abc&quot; &quot;def&quot;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The value produced by evaluating this expression is &lt;code&gt;&quot;abcdef&quot;&lt;/code&gt;.

   &lt;/div&gt;
A function such as &lt;code&gt;substring&lt;/code&gt; uses both a string and numbers as
arguments.  The function returns a part of the string, a substring of
the first argument.  This function takes three arguments.  Its first
argument is the string of characters, the second and third arguments are
numbers that indicate the beginning and end of the substring.  The
numbers are a count of the number of characters (including spaces and
punctuation) from the beginning of the string.

   &lt;br /&gt;
For example, if you evaluate the following:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (substring &quot;The quick brown fox jumped.&quot; 16 19)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
you will see &lt;code&gt;&quot;fox&quot;&lt;/code&gt; appear in the echo area.  The arguments are the
string and the two numbers.

   &lt;/div&gt;
Note that the string passed to &lt;code&gt;substring&lt;/code&gt; is a single atom even
though it is made up of several words separated by spaces.  Lisp counts
everything between the two quotation marks as part of the string,
including the spaces.  You can think of the &lt;code&gt;substring&lt;/code&gt; function as
a kind of `atom smasher&#39; since it takes an otherwise indivisible atom
and extracts a part.  However, &lt;code&gt;substring&lt;/code&gt; is only able to extract
a substring from an argument that is a string, not from another type of
atom such as a number or symbol.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Args-as-Variable-or-List&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variable-Number-of-Arguments&quot; rel=&quot;next&quot;&gt;Variable Number of Arguments&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Data-types&quot; rel=&quot;previous&quot;&gt;Data types&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Arguments&quot; rel=&quot;up&quot;&gt;Arguments&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.8.2 An Argument as the Value of a Variable or List&lt;/h4&gt;
An argument can be a symbol that returns a value when it is evaluated. 
For example, when the symbol &lt;code&gt;fill-column&lt;/code&gt; by itself is evaluated,
it returns a number.  This number can be used in an addition.

   &lt;br /&gt;
Position the cursor after the following expression and type &lt;kbd&gt;C-x
C-e&lt;/kbd&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+ 2 fill-column)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The value will be a number two more than what you get by evaluating
&lt;code&gt;fill-column&lt;/code&gt; alone.  For me, this is 74, because my value of
&lt;code&gt;fill-column&lt;/code&gt; is 72.

   &lt;/div&gt;
As we have just seen, an argument can be a symbol that returns a value
when evaluated.  In addition, an argument can be a list that returns a
value when it is evaluated.  For example, in the following expression,
the arguments to the function &lt;code&gt;concat&lt;/code&gt; are the strings
&lt;code&gt;&quot;The&amp;nbsp;&quot;&lt;/code&gt; and &lt;code&gt;&quot;&amp;nbsp;red&amp;nbsp;foxes.&quot;&lt;/code&gt; and the list
&lt;code&gt;(number-to-string (+ 2 fill-column))&lt;/code&gt;.


&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (concat &quot;The &quot; (number-to-string (+ 2 fill-column)) &quot; red foxes.&quot;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If you evaluate this expression—and if, as with my Emacs,
&lt;code&gt;fill-column&lt;/code&gt; evaluates to 72—&lt;code&gt;&quot;The 74 red foxes.&quot;&lt;/code&gt; will
appear in the echo area.  (Note that you must put spaces after the
word ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;The&lt;/span&gt;&lt;/samp&gt;’ and before the word ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;red&lt;/span&gt;&lt;/samp&gt;’ so they will appear in
the final string.  The function &lt;code&gt;number-to-string&lt;/code&gt; converts the
integer that the addition function returns to a string. 
&lt;code&gt;number-to-string&lt;/code&gt; is also known as &lt;code&gt;int-to-string&lt;/code&gt;.)

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Variable-Number-of-Arguments&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Wrong-Type-of-Argument&quot; rel=&quot;next&quot;&gt;Wrong Type of Argument&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Args-as-Variable-or-List&quot; rel=&quot;previous&quot;&gt;Args as Variable or List&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Arguments&quot; rel=&quot;up&quot;&gt;Arguments&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.8.3 Variable Number of Arguments&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Variable-number-of-arguments-50&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Arguments_002c-variable-number-of-51&quot;&gt;&lt;/a&gt;
Some functions, such as &lt;code&gt;concat&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;*&lt;/code&gt;, take any
number of arguments.  (The &lt;code&gt;*&lt;/code&gt; is the symbol for multiplication.) 
This can be seen by evaluating each of the following expressions in
the usual way.  What you will see in the echo area is printed in this
text after ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;⇒&lt;/span&gt;&lt;/samp&gt;’, which you may read as `evaluates to&#39;.

   &lt;br /&gt;
In the first set, the functions have no arguments:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+)       ⇒ 0
     
     (*)       ⇒ 1
&lt;/pre&gt;
In this set, the functions have one argument each:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+ 3)     ⇒ 3
     
     (* 3)     ⇒ 3
&lt;/pre&gt;
In this set, the functions have three arguments each:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+ 3 4 5) ⇒ 12
     
     (* 3 4 5) ⇒ 60
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Wrong-Type-of-Argument&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#message&quot; rel=&quot;next&quot;&gt;message&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variable-Number-of-Arguments&quot; rel=&quot;previous&quot;&gt;Variable Number of Arguments&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Arguments&quot; rel=&quot;up&quot;&gt;Arguments&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.8.4 Using the Wrong Type Object as an Argument&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Wrong-type-of-argument-52&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Argument_002c-wrong-type-of-53&quot;&gt;&lt;/a&gt;
When a function is passed an argument of the wrong type, the Lisp
interpreter produces an error message.  For example, the &lt;code&gt;+&lt;/code&gt;
function expects the values of its arguments to be numbers.  As an
experiment we can pass it the quoted symbol &lt;code&gt;hello&lt;/code&gt; instead of a
number.  Position the cursor after the following expression and type
&lt;kbd&gt;C-x C-e&lt;/kbd&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (+ 2 &#39;hello)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When you do this you will generate an error message.  What has happened
is that &lt;code&gt;+&lt;/code&gt; has tried to add the 2 to the value returned by
&lt;code&gt;&#39;hello&lt;/code&gt;, but the value returned by &lt;code&gt;&#39;hello&lt;/code&gt; is the symbol
&lt;code&gt;hello&lt;/code&gt;, not a number.  Only numbers can be added.  So &lt;code&gt;+&lt;/code&gt;
could not carry out its addition.

   &lt;/div&gt;
You will create and enter a &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Backtrace*&lt;/span&gt;&lt;/samp&gt; buffer that says:

&lt;br /&gt;
&lt;div class=&quot;noindent&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     ---------- Buffer: *Backtrace* ----------
     Debugger entered--Lisp error:
              (wrong-type-argument number-or-marker-p hello)
       +(2 hello)
       eval((+ 2 (quote hello)))
       eval-last-sexp-1(nil)
       eval-last-sexp(nil)
       call-interactively(eval-last-sexp)
     ---------- Buffer: *Backtrace* ----------
&lt;/pre&gt;
As usual, the error message tries to be helpful and makes sense after you
learn how to read it.&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-3&quot; name=&quot;fnd-3&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;

   &lt;br /&gt;
The first part of the error message is straightforward; it says
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;wrong type argument&lt;/span&gt;&lt;/samp&gt;’.  Next comes the mysterious jargon word
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;number-or-marker-p&lt;/span&gt;&lt;/samp&gt;’.  This word is trying to tell you what
kind of argument the &lt;code&gt;+&lt;/code&gt; expected.

   &lt;br /&gt;
The symbol &lt;code&gt;number-or-marker-p&lt;/code&gt; says that the Lisp interpreter is
trying to determine whether the information presented it (the value of
the argument) is a number or a marker (a special object representing a
buffer position).  What it does is test to see whether the &lt;code&gt;+&lt;/code&gt; is
being given numbers to add.  It also tests to see whether the
argument is something called a marker, which is a specific feature of
Emacs Lisp.  (In Emacs, locations in a buffer are recorded as markers. 
When the mark is set with the &lt;kbd&gt;C-@&lt;/kbd&gt; or &lt;kbd&gt;C-&amp;lt;SPC&amp;gt;&lt;/kbd&gt; command,
its position is kept as a marker.  The mark can be considered a
number—the number of characters the location is from the beginning
of the buffer.)  In Emacs Lisp, &lt;code&gt;+&lt;/code&gt; can be used to add the
numeric value of marker positions as numbers.

   &lt;br /&gt;
The ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’ of &lt;code&gt;number-or-marker-p&lt;/code&gt; is the embodiment of a
practice started in the early days of Lisp programming.  The ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’
stands for `predicate&#39;.  In the jargon used by the early Lisp
researchers, a predicate refers to a function to determine whether some
property is true or false.  So the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’ tells us that
&lt;code&gt;number-or-marker-p&lt;/code&gt; is the name of a function that determines
whether it is true or false that the argument supplied is a number or
a marker.  Other Lisp symbols that end in ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’ include &lt;code&gt;zerop&lt;/code&gt;,
a function that tests whether its argument has the value of zero, and
&lt;code&gt;listp&lt;/code&gt;, a function that tests whether its argument is a list.

   &lt;br /&gt;
Finally, the last part of the error message is the symbol &lt;code&gt;hello&lt;/code&gt;. 
This is the value of the argument that was passed to &lt;code&gt;+&lt;/code&gt;.  If the
addition had been passed the correct type of object, the value passed
would have been a number, such as 37, rather than a symbol like
&lt;code&gt;hello&lt;/code&gt;.  But then you would not have got the error message.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;message&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Wrong-Type-of-Argument&quot; rel=&quot;previous&quot;&gt;Wrong Type of Argument&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Arguments&quot; rel=&quot;up&quot;&gt;Arguments&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.8.5 The &lt;code&gt;message&lt;/code&gt; Function&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-message-54&quot;&gt;&lt;/a&gt;
Like &lt;code&gt;+&lt;/code&gt;, the &lt;code&gt;message&lt;/code&gt; function takes a variable number of
arguments.  It is used to send messages to the user and is so useful
that we will describe it here.

   &lt;br /&gt;
A message is printed in the echo area.  For example, you can print a
message in your echo area by evaluating the following list:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (message &quot;This message appears in the echo area!&quot;)
&lt;/pre&gt;
The whole string between double quotation marks is a single argument
and is printed &lt;i&gt;in toto&lt;/i&gt;.  (Note that in this example, the message
itself will appear in the echo area within double quotes; that is
because you see the value returned by the &lt;code&gt;message&lt;/code&gt; function.  In
most uses of &lt;code&gt;message&lt;/code&gt; in programs that you write, the text will
be printed in the echo area as a side-effect, without the quotes. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#multiply_002dby_002dseven-in-detail&quot;&gt;&lt;code&gt;multiply-by-seven&lt;/code&gt; in detail&lt;/a&gt;, for an example of this.)

   &lt;br /&gt;
However, if there is a ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’ in the quoted string of characters, the
&lt;code&gt;message&lt;/code&gt; function does not print the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’ as such, but looks
to the argument that follows the string.  It evaluates the second
argument and prints the value at the location in the string where the
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’ is.

   &lt;br /&gt;
You can see this by positioning the cursor after the following
expression and typing &lt;kbd&gt;C-x C-e&lt;/kbd&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (message &quot;The name of this buffer is: %s.&quot; (buffer-name))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In Info, &lt;code&gt;&quot;The name of this buffer is: *info*.&quot;&lt;/code&gt; will appear in the
echo area.  The function &lt;code&gt;buffer-name&lt;/code&gt; returns the name of the
buffer as a string, which the &lt;code&gt;message&lt;/code&gt; function inserts in place
of &lt;code&gt;%s&lt;/code&gt;.

   &lt;/div&gt;
To print a value as an integer, use ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’ in the same way as
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’.  For example, to print a message in the echo area that
states the value of the &lt;code&gt;fill-column&lt;/code&gt;, evaluate the following:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (message &quot;The value of fill-column is %d.&quot; fill-column)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
On my system, when I evaluate this list, &lt;code&gt;&quot;The value of
fill-column is 72.&quot;&lt;/code&gt; appears in my echo area&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-4&quot; name=&quot;fnd-4&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt;.

   &lt;/div&gt;
If there is more than one ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’ in the quoted string, the value of
the first argument following the quoted string is printed at the
location of the first ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’ and the value of the second argument is
printed at the location of the second ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’, and so on.

   &lt;br /&gt;
For example, if you evaluate the following,

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (message &quot;There are %d %s in the office!&quot;
              (- fill-column 14) &quot;pink elephants&quot;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
a rather whimsical message will appear in your echo area.  On my system
it says, &lt;code&gt;&quot;There are 58 pink elephants in the office!&quot;&lt;/code&gt;.

   &lt;/div&gt;
The expression &lt;code&gt;(- fill-column 14)&lt;/code&gt; is evaluated and the resulting
number is inserted in place of the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’; and the string in double
quotes, &lt;code&gt;&quot;pink elephants&quot;&lt;/code&gt;, is treated as a single argument and
inserted in place of the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’.  (That is to say, a string between
double quotes evaluates to itself, like a number.)

   &lt;br /&gt;
Finally, here is a somewhat complex example that not only illustrates
the computation of a number, but also shows how you can use an
expression within an expression to generate the text that is substituted
for ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (message &quot;He saw %d %s&quot;
              (- fill-column 32)
              (concat &quot;red &quot;
                      (substring
                       &quot;The quick brown foxes jumped.&quot; 16 21)
                      &quot; leaping.&quot;))
&lt;/pre&gt;
In this example, &lt;code&gt;message&lt;/code&gt; has three arguments: the string,
&lt;code&gt;&quot;He saw %d %s&quot;&lt;/code&gt;, the expression, &lt;code&gt;(- fill-column 32)&lt;/code&gt;, and
the expression beginning with the function &lt;code&gt;concat&lt;/code&gt;.  The value
resulting from the evaluation of &lt;code&gt;(- fill-column 32)&lt;/code&gt; is inserted
in place of the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’; and the value returned by the expression
beginning with &lt;code&gt;concat&lt;/code&gt; is inserted in place of the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’.

   &lt;br /&gt;
When your fill column is 70 and you evaluate the expression, the
message &lt;code&gt;&quot;He saw 38 red foxes leaping.&quot;&lt;/code&gt; appears in your echo
area.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;set-&amp;amp;-setq&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;set-_0026-setq&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Summary&quot; rel=&quot;next&quot;&gt;Summary&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Arguments&quot; rel=&quot;previous&quot;&gt;Arguments&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.9 Setting the Value of a Variable&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Variable_002c-setting-value-55&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Setting-value-of-variable-56&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bbind_007d-defined-57&quot;&gt;&lt;/a&gt;There are several ways by which a variable can be given a value.  One of
the ways is to use either the function &lt;code&gt;set&lt;/code&gt; or the function
&lt;code&gt;setq&lt;/code&gt;.  Another way is to use &lt;code&gt;let&lt;/code&gt; (see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot;&gt;let&lt;/a&gt;).  (The
jargon for this process is to &lt;dfn&gt;bind&lt;/dfn&gt; a variable to a value.)

   &lt;br /&gt;
The following sections not only describe how &lt;code&gt;set&lt;/code&gt; and &lt;code&gt;setq&lt;/code&gt;
work but also illustrate how arguments are passed.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Using-set&quot;&gt;Using set&lt;/a&gt;:                   Setting values. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Using-setq&quot;&gt;Using setq&lt;/a&gt;:                  Setting a quoted value. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Counting&quot;&gt;Counting&lt;/a&gt;:                    Using &lt;code&gt;setq&lt;/code&gt; to count. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Using-set&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Using-setq&quot; rel=&quot;next&quot;&gt;Using setq&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#set-_0026-setq&quot; rel=&quot;up&quot;&gt;set &amp;amp; setq&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.9.1 Using &lt;code&gt;set&lt;/code&gt;&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-set-58&quot;&gt;&lt;/a&gt;
To set the value of the symbol &lt;code&gt;flowers&lt;/code&gt; to the list &lt;code&gt;&#39;(rose
violet daisy buttercup)&lt;/code&gt;, evaluate the following expression by
positioning the cursor after the expression and typing &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (set &#39;flowers &#39;(rose violet daisy buttercup))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The list &lt;code&gt;(rose violet daisy buttercup)&lt;/code&gt; will appear in the echo
area.  This is what is &lt;em&gt;returned&lt;/em&gt; by the &lt;code&gt;set&lt;/code&gt; function.  As a
side effect, the symbol &lt;code&gt;flowers&lt;/code&gt; is bound to the list; that is,
the symbol &lt;code&gt;flowers&lt;/code&gt;, which can be viewed as a variable, is given
the list as its value.  (This process, by the way, illustrates how a
side effect to the Lisp interpreter, setting the value, can be the
primary effect that we humans are interested in.  This is because every
Lisp function must return a value if it does not get an error, but it
will only have a side effect if it is designed to have one.)

   &lt;/div&gt;
After evaluating the &lt;code&gt;set&lt;/code&gt; expression, you can evaluate the symbol
&lt;code&gt;flowers&lt;/code&gt; and it will return the value you just set.  Here is the
symbol.  Place your cursor after it and type &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     flowers
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When you evaluate &lt;code&gt;flowers&lt;/code&gt;, the list
&lt;code&gt;(rose violet daisy buttercup)&lt;/code&gt; appears in the echo area.

   &lt;/div&gt;
Incidentally, if you evaluate &lt;code&gt;&#39;flowers&lt;/code&gt;, the variable with a quote
in front of it, what you will see in the echo area is the symbol itself,
&lt;code&gt;flowers&lt;/code&gt;.  Here is the quoted symbol, so you can try this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &#39;flowers
&lt;/pre&gt;
Note also, that when you use &lt;code&gt;set&lt;/code&gt;, you need to quote both
arguments to &lt;code&gt;set&lt;/code&gt;, unless you want them evaluated.  Since we do
not want either argument evaluated, neither the variable
&lt;code&gt;flowers&lt;/code&gt; nor the list &lt;code&gt;(rose violet daisy buttercup)&lt;/code&gt;, both
are quoted.  (When you use &lt;code&gt;set&lt;/code&gt; without quoting its first
argument, the first argument is evaluated before anything else is
done.  If you did this and &lt;code&gt;flowers&lt;/code&gt; did not have a value
already, you would get an error message that the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Symbol&#39;s value
as variable is void&lt;/span&gt;&lt;/samp&gt;’; on the other hand, if &lt;code&gt;flowers&lt;/code&gt; did return
a value after it was evaluated, the &lt;code&gt;set&lt;/code&gt; would attempt to set
the value that was returned.  There are situations where this is the
right thing for the function to do; but such situations are rare.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Using-setq&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Counting&quot; rel=&quot;next&quot;&gt;Counting&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Using-set&quot; rel=&quot;previous&quot;&gt;Using set&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#set-_0026-setq&quot; rel=&quot;up&quot;&gt;set &amp;amp; setq&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.9.2 Using &lt;code&gt;setq&lt;/code&gt;&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-setq-59&quot;&gt;&lt;/a&gt;
As a practical matter, you almost always quote the first argument to
&lt;code&gt;set&lt;/code&gt;.  The combination of &lt;code&gt;set&lt;/code&gt; and a quoted first argument
is so common that it has its own name: the special form &lt;code&gt;setq&lt;/code&gt;. 
This special form is just like &lt;code&gt;set&lt;/code&gt; except that the first argument
is quoted automatically, so you don&#39;t need to type the quote mark
yourself.  Also, as an added convenience, &lt;code&gt;setq&lt;/code&gt; permits you to set
several different variables to different values, all in one expression.

   &lt;br /&gt;
To set the value of the variable &lt;code&gt;carnivores&lt;/code&gt; to the list
&lt;code&gt;&#39;(lion tiger leopard)&lt;/code&gt; using &lt;code&gt;setq&lt;/code&gt;, the following expression
is used:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq carnivores &#39;(lion tiger leopard))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
This is exactly the same as using &lt;code&gt;set&lt;/code&gt; except the first argument
is automatically quoted by &lt;code&gt;setq&lt;/code&gt;.  (The ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;q&lt;/span&gt;&lt;/samp&gt;’ in &lt;code&gt;setq&lt;/code&gt;
means &lt;code&gt;quote&lt;/code&gt;.)

   &lt;/div&gt;
With &lt;code&gt;set&lt;/code&gt;, the expression would look like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (set &#39;carnivores &#39;(lion tiger leopard))
&lt;/pre&gt;
Also, &lt;code&gt;setq&lt;/code&gt; can be used to assign different values to
different variables.  The first argument is bound to the value
of the second argument, the third argument is bound to the value of the
fourth argument, and so on.  For example, you could use the following to
assign a list of trees to the symbol &lt;code&gt;trees&lt;/code&gt; and a list of herbivores
to the symbol &lt;code&gt;herbivores&lt;/code&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq trees &#39;(pine fir oak maple)
           herbivores &#39;(gazelle antelope zebra))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(The expression could just as well have been on one line, but it might
not have fit on a page; and humans find it easier to read nicely
formatted lists.)

   &lt;/div&gt;
Although I have been using the term `assign&#39;, there is another way of
thinking about the workings of &lt;code&gt;set&lt;/code&gt; and &lt;code&gt;setq&lt;/code&gt;; and that is to
say that &lt;code&gt;set&lt;/code&gt; and &lt;code&gt;setq&lt;/code&gt; make the symbol &lt;em&gt;point&lt;/em&gt; to the
list.  This latter way of thinking is very common and in forthcoming
chapters we shall come upon at least one symbol that has `pointer&#39; as
part of its name.  The name is chosen because the symbol has a value,
specifically a list, attached to it; or, expressed another way,
the symbol is set to “point” to the list.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Counting&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Using-setq&quot; rel=&quot;previous&quot;&gt;Using setq&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#set-_0026-setq&quot; rel=&quot;up&quot;&gt;set &amp;amp; setq&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
1.9.3 Counting&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Counting-60&quot;&gt;&lt;/a&gt;
Here is an example that shows how to use &lt;code&gt;setq&lt;/code&gt; in a counter.  You
might use this to count how many times a part of your program repeats
itself.  First set a variable to zero; then add one to the number each
time the program repeats itself.  To do this, you need a variable that
serves as a counter, and two expressions: an initial &lt;code&gt;setq&lt;/code&gt;
expression that sets the counter variable to zero; and a second
&lt;code&gt;setq&lt;/code&gt; expression that increments the counter each time it is
evaluated.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq counter 0)                ; &lt;span class=&quot;roman&quot;&gt;Let&#39;s call this the initializer.&lt;/span&gt;
     
     (setq counter (+ counter 1))    ; &lt;span class=&quot;roman&quot;&gt;This is the incrementer.&lt;/span&gt;
     
     counter                         ; &lt;span class=&quot;roman&quot;&gt;This is the counter.&lt;/span&gt;
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(The text following the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;;&lt;/span&gt;&lt;/samp&gt;’ are comments.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Change-a-defun&quot;&gt;Change a Function Definition&lt;/a&gt;.)

   &lt;/div&gt;
If you evaluate the first of these expressions, the initializer,
&lt;code&gt;(setq counter 0)&lt;/code&gt;, and then evaluate the third expression,
&lt;code&gt;counter&lt;/code&gt;, the number &lt;code&gt;0&lt;/code&gt; will appear in the echo area.  If
you then evaluate the second expression, the incrementer, &lt;code&gt;(setq
counter (+ counter 1))&lt;/code&gt;, the counter will get the value 1.  So if you
again evaluate &lt;code&gt;counter&lt;/code&gt;, the number &lt;code&gt;1&lt;/code&gt; will appear in the
echo area.  Each time you evaluate the second expression, the value of
the counter will be incremented.

   &lt;br /&gt;
When you evaluate the incrementer, &lt;code&gt;(setq counter (+ counter 1))&lt;/code&gt;,
the Lisp interpreter first evaluates the innermost list; this is the
addition.  In order to evaluate this list, it must evaluate the variable
&lt;code&gt;counter&lt;/code&gt; and the number &lt;code&gt;1&lt;/code&gt;.  When it evaluates the variable
&lt;code&gt;counter&lt;/code&gt;, it receives its current value.  It passes this value and
the number &lt;code&gt;1&lt;/code&gt; to the &lt;code&gt;+&lt;/code&gt; which adds them together.  The sum
is then returned as the value of the inner list and passed to the
&lt;code&gt;setq&lt;/code&gt; which sets the variable &lt;code&gt;counter&lt;/code&gt; to this new value. 
Thus, the value of the variable, &lt;code&gt;counter&lt;/code&gt;, is changed.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Summary&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Error-Message-Exercises&quot; rel=&quot;next&quot;&gt;Error Message Exercises&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#set-_0026-setq&quot; rel=&quot;previous&quot;&gt;set &amp;amp; setq&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.10 Summary&lt;/h3&gt;
Learning Lisp is like climbing a hill in which the first part is the
steepest.  You have now climbed the most difficult part; what remains
becomes easier as you progress onwards.

   &lt;br /&gt;
In summary,

     &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Lisp programs are made up of expressions, which are lists or single atoms.

     &lt;/li&gt;
&lt;li&gt;Lists are made up of zero or more atoms or inner lists, separated by whitespace and
surrounded by parentheses.  A list can be empty.

     &lt;/li&gt;
&lt;li&gt;Atoms are multi-character symbols, like &lt;code&gt;forward-paragraph&lt;/code&gt;, single
character symbols like &lt;code&gt;+&lt;/code&gt;, strings of characters between double
quotation marks, or numbers.

     &lt;/li&gt;
&lt;li&gt;A number evaluates to itself.

     &lt;/li&gt;
&lt;li&gt;A string between double quotes also evaluates to itself.

     &lt;/li&gt;
&lt;li&gt;When you evaluate a symbol by itself, its value is returned.

     &lt;/li&gt;
&lt;li&gt;When you evaluate a list, the Lisp interpreter looks at the first symbol
in the list and then at the function definition bound to that symbol. 
Then the instructions in the function definition are carried out.

     &lt;/li&gt;
&lt;li&gt;A single quotation mark,
&lt;code&gt;&#39;&lt;/code&gt;
, tells the Lisp interpreter that it should
return the following expression as written, and not evaluate it as it
would if the quote were not there.

     &lt;/li&gt;
&lt;li&gt;Arguments are the information passed to a function.  The arguments to a
function are computed by evaluating the rest of the elements of the list
of which the function is the first element.

     &lt;/li&gt;
&lt;li&gt;A function always returns a value when it is evaluated (unless it gets
an error); in addition, it may also carry out some action called a
“side effect”.  In many cases, a function&#39;s primary purpose is to
create a side effect. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Error-Message-Exercises&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Summary&quot; rel=&quot;previous&quot;&gt;Summary&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;up&quot;&gt;List Processing&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
1.11 Exercises&lt;/h3&gt;
A few simple exercises:

     &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Generate an error message by evaluating an appropriate symbol that is
not within parentheses.

     &lt;/li&gt;
&lt;li&gt;Generate an error message by evaluating an appropriate symbol that is
between parentheses.

     &lt;/li&gt;
&lt;li&gt;Create a counter that increments by two rather than one.

     &lt;/li&gt;
&lt;li&gt;Write an expression that prints a message in the echo area when
evaluated. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Practicing-Evaluation&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;next&quot;&gt;Writing Defuns&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Processing&quot; rel=&quot;previous&quot;&gt;List Processing&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
2 Practicing Evaluation&lt;/h2&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Practicing-evaluation-61&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Evaluation-practice-62&quot;&gt;&lt;/a&gt;
Before learning how to write a function definition in Emacs Lisp, it is
useful to spend a little time evaluating various expressions that have
already been written.  These expressions will be lists with the
functions as their first (and often only) element.  Since some of the
functions associated with buffers are both simple and interesting, we
will start with those.  In this section, we will evaluate a few of
these.  In another section, we will study the code of several other
buffer-related functions, to see how they were written.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#How-to-Evaluate&quot;&gt;How to Evaluate&lt;/a&gt;:             Typing editing commands or &lt;kbd&gt;C-x C-e&lt;/kbd&gt;
                                 causes evaluation. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Names&quot;&gt;Buffer Names&lt;/a&gt;:                Buffers and files are different. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Getting-Buffers&quot;&gt;Getting Buffers&lt;/a&gt;:             Getting a buffer itself, not merely its name. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Switching-Buffers&quot;&gt;Switching Buffers&lt;/a&gt;:           How to change to another buffer. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Size-_0026-Locations&quot;&gt;Buffer Size &amp;amp; Locations&lt;/a&gt;:     Where point is located and the size of
                               the buffer. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluation-Exercise&quot;&gt;Evaluation Exercise&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;How-to-Evaluate&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Names&quot; rel=&quot;next&quot;&gt;Buffer Names&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Practicing-Evaluation&quot; rel=&quot;up&quot;&gt;Practicing Evaluation&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
How to Evaluate&lt;/h3&gt;
&lt;i&gt;Whenever you give an editing command&lt;/i&gt; to Emacs Lisp, such as the
command to move the cursor or to scroll the screen, &lt;i&gt;you are evaluating
an expression,&lt;/i&gt; the first element of which is a function.  &lt;i&gt;This is
how Emacs works.&lt;/i&gt;

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007binteractive-function_007d-defined-63&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bcommand_007d-defined-64&quot;&gt;&lt;/a&gt;When you type keys, you cause the Lisp interpreter to evaluate an
expression and that is how you get your results.  Even typing plain text
involves evaluating an Emacs Lisp function, in this case, one that uses
&lt;code&gt;self-insert-command&lt;/code&gt;, which simply inserts the character you
typed.  The functions you evaluate by typing keystrokes are called
&lt;dfn&gt;interactive&lt;/dfn&gt; functions, or &lt;dfn&gt;commands&lt;/dfn&gt;; how you make a function
interactive will be illustrated in the chapter on how to write function
definitions.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive&quot;&gt;Making a Function Interactive&lt;/a&gt;.

   &lt;br /&gt;
In addition to typing keyboard commands, we have seen a second way to
evaluate an expression: by positioning the cursor after a list and
typing &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.  This is what we will do in the rest of this
section.  There are other ways to evaluate an expression as well; these
will be described as we come to them.

   &lt;br /&gt;
Besides being used for practicing evaluation, the functions shown in the
next few sections are important in their own right.  A study of these
functions makes clear the distinction between buffers and files, how to
switch to a buffer, and how to determine a location within it.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Buffer-Names&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Getting-Buffers&quot; rel=&quot;next&quot;&gt;Getting Buffers&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#How-to-Evaluate&quot; rel=&quot;previous&quot;&gt;How to Evaluate&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Practicing-Evaluation&quot; rel=&quot;up&quot;&gt;Practicing Evaluation&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
2.1 Buffer Names&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-buffer_002dname-65&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-buffer_002dfile_002dname-66&quot;&gt;&lt;/a&gt;
The two functions, &lt;code&gt;buffer-name&lt;/code&gt; and &lt;code&gt;buffer-file-name&lt;/code&gt;, show
the difference between a file and a buffer.  When you evaluate the
following expression, &lt;code&gt;(buffer-name)&lt;/code&gt;, the name of the buffer
appears in the echo area.  When you evaluate &lt;code&gt;(buffer-file-name)&lt;/code&gt;,
the name of the file to which the buffer refers appears in the echo
area.  Usually, the name returned by &lt;code&gt;(buffer-name)&lt;/code&gt; is the same as
the name of the file to which it refers, and the name returned by
&lt;code&gt;(buffer-file-name)&lt;/code&gt; is the full path-name of the file.

   &lt;br /&gt;
A file and a buffer are two different entities.  A file is information
recorded permanently in the computer (unless you delete it).  A buffer,
on the other hand, is information inside of Emacs that will vanish at
the end of the editing session (or when you kill the buffer).  Usually,
a buffer contains information that you have copied from a file; we say
the buffer is &lt;dfn&gt;visiting&lt;/dfn&gt; that file.  This copy is what you work on
and modify.  Changes to the buffer do not change the file, until you
save the buffer.  When you save the buffer, the buffer is copied to the file
and is thus saved permanently.

   &lt;br /&gt;
If you are reading this in Info inside of GNU Emacs, you can evaluate
each of the following expressions by positioning the cursor after it and
typing &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.

&lt;br /&gt;
&lt;pre class=&quot;example&quot;&gt;     (buffer-name)
     
     (buffer-file-name)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When I do this in Info, the value returned by evaluating
&lt;code&gt;(buffer-name)&lt;/code&gt; is &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;&quot;*info*&quot;&lt;/span&gt;&lt;/samp&gt;, and the value returned by
evaluating &lt;code&gt;(buffer-file-name)&lt;/code&gt; is &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;nil&lt;/span&gt;&lt;/samp&gt;.

   &lt;/div&gt;
On the other hand, while I am writing this document, the value
returned by evaluating &lt;code&gt;(buffer-name)&lt;/code&gt; is
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;&quot;introduction.texinfo&quot;&lt;/span&gt;&lt;/samp&gt;, and the value returned by evaluating
&lt;code&gt;(buffer-file-name)&lt;/code&gt; is
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;&quot;/gnu/work/intro/introduction.texinfo&quot;&lt;/span&gt;&lt;/samp&gt;.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040code_007bnil_007d_002c-history-of-word-67&quot;&gt;&lt;/a&gt;The former is the name of the buffer and the latter is the name of the
file.  In Info, the buffer name is &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;&quot;*info*&quot;&lt;/span&gt;&lt;/samp&gt;.  Info does not
point to any file, so the result of evaluating
&lt;code&gt;(buffer-file-name)&lt;/code&gt; is &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;nil&lt;/span&gt;&lt;/samp&gt;.  The symbol &lt;code&gt;nil&lt;/code&gt; is
from the Latin word for `nothing&#39;; in this case, it means that the
buffer is not associated with any file.  (In Lisp, &lt;code&gt;nil&lt;/code&gt; is also
used to mean `false&#39; and is a synonym for the empty list, &lt;code&gt;()&lt;/code&gt;.)

   &lt;br /&gt;
When I am writing, the name of my buffer is
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;&quot;introduction.texinfo&quot;&lt;/span&gt;&lt;/samp&gt;.  The name of the file to which it
points is &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;&quot;/gnu/work/intro/introduction.texinfo&quot;&lt;/span&gt;&lt;/samp&gt;.

   &lt;br /&gt;
(In the expressions, the parentheses tell the Lisp interpreter to
treat &lt;code&gt;buffer-name&lt;/code&gt; and &lt;code&gt;buffer-file-name&lt;/code&gt; as
functions; without the parentheses, the interpreter would attempt to
evaluate the symbols as variables.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Variables&quot;&gt;Variables&lt;/a&gt;.)

   &lt;br /&gt;
In spite of the distinction between files and buffers, you will often
find that people refer to a file when they mean a buffer and vice-verse. 
Indeed, most people say, “I am editing a file,” rather than saying,
“I am editing a buffer which I will soon save to a file.”  It is
almost always clear from context what people mean.  When dealing with
computer programs, however, it is important to keep the distinction in mind,
since the computer is not as smart as a person.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Buffer_002c-history-of-word-68&quot;&gt;&lt;/a&gt;The word `buffer&#39;, by the way, comes from the meaning of the word as a
cushion that deadens the force of a collision.  In early computers, a
buffer cushioned the interaction between files and the computer&#39;s
central processing unit.  The drums or tapes that held a file and the
central processing unit were pieces of equipment that were very
different from each other, working at their own speeds, in spurts.  The
buffer made it possible for them to work together effectively. 
Eventually, the buffer grew from being an intermediary, a temporary
holding place, to being the place where work is done.  This
transformation is rather like that of a small seaport that grew into a
great city: once it was merely the place where cargo was warehoused
temporarily before being loaded onto ships; then it became a business
and cultural center in its own right.

   &lt;br /&gt;
Not all buffers are associated with files.  For example, a
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer does not visit any file.  Similarly, a
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Help*&lt;/span&gt;&lt;/samp&gt; buffer is not associated with any file.

   &lt;br /&gt;
In the old days, when you lacked a &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;~/.emacs&lt;/span&gt;&lt;/samp&gt; file and started an
Emacs session by typing the command &lt;code&gt;emacs&lt;/code&gt; alone, without naming
any files, Emacs started with the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer visible. 
Nowadays, you will see a splash screen.  You can follow one of the
commands suggested on the splash screen, visit a file, or press the
spacebar to reach the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer.

   &lt;br /&gt;
If you switch to the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer, type
&lt;code&gt;(buffer-name)&lt;/code&gt;, position the cursor after it, and then type
&lt;kbd&gt;C-x C-e&lt;/kbd&gt; to evaluate the expression.  The name &lt;code&gt;&quot;*scratch*&quot;&lt;/code&gt;
will be returned and will appear in the echo area.  &lt;code&gt;&quot;*scratch*&quot;&lt;/code&gt;
is the name of the buffer.  When you type &lt;code&gt;(buffer-file-name)&lt;/code&gt; in
the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer and evaluate that, &lt;code&gt;nil&lt;/code&gt; will appear
in the echo area, just as it does when you evaluate
&lt;code&gt;(buffer-file-name)&lt;/code&gt; in Info.

   &lt;br /&gt;
Incidentally, if you are in the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer and want the
value returned by an expression to appear in the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt;
buffer itself rather than in the echo area, type &lt;kbd&gt;C-u C-x C-e&lt;/kbd&gt;
instead of &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.  This causes the value returned to appear
after the expression.  The buffer will look like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (buffer-name)&quot;*scratch*&quot;
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
You cannot do this in Info since Info is read-only and it will not allow
you to change the contents of the buffer.  But you can do this in any
buffer you can edit; and when you write code or documentation (such as
this book), this feature is very useful.

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Getting-Buffers&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Switching-Buffers&quot; rel=&quot;next&quot;&gt;Switching Buffers&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Names&quot; rel=&quot;previous&quot;&gt;Buffer Names&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Practicing-Evaluation&quot; rel=&quot;up&quot;&gt;Practicing Evaluation&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
2.2 Getting Buffers&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-current_002dbuffer-69&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-other_002dbuffer-70&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Getting-a-buffer-71&quot;&gt;&lt;/a&gt;
The &lt;code&gt;buffer-name&lt;/code&gt; function returns the &lt;em&gt;name&lt;/em&gt; of the buffer;
to get the buffer &lt;em&gt;itself&lt;/em&gt;, a different function is needed: the
&lt;code&gt;current-buffer&lt;/code&gt; function.  If you use this function in code, what
you get is the buffer itself.

   &lt;br /&gt;
A name and the object or entity to which the name refers are different
from each other.  You are not your name.  You are a person to whom
others refer by name.  If you ask to speak to George and someone hands you
a card with the letters ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;G&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;e&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;o&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;r&lt;/span&gt;&lt;/samp&gt;’,
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;g&lt;/span&gt;&lt;/samp&gt;’, and ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;e&lt;/span&gt;&lt;/samp&gt;’ written on it, you might be amused, but you would
not be satisfied.  You do not want to speak to the name, but to the
person to whom the name refers.  A buffer is similar: the name of the
scratch buffer is &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt;, but the name is not the buffer.  To
get a buffer itself, you need to use a function such as
&lt;code&gt;current-buffer&lt;/code&gt;.

   &lt;br /&gt;
However, there is a slight complication: if you evaluate
&lt;code&gt;current-buffer&lt;/code&gt; in an expression on its own, as we will do here,
what you see is a printed representation of the name of the buffer
without the contents of the buffer.  Emacs works this way for two
reasons: the buffer may be thousands of lines long—too long to be
conveniently displayed; and, another buffer may have the same contents
but a different name, and it is important to distinguish between them.

   &lt;br /&gt;
Here is an expression containing the function:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (current-buffer)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If you evaluate this expression in Info in Emacs in the usual way,
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;#&amp;lt;buffer *info*&amp;gt;&lt;/span&gt;&lt;/samp&gt; will appear in the echo area.  The special
format indicates that the buffer itself is being returned, rather than
just its name.

   &lt;/div&gt;
Incidentally, while you can type a number or symbol into a program, you
cannot do that with the printed representation of a buffer: the only way
to get a buffer itself is with a function such as &lt;code&gt;current-buffer&lt;/code&gt;.

   &lt;br /&gt;
A related function is &lt;code&gt;other-buffer&lt;/code&gt;.  This returns the most
recently selected buffer other than the one you are in currently, not
a printed representation of its name.  If you have recently switched
back and forth from the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer, &lt;code&gt;other-buffer&lt;/code&gt;
will return that buffer.

   &lt;br /&gt;
You can see this by evaluating the expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (other-buffer)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
You should see &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;#&amp;lt;buffer *scratch*&amp;gt;&lt;/span&gt;&lt;/samp&gt; appear in the echo area, or
the name of whatever other buffer you switched back from most
recently&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-5&quot; name=&quot;fnd-5&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt;.

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Switching-Buffers&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Size-_0026-Locations&quot; rel=&quot;next&quot;&gt;Buffer Size &amp;amp; Locations&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Getting-Buffers&quot; rel=&quot;previous&quot;&gt;Getting Buffers&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Practicing-Evaluation&quot; rel=&quot;up&quot;&gt;Practicing Evaluation&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
2.3 Switching Buffers&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-switch_002dto_002dbuffer-72&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-set_002dbuffer-73&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Switching-to-a-buffer-74&quot;&gt;&lt;/a&gt;
The &lt;code&gt;other-buffer&lt;/code&gt; function actually provides a buffer when it is
used as an argument to a function that requires one.  We can see this
by using &lt;code&gt;other-buffer&lt;/code&gt; and &lt;code&gt;switch-to-buffer&lt;/code&gt; to switch to a
different buffer.

   &lt;br /&gt;
But first, a brief introduction to the &lt;code&gt;switch-to-buffer&lt;/code&gt;
function.  When you switched back and forth from Info to the
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer to evaluate &lt;code&gt;(buffer-name)&lt;/code&gt;, you most
likely typed &lt;kbd&gt;C-x b&lt;/kbd&gt; and then typed &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-6&quot; name=&quot;fnd-6&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt; when prompted in the minibuffer for the name of
the buffer to which you wanted to switch.  The keystrokes, &lt;kbd&gt;C-x
b&lt;/kbd&gt;, cause the Lisp interpreter to evaluate the interactive function
&lt;code&gt;switch-to-buffer&lt;/code&gt;.  As we said before, this is how Emacs works:
different keystrokes call or run different functions.  For example,
&lt;kbd&gt;C-f&lt;/kbd&gt; calls &lt;code&gt;forward-char&lt;/code&gt;, &lt;kbd&gt;M-e&lt;/kbd&gt; calls
&lt;code&gt;forward-sentence&lt;/code&gt;, and so on.

   &lt;br /&gt;
By writing &lt;code&gt;switch-to-buffer&lt;/code&gt; in an expression, and giving it a
buffer to switch to, we can switch buffers just the way &lt;kbd&gt;C-x b&lt;/kbd&gt;
does:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (switch-to-buffer (other-buffer))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The symbol &lt;code&gt;switch-to-buffer&lt;/code&gt; is the first element of the list,
so the Lisp interpreter will treat it as a function and carry out the
instructions that are attached to it.  But before doing that, the
interpreter will note that &lt;code&gt;other-buffer&lt;/code&gt; is inside parentheses
and work on that symbol first.  &lt;code&gt;other-buffer&lt;/code&gt; is the first (and
in this case, the only) element of this list, so the Lisp interpreter
calls or runs the function.  It returns another buffer.  Next, the
interpreter runs &lt;code&gt;switch-to-buffer&lt;/code&gt;, passing to it, as an
argument, the other buffer, which is what Emacs will switch to.  If
you are reading this in Info, try this now.  Evaluate the expression. 
(To get back, type &lt;kbd&gt;C-x b &amp;lt;RET&amp;gt;&lt;/kbd&gt;.)&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-7&quot; name=&quot;fnd-7&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;7&lt;/sup&gt;&lt;/a&gt;

   &lt;/div&gt;
In the programming examples in later sections of this document, you will
see the function &lt;code&gt;set-buffer&lt;/code&gt; more often than
&lt;code&gt;switch-to-buffer&lt;/code&gt;.  This is because of a difference between
computer programs and humans: humans have eyes and expect to see the
buffer on which they are working on their computer terminals.  This is
so obvious, it almost goes without saying.  However, programs do not
have eyes.  When a computer program works on a buffer, that buffer does
not need to be visible on the screen.

   &lt;br /&gt;
&lt;code&gt;switch-to-buffer&lt;/code&gt; is designed for humans and does two different
things: it switches the buffer to which Emacs&#39;s attention is directed; and
it switches the buffer displayed in the window to the new buffer. 
&lt;code&gt;set-buffer&lt;/code&gt;, on the other hand, does only one thing: it switches
the attention of the computer program to a different buffer.  The buffer
on the screen remains unchanged (of course, normally nothing happens
there until the command finishes running).

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bcall_007d-defined-75&quot;&gt;&lt;/a&gt;Also, we have just introduced another jargon term, the word &lt;dfn&gt;call&lt;/dfn&gt;. 
When you evaluate a list in which the first symbol is a function, you
are calling that function.  The use of the term comes from the notion of
the function as an entity that can do something for you if you `call&#39;
it—just as a plumber is an entity who can fix a leak if you call him
or her.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Buffer-Size-&amp;amp;-Locations&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Buffer-Size-_0026-Locations&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Evaluation-Exercise&quot; rel=&quot;next&quot;&gt;Evaluation Exercise&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Switching-Buffers&quot; rel=&quot;previous&quot;&gt;Switching Buffers&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Practicing-Evaluation&quot; rel=&quot;up&quot;&gt;Practicing Evaluation&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
2.4 Buffer Size and the Location of Point&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Size-of-buffer-76&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Buffer-size-77&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Point-location-78&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Location-of-point-79&quot;&gt;&lt;/a&gt;
Finally, let&#39;s look at several rather simple functions,
&lt;code&gt;buffer-size&lt;/code&gt;, &lt;code&gt;point&lt;/code&gt;, &lt;code&gt;point-min&lt;/code&gt;, and
&lt;code&gt;point-max&lt;/code&gt;.  These give information about the size of a buffer and
the location of point within it.

   &lt;br /&gt;
The function &lt;code&gt;buffer-size&lt;/code&gt; tells you the size of the current
buffer; that is, the function returns a count of the number of
characters in the buffer.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (buffer-size)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
You can evaluate this in the usual way, by positioning the
cursor after the expression and typing &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.

   &lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bpoint_007d-defined-80&quot;&gt;&lt;/a&gt;In Emacs, the current  position of the cursor is called &lt;dfn&gt;point&lt;/dfn&gt;. 
The expression &lt;code&gt;(point)&lt;/code&gt; returns a number that tells you where the
cursor is located as a count of the number of characters from the
beginning of the buffer up to point.

   &lt;br /&gt;
You can see the character count for point in this buffer by evaluating
the following expression in the usual way:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (point)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
As I write this, the value of &lt;code&gt;point&lt;/code&gt; is 65724.  The &lt;code&gt;point&lt;/code&gt;
function is frequently used in some of the examples later in this
book.

   &lt;/div&gt;
The value of point depends, of course, on its location within the
buffer.  If you evaluate point in this spot, the number will be larger:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (point)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
For me, the value of point in this location is 66043, which means that
there are 319 characters (including spaces) between the two
expressions.  (Doubtless, you will see different numbers, since I will
have edited this since I first evaluated point.)

   &lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bnarrowing_007d-defined-81&quot;&gt;&lt;/a&gt;The function &lt;code&gt;point-min&lt;/code&gt; is somewhat similar to &lt;code&gt;point&lt;/code&gt;, but
it returns the value of the minimum permissible value of point in the
current buffer.  This is the number 1 unless &lt;dfn&gt;narrowing&lt;/dfn&gt; is in
effect.  (Narrowing is a mechanism whereby you can restrict yourself,
or a program, to operations on just a part of a buffer. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot;&gt;Narrowing and Widening&lt;/a&gt;.)  Likewise, the
function &lt;code&gt;point-max&lt;/code&gt; returns the value of the maximum permissible
value of point in the current buffer.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Evaluation-Exercise&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Size-_0026-Locations&quot; rel=&quot;previous&quot;&gt;Buffer Size &amp;amp; Locations&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Practicing-Evaluation&quot; rel=&quot;up&quot;&gt;Practicing Evaluation&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
2.5 Exercise&lt;/h3&gt;
Find a file with which you are working and move towards its middle. 
Find its buffer name, file name, length, and your position in the file.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Writing-Defuns&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Walk-Through&quot; rel=&quot;next&quot;&gt;Buffer Walk Through&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Practicing-Evaluation&quot; rel=&quot;previous&quot;&gt;Practicing Evaluation&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
3 How To Write Function Definitions&lt;/h2&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Definition-writing-82&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Function-definition-writing-83&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Writing-a-function-definition-84&quot;&gt;&lt;/a&gt;
When the Lisp interpreter evaluates a list, it looks to see whether the
first symbol on the list has a function definition attached to it; or,
put another way, whether the symbol points to a function definition.  If
it does, the computer carries out the instructions in the definition.  A
symbol that has a function definition is called, simply, a function
(although, properly speaking, the definition is the function and the
symbol refers to it.)

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Primitive-Functions&quot;&gt;Primitive Functions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defun&quot;&gt;defun&lt;/a&gt;:                         The &lt;code&gt;defun&lt;/code&gt; special form. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Install&quot;&gt;Install&lt;/a&gt;:                       Install a function definition. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive&quot;&gt;Interactive&lt;/a&gt;:                   Making a function interactive. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive-Options&quot;&gt;Interactive Options&lt;/a&gt;:           Different options for &lt;code&gt;interactive&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Permanent-Installation&quot;&gt;Permanent Installation&lt;/a&gt;:        Installing code permanently. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;7&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot;&gt;let&lt;/a&gt;:                           Creating and initializing local variables. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;8&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if&quot;&gt;if&lt;/a&gt;:                            What if? 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;9&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#else&quot;&gt;else&lt;/a&gt;:                          If--then--else expressions. 
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Truth-_0026-Falsehood&quot;&gt;Truth &amp;amp; Falsehood&lt;/a&gt;:             What Lisp considers false and true. 
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002dexcursion&quot;&gt;save-excursion&lt;/a&gt;:                Keeping track of point, mark, and buffer. 
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Review&quot;&gt;Review&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defun-Exercises&quot;&gt;defun Exercises&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Primitive-Functions&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defun&quot; rel=&quot;next&quot;&gt;defun&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
An Aside about Primitive Functions&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Primitive-functions-85&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Functions_002c-primitive-86&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-C-language-primitives-87&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Primitives-written-in-C-88&quot;&gt;&lt;/a&gt;All functions are defined in terms of other functions, except for a few
&lt;dfn&gt;primitive&lt;/dfn&gt; functions that are written in the C programming
language.  When you write functions&#39; definitions, you will write them in
Emacs Lisp and use other functions as your building blocks.  Some of the
functions you will use will themselves be written in Emacs Lisp (perhaps
by you) and some will be primitives written in C.  The primitive
functions are used exactly like those written in Emacs Lisp and behave
like them.  They are written in C so we can easily run GNU Emacs on any
computer that has sufficient power and can run C.

   &lt;br /&gt;
Let me re-emphasize this: when you write code in Emacs Lisp, you do not
distinguish between the use of functions written in C and the use of
functions written in Emacs Lisp.  The difference is irrelevant.  I
mention the distinction only because it is interesting to know.  Indeed,
unless you investigate, you won&#39;t know whether an already-written
function is written in Emacs Lisp or C.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;defun&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Install&quot; rel=&quot;next&quot;&gt;Install&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Primitive-Functions&quot; rel=&quot;previous&quot;&gt;Primitive Functions&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.1 The &lt;code&gt;defun&lt;/code&gt; Special Form&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-defun-89&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Special-form-of-_0040code_007bdefun_007d-90&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bfunction-definition_007d-defined-91&quot;&gt;&lt;/a&gt;In Lisp, a symbol such as &lt;code&gt;mark-whole-buffer&lt;/code&gt; has code attached to
it that tells the computer what to do when the function is called. 
This code is called the &lt;dfn&gt;function definition&lt;/dfn&gt; and is created by
evaluating a Lisp expression that starts with the symbol &lt;code&gt;defun&lt;/code&gt;
(which is an abbreviation for &lt;em&gt;define function&lt;/em&gt;).  Because
&lt;code&gt;defun&lt;/code&gt; does not evaluate its arguments in the usual way, it is
called a &lt;dfn&gt;special form&lt;/dfn&gt;.

   &lt;br /&gt;
In subsequent sections, we will look at function definitions from the
Emacs source code, such as &lt;code&gt;mark-whole-buffer&lt;/code&gt;.  In this section,
we will describe a simple function definition so you can see how it
looks.  This function definition uses arithmetic because it makes for a
simple example.  Some people dislike examples using arithmetic; however,
if you are such a person, do not despair.  Hardly any of the code we
will study in the remainder of this introduction involves arithmetic or
mathematics.  The examples mostly involve text in one way or another.

   &lt;br /&gt;
A function definition has up to five parts following the word
&lt;code&gt;defun&lt;/code&gt;:

     &lt;br /&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li&gt;The name of the symbol to which the function definition should be
attached.

     &lt;/li&gt;
&lt;li&gt;A list of the arguments that will be passed to the function.  If no
arguments will be passed to the function, this is an empty list,
&lt;code&gt;()&lt;/code&gt;.

     &lt;/li&gt;
&lt;li&gt;Documentation describing the function.  (Technically optional, but
strongly recommended.)

     &lt;/li&gt;
&lt;li&gt;Optionally, an expression to make the function interactive so you can
use it by typing &lt;kbd&gt;M-x&lt;/kbd&gt; and then the name of the function; or by
typing an appropriate key or keychord.

     &lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bbody_007d-defined-92&quot;&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The code that instructs the computer what to do: the &lt;dfn&gt;body&lt;/dfn&gt; of the
function definition.
        &lt;/li&gt;
&lt;/ol&gt;
It is helpful to think of the five parts of a function definition as
being organized in a template, with slots for each part:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun &lt;var&gt;function-name&lt;/var&gt; (&lt;var&gt;arguments&lt;/var&gt;...)
       &quot;&lt;var&gt;optional-documentation&lt;/var&gt;...&quot;
       (interactive &lt;var&gt;argument-passing-info&lt;/var&gt;)     ; &lt;span class=&quot;roman&quot;&gt;optional&lt;/span&gt;
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
As an example, here is the code for a function that multiplies its
argument by 7.  (This example is not interactive.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive&quot;&gt;Making a Function Interactive&lt;/a&gt;, for that information.)

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun multiply-by-seven (number)
       &quot;Multiply NUMBER by seven.&quot;
       (* 7 number))
&lt;/pre&gt;
This definition begins with a parenthesis and the symbol &lt;code&gt;defun&lt;/code&gt;,
followed by the name of the function.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bargument-list_007d-defined-93&quot;&gt;&lt;/a&gt;The name of the function is followed by a list that contains the
arguments that will be passed to the function.  This list is called
the &lt;dfn&gt;argument list&lt;/dfn&gt;.  In this example, the list has only one
element, the symbol, &lt;code&gt;number&lt;/code&gt;.  When the function is used, the
symbol will be bound to the value that is used as the argument to the
function.

   &lt;br /&gt;
Instead of choosing the word &lt;code&gt;number&lt;/code&gt; for the name of the argument,
I could have picked any other name.  For example, I could have chosen
the word &lt;code&gt;multiplicand&lt;/code&gt;.  I picked the word `number&#39; because it
tells what kind of value is intended for this slot; but I could just as
well have chosen the word `multiplicand&#39; to indicate the role that the
value placed in this slot will play in the workings of the function.  I
could have called it &lt;code&gt;foogle&lt;/code&gt;, but that would have been a bad
choice because it would not tell humans what it means.  The choice of
name is up to the programmer and should be chosen to make the meaning of
the function clear.

   &lt;br /&gt;
Indeed, you can choose any name you wish for a symbol in an argument
list, even the name of a symbol used in some other function: the name
you use in an argument list is private to that particular definition. 
In that definition, the name refers to a different entity than any use
of the same name outside the function definition.  Suppose you have a
nick-name `Shorty&#39; in your family; when your family members refer to
`Shorty&#39;, they mean you.  But outside your family, in a movie, for
example, the name `Shorty&#39; refers to someone else.  Because a name in an
argument list is private to the function definition, you can change the
value of such a symbol inside the body of a function without changing
its value outside the function.  The effect is similar to that produced
by a &lt;code&gt;let&lt;/code&gt; expression.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot;&gt;&lt;code&gt;let&lt;/code&gt;&lt;/a&gt;.)

   &lt;br /&gt;
The argument list is followed by the documentation string that
describes the function.  This is what you see when you type
&lt;kbd&gt;C-h&amp;nbsp;f&lt;/kbd&gt; and the name of a function.  Incidentally, when you
write a documentation string like this, you should make the first line
a complete sentence since some commands, such as &lt;code&gt;apropos&lt;/code&gt;, print
only the first line of a multi-line documentation string.  Also, you
should not indent the second line of a documentation string, if you
have one, because that looks odd when you use &lt;kbd&gt;C-h f&lt;/kbd&gt;
(&lt;code&gt;describe-function&lt;/code&gt;).  The documentation string is optional, but
it is so useful, it should be included in almost every function you
write.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_002a-_0040r_007b_0028multiplication_0029_007d-94&quot;&gt;&lt;/a&gt;The third line of the example consists of the body of the function
definition.  (Most functions&#39; definitions, of course, are longer than
this.)  In this function, the body is the list, &lt;code&gt;(* 7 number)&lt;/code&gt;, which
says to multiply the value of &lt;var&gt;number&lt;/var&gt; by 7.  (In Emacs Lisp,
&lt;code&gt;*&lt;/code&gt; is the function for multiplication, just as &lt;code&gt;+&lt;/code&gt; is the
function for addition.)

   &lt;br /&gt;
When you use the &lt;code&gt;multiply-by-seven&lt;/code&gt; function, the argument
&lt;code&gt;number&lt;/code&gt; evaluates to the actual number you want used.  Here is an
example that shows how &lt;code&gt;multiply-by-seven&lt;/code&gt; is used; but don&#39;t try
to evaluate this yet!

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (multiply-by-seven 3)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The symbol &lt;code&gt;number&lt;/code&gt;, specified in the function definition in the
next section, is given or “bound to” the value 3 in the actual use of
the function.  Note that although &lt;code&gt;number&lt;/code&gt; was inside parentheses
in the function definition, the argument passed to the
&lt;code&gt;multiply-by-seven&lt;/code&gt; function is not in parentheses.  The
parentheses are written in the function definition so the computer can
figure out where the argument list ends and the rest of the function
definition begins.

   &lt;/div&gt;
If you evaluate this example, you are likely to get an error message. 
(Go ahead, try it!)  This is because we have written the function
definition, but not yet told the computer about the definition—we have
not yet installed (or `loaded&#39;) the function definition in Emacs. 
Installing a function is the process that tells the Lisp interpreter the
definition of the function.  Installation is described in the next
section.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Install&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive&quot; rel=&quot;next&quot;&gt;Interactive&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defun&quot; rel=&quot;previous&quot;&gt;defun&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.2 Install a Function Definition&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Install-a-Function-Definition-95&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Definition-installation-96&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Function-definition-installation-97&quot;&gt;&lt;/a&gt;
If you are reading this inside of Info in Emacs, you can try out the
&lt;code&gt;multiply-by-seven&lt;/code&gt; function by first evaluating the function
definition and then evaluating &lt;code&gt;(multiply-by-seven 3)&lt;/code&gt;.  A copy of
the function definition follows.  Place the cursor after the last
parenthesis of the function definition and type &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.  When you
do this, &lt;code&gt;multiply-by-seven&lt;/code&gt; will appear in the echo area.  (What
this means is that when a function definition is evaluated, the value it
returns is the name of the defined function.)  At the same time, this
action installs the function definition.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun multiply-by-seven (number)
       &quot;Multiply NUMBER by seven.&quot;
       (* 7 number))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
By evaluating this &lt;code&gt;defun&lt;/code&gt;, you have just installed
&lt;code&gt;multiply-by-seven&lt;/code&gt; in Emacs.  The function is now just as much a
part of Emacs as &lt;code&gt;forward-word&lt;/code&gt; or any other editing function you
use.  (&lt;code&gt;multiply-by-seven&lt;/code&gt; will stay installed until you quit
Emacs.  To reload code automatically whenever you start Emacs, see
&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Permanent-Installation&quot;&gt;Installing Code Permanently&lt;/a&gt;.)

&lt;/div&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Effect-of-installation&quot;&gt;Effect of installation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Change-a-defun&quot;&gt;Change a defun&lt;/a&gt;:               How to change a function definition. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Effect-of-installation&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Change-a-defun&quot; rel=&quot;next&quot;&gt;Change a defun&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Install&quot; rel=&quot;up&quot;&gt;Install&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
The effect of installation&lt;/h4&gt;
You can see the effect of installing &lt;code&gt;multiply-by-seven&lt;/code&gt; by
evaluating the following sample.  Place the cursor after the following
expression and type &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.  The number 21 will appear in the
echo area.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (multiply-by-seven 3)
&lt;/pre&gt;
If you wish, you can read the documentation for the function by typing
&lt;kbd&gt;C-h f&lt;/kbd&gt; (&lt;code&gt;describe-function&lt;/code&gt;) and then the name of the
function, &lt;code&gt;multiply-by-seven&lt;/code&gt;.  When you do this, a
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Help*&lt;/span&gt;&lt;/samp&gt; window will appear on your screen that says:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     multiply-by-seven is a Lisp function.
     (multiply-by-seven NUMBER)
     
     Multiply NUMBER by seven.
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(To return to a single window on your screen, type &lt;kbd&gt;C-x 1&lt;/kbd&gt;.)

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Change-a-defun&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Effect-of-installation&quot; rel=&quot;previous&quot;&gt;Effect of installation&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Install&quot; rel=&quot;up&quot;&gt;Install&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
3.2.1 Change a Function Definition&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Changing-a-function-definition-98&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Function-definition_002c-how-to-change-99&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Definition_002c-how-to-change-100&quot;&gt;&lt;/a&gt;
If you want to change the code in &lt;code&gt;multiply-by-seven&lt;/code&gt;, just rewrite
it.  To install the new version in place of the old one, evaluate the
function definition again.  This is how you modify code in Emacs.  It is
very simple.

   &lt;br /&gt;
As an example, you can change the &lt;code&gt;multiply-by-seven&lt;/code&gt; function to
add the number to itself seven times instead of multiplying the number
by seven.  It produces the same answer, but by a different path.  At
the same time, we will add a comment to the code; a comment is text
that the Lisp interpreter ignores, but that a human reader may find
useful or enlightening.  The comment is that this is the “second
version”.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun multiply-by-seven (number)       ; &lt;span class=&quot;roman&quot;&gt;Second version.&lt;/span&gt;
       &quot;Multiply NUMBER by seven.&quot;
       (+ number number number number number number number))
&lt;/pre&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Comments-in-Lisp-code-101&quot;&gt;&lt;/a&gt;The comment follows a semicolon, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;;&lt;/span&gt;&lt;/samp&gt;’.  In Lisp, everything on a
line that follows a semicolon is a comment.  The end of the line is the
end of the comment.  To stretch a comment over two or more lines, begin
each line with a semicolon.

   &lt;br /&gt;
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Beginning-a-_002eemacs-File&quot;&gt;Beginning a &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.emacs&lt;/span&gt;&lt;/samp&gt; File&lt;/a&gt;, and &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Comments&quot;&gt;Comments&lt;/a&gt;, for more about comments.

   &lt;br /&gt;
You can install this version of the &lt;code&gt;multiply-by-seven&lt;/code&gt; function by
evaluating it in the same way you evaluated the first function: place
the cursor after the last parenthesis and type &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.

   &lt;br /&gt;
In summary, this is how you write code in Emacs Lisp: you write a
function; install it; test it; and then make fixes or enhancements and
install it again.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Interactive&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive-Options&quot; rel=&quot;next&quot;&gt;Interactive Options&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Install&quot; rel=&quot;previous&quot;&gt;Install&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.3 Make a Function Interactive&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Interactive-functions-102&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-interactive-103&quot;&gt;&lt;/a&gt;
You make a function interactive by placing a list that begins with
the special form &lt;code&gt;interactive&lt;/code&gt; immediately after the
documentation.  A user can invoke an interactive function by typing
&lt;kbd&gt;M-x&lt;/kbd&gt; and then the name of the function; or by typing the keys to
which it is bound, for example, by typing &lt;kbd&gt;C-n&lt;/kbd&gt; for
&lt;code&gt;next-line&lt;/code&gt; or &lt;kbd&gt;C-x h&lt;/kbd&gt; for &lt;code&gt;mark-whole-buffer&lt;/code&gt;.

   &lt;br /&gt;
Interestingly, when you call an interactive function interactively,
the value returned is not automatically displayed in the echo area. 
This is because you often call an interactive function for its side
effects, such as moving forward by a word or line, and not for the
value returned.  If the returned value were displayed in the echo area
each time you typed a key, it would be very distracting.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive-multiply_002dby_002dseven&quot;&gt;Interactive multiply-by-seven&lt;/a&gt;:   An overview. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#multiply_002dby_002dseven-in-detail&quot;&gt;multiply-by-seven in detail&lt;/a&gt;:     The interactive version. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Interactive-multiply-by-seven&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Interactive-multiply_002dby_002dseven&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#multiply_002dby_002dseven-in-detail&quot; rel=&quot;next&quot;&gt;multiply-by-seven in detail&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive&quot; rel=&quot;up&quot;&gt;Interactive&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
An Interactive &lt;code&gt;multiply-by-seven&lt;/code&gt;, An Overview&lt;/h4&gt;
Both the use of the special form &lt;code&gt;interactive&lt;/code&gt; and one way to
display a value in the echo area can be illustrated by creating an
interactive version of &lt;code&gt;multiply-by-seven&lt;/code&gt;.

   &lt;br /&gt;
Here is the code:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun multiply-by-seven (number)       ; &lt;span class=&quot;roman&quot;&gt;Interactive version.&lt;/span&gt;
       &quot;Multiply NUMBER by seven.&quot;
       (interactive &quot;p&quot;)
       (message &quot;The result is %d&quot; (* 7 number)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
You can install this code by placing your cursor after it and typing
&lt;kbd&gt;C-x C-e&lt;/kbd&gt;.  The name of the function will appear in your echo area. 
Then, you can use this code by typing &lt;kbd&gt;C-u&lt;/kbd&gt; and a number and then
typing &lt;kbd&gt;M-x multiply-by-seven&lt;/kbd&gt; and pressing &amp;lt;RET&amp;gt;.  The phrase
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;The result is ...&lt;/span&gt;&lt;/samp&gt;’ followed by the product will appear in the
echo area.

   &lt;/div&gt;
Speaking more generally, you invoke a function like this in either of two
ways:

     &lt;br /&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li&gt;By typing a prefix argument that contains the number to be passed, and
then typing &lt;kbd&gt;M-x&lt;/kbd&gt; and the name of the function, as with
&lt;kbd&gt;C-u 3 M-x forward-sentence&lt;/kbd&gt;; or,

     &lt;/li&gt;
&lt;li&gt;By typing whatever key or keychord the function is bound to, as with
&lt;kbd&gt;C-u 3 M-e&lt;/kbd&gt;.
        &lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;noindent&quot;&gt;
Both the examples just mentioned work identically to move point forward
three sentences.  (Since &lt;code&gt;multiply-by-seven&lt;/code&gt; is not bound to a key,
it could not be used as an example of key binding.)

   &lt;/div&gt;
(See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Keybindings&quot;&gt;Some Keybindings&lt;/a&gt;, to learn how to bind a command
to a key.)

   &lt;br /&gt;
A prefix argument is passed to an interactive function by typing the
&amp;lt;META&amp;gt; key followed by a number, for example, &lt;kbd&gt;M-3 M-e&lt;/kbd&gt;, or by
typing &lt;kbd&gt;C-u&lt;/kbd&gt; and then a number, for example, &lt;kbd&gt;C-u 3 M-e&lt;/kbd&gt; (if you
type &lt;kbd&gt;C-u&lt;/kbd&gt; without a number, it defaults to 4).

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;multiply-by-seven-in-detail&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;multiply_002dby_002dseven-in-detail&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive-multiply_002dby_002dseven&quot; rel=&quot;previous&quot;&gt;Interactive multiply-by-seven&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive&quot; rel=&quot;up&quot;&gt;Interactive&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
3.3.1 An Interactive &lt;code&gt;multiply-by-seven&lt;/code&gt;&lt;/h4&gt;
Let&#39;s look at the use of the special form &lt;code&gt;interactive&lt;/code&gt; and then at
the function &lt;code&gt;message&lt;/code&gt; in the interactive version of
&lt;code&gt;multiply-by-seven&lt;/code&gt;.  You will recall that the function definition
looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun multiply-by-seven (number)       ; &lt;span class=&quot;roman&quot;&gt;Interactive version.&lt;/span&gt;
       &quot;Multiply NUMBER by seven.&quot;
       (interactive &quot;p&quot;)
       (message &quot;The result is %d&quot; (* 7 number)))
&lt;/pre&gt;
In this function, the expression, &lt;code&gt;(interactive &quot;p&quot;)&lt;/code&gt;, is a list of
two elements.  The &lt;code&gt;&quot;p&quot;&lt;/code&gt; tells Emacs to pass the prefix argument to
the function and use its value for the argument of the function.

   &lt;br /&gt;
The argument will be a number.  This means that the symbol
&lt;code&gt;number&lt;/code&gt; will be bound to a number in the line:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (message &quot;The result is %d&quot; (* 7 number))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
For example, if your prefix argument is 5, the Lisp interpreter will
evaluate the line as if it were:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (message &quot;The result is %d&quot; (* 7 5))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(If you are reading this in GNU Emacs, you can evaluate this expression
yourself.)  First, the interpreter will evaluate the inner list, which
is &lt;code&gt;(* 7 5)&lt;/code&gt;.  This returns a value of 35.  Next, it
will evaluate the outer list, passing the values of the second and
subsequent elements of the list to the function &lt;code&gt;message&lt;/code&gt;.

   &lt;/div&gt;
As we have seen, &lt;code&gt;message&lt;/code&gt; is an Emacs Lisp function especially
designed for sending a one line message to a user.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#message&quot;&gt;The &lt;code&gt;message&lt;/code&gt; function&lt;/a&gt;.)  In summary, the &lt;code&gt;message&lt;/code&gt;
function prints its first argument in the echo area as is, except for
occurrences of ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’ or ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’ (and various other %-sequences
which we have not mentioned).  When it sees a control sequence, the
function looks to the second or subsequent arguments and prints the
value of the argument in the location in the string where the control
sequence is located.

   &lt;br /&gt;
In the interactive &lt;code&gt;multiply-by-seven&lt;/code&gt; function, the control string
is ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’, which requires a number, and the value returned by
evaluating &lt;code&gt;(* 7 5)&lt;/code&gt; is the number 35.  Consequently, the number 35
is printed in place of the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’ and the message is ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;The result
is 35&lt;/span&gt;&lt;/samp&gt;’.

   &lt;br /&gt;
(Note that when you call the function &lt;code&gt;multiply-by-seven&lt;/code&gt;, the
message is printed without quotes, but when you call &lt;code&gt;message&lt;/code&gt;, the
text is printed in double quotes.  This is because the value returned by
&lt;code&gt;message&lt;/code&gt; is what appears in the echo area when you evaluate an
expression whose first element is &lt;code&gt;message&lt;/code&gt;; but when embedded in a
function, &lt;code&gt;message&lt;/code&gt; prints the text as a side effect without
quotes.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Interactive-Options&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Permanent-Installation&quot; rel=&quot;next&quot;&gt;Permanent Installation&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive&quot; rel=&quot;previous&quot;&gt;Interactive&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.4 Different Options for &lt;code&gt;interactive&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Options-for-_0040code_007binteractive_007d-104&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Interactive-options-105&quot;&gt;&lt;/a&gt;
In the example, &lt;code&gt;multiply-by-seven&lt;/code&gt; used &lt;code&gt;&quot;p&quot;&lt;/code&gt; as the
argument to &lt;code&gt;interactive&lt;/code&gt;.  This argument told Emacs to interpret
your typing either &lt;kbd&gt;C-u&lt;/kbd&gt; followed by a number or &amp;lt;META&amp;gt;
followed by a number as a command to pass that number to the function
as its argument.  Emacs has more than twenty characters predefined for
use with &lt;code&gt;interactive&lt;/code&gt;.  In almost every case, one of these
options will enable you to pass the right information interactively to
a function.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Interactive-Codes&quot;&gt;Code Characters for &lt;code&gt;interactive&lt;/code&gt;&lt;/a&gt;.)

   &lt;br /&gt;
Consider the function &lt;code&gt;zap-to-char&lt;/code&gt;.  Its interactive expression
is

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (interactive &quot;p\ncZap to char: &quot;)
&lt;/pre&gt;
The first part of the argument to &lt;code&gt;interactive&lt;/code&gt; is ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’, with
which you are already familiar.  This argument tells Emacs to
interpret a `prefix&#39;, as a number to be passed to the function.  You
can specify a prefix either by typing &lt;kbd&gt;C-u&lt;/kbd&gt; followed by a number
or by typing &amp;lt;META&amp;gt; followed by a number.  The prefix is the
number of specified characters.  Thus, if your prefix is three and the
specified character is ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;x&lt;/span&gt;&lt;/samp&gt;’, then you will delete all the text up
to and including the third next ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;x&lt;/span&gt;&lt;/samp&gt;’.  If you do not set a prefix,
then you delete all the text up to and including the specified
character, but no more.

   &lt;br /&gt;
The ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;c&lt;/span&gt;&lt;/samp&gt;’ tells the function the name of the character to which to delete.

   &lt;br /&gt;
More formally, a function with two or more arguments can have
information passed to each argument by adding parts to the string that
follows &lt;code&gt;interactive&lt;/code&gt;.  When you do this, the information is
passed to each argument in the same order it is specified in the
&lt;code&gt;interactive&lt;/code&gt; list.  In the string, each part is separated from
the next part by a ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;\n&lt;/span&gt;&lt;/samp&gt;’, which is a newline.  For example, you
can follow ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’ with a ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;\n&lt;/span&gt;&lt;/samp&gt;’ and an ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;cZap to char: &lt;/span&gt;&lt;/samp&gt;’. 
This causes Emacs to pass the value of the prefix argument (if there
is one) and the character.

   &lt;br /&gt;
In this case, the function definition looks like the following, where
&lt;code&gt;arg&lt;/code&gt; and &lt;code&gt;char&lt;/code&gt; are the symbols to which &lt;code&gt;interactive&lt;/code&gt;
binds the prefix argument and the specified character:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun &lt;var&gt;name-of-function&lt;/var&gt; (arg char)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       (interactive &quot;p\ncZap to char: &quot;)
       &lt;var&gt;body-of-function&lt;/var&gt;...)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(The space after the colon in the prompt makes it look better when you
are prompted.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dto_002dbuffer&quot;&gt;The Definition of &lt;code&gt;copy-to-buffer&lt;/code&gt;&lt;/a&gt;, for an example.)

   &lt;/div&gt;
When a function does not take arguments, &lt;code&gt;interactive&lt;/code&gt; does not
require any.  Such a function contains the simple expression
&lt;code&gt;(interactive)&lt;/code&gt;.  The &lt;code&gt;mark-whole-buffer&lt;/code&gt; function is like
this.

   &lt;br /&gt;
Alternatively, if the special letter-codes are not right for your
application, you can pass your own arguments to &lt;code&gt;interactive&lt;/code&gt; as
a list.

   &lt;br /&gt;
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot;&gt;The Definition of &lt;code&gt;append-to-buffer&lt;/code&gt;&lt;/a&gt;,
for an example.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Using-Interactive&quot;&gt;Using &lt;code&gt;Interactive&lt;/code&gt;&lt;/a&gt;, for a more complete
explanation about this technique.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Permanent-Installation&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot; rel=&quot;next&quot;&gt;let&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive-Options&quot; rel=&quot;previous&quot;&gt;Interactive Options&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.5 Install Code Permanently&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Install-code-permanently-106&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Permanent-code-installation-107&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Code-installation-108&quot;&gt;&lt;/a&gt;
When you install a function definition by evaluating it, it will stay
installed until you quit Emacs.  The next time you start a new session
of Emacs, the function will not be installed unless you evaluate the
function definition again.

   &lt;br /&gt;
At some point, you may want to have code installed automatically
whenever you start a new session of Emacs.  There are several ways of
doing this:

     &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;If you have code that is just for yourself, you can put the code for the
function definition in your &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.emacs&lt;/span&gt;&lt;/samp&gt; initialization file.  When you
start Emacs, your &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.emacs&lt;/span&gt;&lt;/samp&gt; file is automatically evaluated and all
the function definitions within it are installed. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Emacs-Initialization&quot;&gt;Your &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.emacs&lt;/span&gt;&lt;/samp&gt; File&lt;/a&gt;.

     &lt;/li&gt;
&lt;li&gt;Alternatively, you can put the function definitions that you want
installed in one or more files of their own and use the &lt;code&gt;load&lt;/code&gt;
function to cause Emacs to evaluate and thereby install each of the
functions in the files. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loading-Files&quot;&gt;Loading Files&lt;/a&gt;.

     &lt;/li&gt;
&lt;li&gt;Thirdly, if you have code that your whole site will use, it is usual
to put it in a file called &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;site-init.el&lt;/span&gt;&lt;/samp&gt; that is loaded when
Emacs is built.  This makes the code available to everyone who uses
your machine.  (See the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;INSTALL&lt;/span&gt;&lt;/samp&gt; file that is part of the Emacs
distribution.) 
&lt;/li&gt;
&lt;/ul&gt;
Finally, if you have code that everyone who uses Emacs may want, you
can post it on a computer network or send a copy to the Free Software
Foundation.  (When you do this, please license the code and its
documentation under a license that permits other people to run, copy,
study, modify, and redistribute the code and which protects you from
having your work taken from you.)  If you send a copy of your code to
the Free Software Foundation, and properly protect yourself and
others, it may be included in the next release of Emacs.  In large
part, this is how Emacs has grown over the past years, by donations.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;let&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if&quot; rel=&quot;next&quot;&gt;if&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Permanent-Installation&quot; rel=&quot;previous&quot;&gt;Permanent Installation&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.6 &lt;code&gt;let&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-let-109&quot;&gt;&lt;/a&gt;
The &lt;code&gt;let&lt;/code&gt; expression is a special form in Lisp that you will need
to use in most function definitions.

   &lt;br /&gt;
&lt;code&gt;let&lt;/code&gt; is used to attach or bind a symbol to a value in such a way
that the Lisp interpreter will not confuse the variable with a
variable of the same name that is not part of the function.

   &lt;br /&gt;
To understand why the &lt;code&gt;let&lt;/code&gt; special form is necessary, consider
the situation in which you own a home that you generally refer to as
`the house&#39;, as in the sentence, “The house needs painting.”  If you
are visiting a friend and your host refers to `the house&#39;, he is
likely to be referring to &lt;em&gt;his&lt;/em&gt; house, not yours, that is, to a
different house.

   &lt;br /&gt;
If your friend is referring to his house and you think he is referring
to your house, you may be in for some confusion.  The same thing could
happen in Lisp if a variable that is used inside of one function has
the same name as a variable that is used inside of another function,
and the two are not intended to refer to the same value.  The
&lt;code&gt;let&lt;/code&gt; special form prevents this kind of confusion.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Prevent-confusion&quot;&gt;Prevent confusion&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Parts-of-let-Expression&quot;&gt;Parts of let Expression&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Sample-let-Expression&quot;&gt;Sample let Expression&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Uninitialized-let-Variables&quot;&gt;Uninitialized let Variables&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Prevent-confusion&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Parts-of-let-Expression&quot; rel=&quot;next&quot;&gt;Parts of let Expression&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot; rel=&quot;up&quot;&gt;let&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
&lt;code&gt;let&lt;/code&gt; Prevents Confusion&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007blocal-variable_007d-defined-110&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bvariable_002c-local_007d_002c-defined-111&quot;&gt;&lt;/a&gt;The &lt;code&gt;let&lt;/code&gt; special form prevents confusion.  &lt;code&gt;let&lt;/code&gt; creates a
name for a &lt;dfn&gt;local variable&lt;/dfn&gt; that overshadows any use of the same
name outside the &lt;code&gt;let&lt;/code&gt; expression.  This is like understanding
that whenever your host refers to `the house&#39;, he means his house, not
yours.  (Symbols used in argument lists work the same way. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defun&quot;&gt;The &lt;code&gt;defun&lt;/code&gt; Special Form&lt;/a&gt;.)

   &lt;br /&gt;
Local variables created by a &lt;code&gt;let&lt;/code&gt; expression retain their value
&lt;em&gt;only&lt;/em&gt; within the &lt;code&gt;let&lt;/code&gt; expression itself (and within
expressions called within the &lt;code&gt;let&lt;/code&gt; expression); the local
variables have no effect outside the &lt;code&gt;let&lt;/code&gt; expression.

   &lt;br /&gt;
Another way to think about &lt;code&gt;let&lt;/code&gt; is that it is like a &lt;code&gt;setq&lt;/code&gt;
that is temporary and local.  The values set by &lt;code&gt;let&lt;/code&gt; are
automatically undone when the &lt;code&gt;let&lt;/code&gt; is finished.  The setting
only affects expressions that are inside the bounds of the &lt;code&gt;let&lt;/code&gt;
expression.  In computer science jargon, we would say “the binding of
a symbol is visible only in functions called in the &lt;code&gt;let&lt;/code&gt; form;
in Emacs Lisp, scoping is dynamic, not lexical.”

   &lt;br /&gt;
&lt;code&gt;let&lt;/code&gt; can create more than one variable at once.  Also,
&lt;code&gt;let&lt;/code&gt; gives each variable it creates an initial value, either a
value specified by you, or &lt;code&gt;nil&lt;/code&gt;.  (In the jargon, this is called
`binding the variable to the value&#39;.)  After &lt;code&gt;let&lt;/code&gt; has created
and bound the variables, it executes the code in the body of the
&lt;code&gt;let&lt;/code&gt;, and returns the value of the last expression in the body,
as the value of the whole &lt;code&gt;let&lt;/code&gt; expression.  (`Execute&#39; is a jargon
term that means to evaluate a list; it comes from the use of the word
meaning `to give practical effect to&#39; (&lt;cite&gt;Oxford English
Dictionary&lt;/cite&gt;).  Since you evaluate an expression to perform an action,
`execute&#39; has evolved as a synonym to `evaluate&#39;.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Parts-of-let-Expression&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Sample-let-Expression&quot; rel=&quot;next&quot;&gt;Sample let Expression&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Prevent-confusion&quot; rel=&quot;previous&quot;&gt;Prevent confusion&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot; rel=&quot;up&quot;&gt;let&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
3.6.1 The Parts of a &lt;code&gt;let&lt;/code&gt; Expression&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040code_007blet_007d-expression_002c-parts-of-112&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Parts-of-_0040code_007blet_007d-expression-113&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bvarlist_007d-defined-114&quot;&gt;&lt;/a&gt;A &lt;code&gt;let&lt;/code&gt; expression is a list of three parts.  The first part is
the symbol &lt;code&gt;let&lt;/code&gt;.  The second part is a list, called a
&lt;dfn&gt;varlist&lt;/dfn&gt;, each element of which is either a symbol by itself or a
two-element list, the first element of which is a symbol.  The third
part of the &lt;code&gt;let&lt;/code&gt; expression is the body of the &lt;code&gt;let&lt;/code&gt;.  The
body usually consists of one or more lists.

   &lt;br /&gt;
A template for a &lt;code&gt;let&lt;/code&gt; expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let &lt;var&gt;varlist&lt;/var&gt; &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The symbols in the varlist are the variables that are given initial
values by the &lt;code&gt;let&lt;/code&gt; special form.  Symbols by themselves are given
the initial value of &lt;code&gt;nil&lt;/code&gt;; and each symbol that is the first
element of a two-element list is bound to the value that is returned
when the Lisp interpreter evaluates the second element.

   &lt;/div&gt;
Thus, a varlist might look like this: &lt;code&gt;(thread (needles 3))&lt;/code&gt;.  In
this case, in a &lt;code&gt;let&lt;/code&gt; expression, Emacs binds the symbol
&lt;code&gt;thread&lt;/code&gt; to an initial value of &lt;code&gt;nil&lt;/code&gt;, and binds the symbol
&lt;code&gt;needles&lt;/code&gt; to an initial value of 3.

   &lt;br /&gt;
When you write a &lt;code&gt;let&lt;/code&gt; expression, what you do is put the
appropriate expressions in the slots of the &lt;code&gt;let&lt;/code&gt; expression
template.

   &lt;br /&gt;
If the varlist is composed of two-element lists, as is often the case,
the template for the &lt;code&gt;let&lt;/code&gt; expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let ((&lt;var&gt;variable&lt;/var&gt; &lt;var&gt;value&lt;/var&gt;)
           (&lt;var&gt;variable&lt;/var&gt; &lt;var&gt;value&lt;/var&gt;)
           ...)
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Sample-let-Expression&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Uninitialized-let-Variables&quot; rel=&quot;next&quot;&gt;Uninitialized let Variables&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Parts-of-let-Expression&quot; rel=&quot;previous&quot;&gt;Parts of let Expression&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot; rel=&quot;up&quot;&gt;let&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
3.6.2 Sample &lt;code&gt;let&lt;/code&gt; Expression&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Sample-_0040code_007blet_007d-expression-115&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040code_007blet_007d-expression-sample-116&quot;&gt;&lt;/a&gt;
The following expression creates and gives initial values
to the two variables &lt;code&gt;zebra&lt;/code&gt; and &lt;code&gt;tiger&lt;/code&gt;.  The body of the
&lt;code&gt;let&lt;/code&gt; expression is a list which calls the &lt;code&gt;message&lt;/code&gt; function.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let ((zebra &#39;stripes)
           (tiger &#39;fierce))
       (message &quot;One kind of animal has %s and another is %s.&quot;
                zebra tiger))
&lt;/pre&gt;
Here, the varlist is &lt;code&gt;((zebra &#39;stripes) (tiger &#39;fierce))&lt;/code&gt;.

   &lt;br /&gt;
The two variables are &lt;code&gt;zebra&lt;/code&gt; and &lt;code&gt;tiger&lt;/code&gt;.  Each variable is
the first element of a two-element list and each value is the second
element of its two-element list.  In the varlist, Emacs binds the
variable &lt;code&gt;zebra&lt;/code&gt; to the value &lt;code&gt;stripes&lt;/code&gt;&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-8&quot; name=&quot;fnd-8&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;8&lt;/sup&gt;&lt;/a&gt;, and binds the
variable &lt;code&gt;tiger&lt;/code&gt; to the value &lt;code&gt;fierce&lt;/code&gt;.  In this example,
both values are symbols preceded by a quote.  The values could just as
well have been another list or a string.  The body of the &lt;code&gt;let&lt;/code&gt;
follows after the list holding the variables.  In this example, the
body is a list that uses the &lt;code&gt;message&lt;/code&gt; function to print a string
in the echo area.

   &lt;br /&gt;
You may evaluate the example in the usual fashion, by placing the
cursor after the last parenthesis and typing &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.  When you do
this, the following will appear in the echo area:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &quot;One kind of animal has stripes and another is fierce.&quot;
&lt;/pre&gt;
As we have seen before, the &lt;code&gt;message&lt;/code&gt; function prints its first
argument, except for ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’.  In this example, the value of the variable
&lt;code&gt;zebra&lt;/code&gt; is printed at the location of the first ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’ and the
value of the variable &lt;code&gt;tiger&lt;/code&gt; is printed at the location of the
second ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Uninitialized-let-Variables&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Sample-let-Expression&quot; rel=&quot;previous&quot;&gt;Sample let Expression&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot; rel=&quot;up&quot;&gt;let&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
3.6.3 Uninitialized Variables in a &lt;code&gt;let&lt;/code&gt; Statement&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Uninitialized-_0040code_007blet_007d-variables-117&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040code_007blet_007d-variables-uninitialized-118&quot;&gt;&lt;/a&gt;
If you do not bind the variables in a &lt;code&gt;let&lt;/code&gt; statement to specific
initial values, they will automatically be bound to an initial value of
&lt;code&gt;nil&lt;/code&gt;, as in the following expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let ((birch 3)
           pine
           fir
           (oak &#39;some))
       (message
        &quot;Here are %d variables with %s, %s, and %s value.&quot;
        birch pine fir oak))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Here, the varlist is &lt;code&gt;((birch 3) pine fir (oak &#39;some))&lt;/code&gt;.

   &lt;/div&gt;
If you evaluate this expression in the usual way, the following will
appear in your echo area:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &quot;Here are 3 variables with nil, nil, and some value.&quot;
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In this example, Emacs binds the symbol &lt;code&gt;birch&lt;/code&gt; to the number 3,
binds the symbols &lt;code&gt;pine&lt;/code&gt; and &lt;code&gt;fir&lt;/code&gt; to &lt;code&gt;nil&lt;/code&gt;, and binds
the symbol &lt;code&gt;oak&lt;/code&gt; to the value &lt;code&gt;some&lt;/code&gt;.

   &lt;/div&gt;
Note that in the first part of the &lt;code&gt;let&lt;/code&gt;, the variables &lt;code&gt;pine&lt;/code&gt;
and &lt;code&gt;fir&lt;/code&gt; stand alone as atoms that are not surrounded by
parentheses; this is because they are being bound to &lt;code&gt;nil&lt;/code&gt;, the
empty list.  But &lt;code&gt;oak&lt;/code&gt; is bound to &lt;code&gt;some&lt;/code&gt; and so is a part of
the list &lt;code&gt;(oak &#39;some)&lt;/code&gt;.  Similarly, &lt;code&gt;birch&lt;/code&gt; is bound to the
number 3 and so is in a list with that number.  (Since a number
evaluates to itself, the number does not need to be quoted.  Also, the
number is printed in the message using a ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’ rather than a
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’.)  The four variables as a group are put into a list to
delimit them from the body of the &lt;code&gt;let&lt;/code&gt;.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;if&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#else&quot; rel=&quot;next&quot;&gt;else&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot; rel=&quot;previous&quot;&gt;let&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.7 The &lt;code&gt;if&lt;/code&gt; Special Form&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-if-119&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Conditional-with-_0040code_007bif_007d-120&quot;&gt;&lt;/a&gt;
A third special form, in addition to &lt;code&gt;defun&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt;, is the
conditional &lt;code&gt;if&lt;/code&gt;.  This form is used to instruct the computer to
make decisions.  You can write function definitions without using
&lt;code&gt;if&lt;/code&gt;, but it is used often enough, and is important enough, to be
included here.  It is used, for example, in the code for the
function &lt;code&gt;beginning-of-buffer&lt;/code&gt;.

   &lt;br /&gt;
The basic idea behind an &lt;code&gt;if&lt;/code&gt;, is that “&lt;em&gt;if&lt;/em&gt; a test is true,
&lt;em&gt;then&lt;/em&gt; an expression is evaluated.”  If the test is not true, the
expression is not evaluated.  For example, you might make a decision
such as, “if it is warm and sunny, then go to the beach!”

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if-in-more-detail&quot;&gt;if in more detail&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#type_002dof_002danimal-in-detail&quot;&gt;type-of-animal in detail&lt;/a&gt;:     An example of an &lt;code&gt;if&lt;/code&gt; expression. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;if-in-more-detail&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#type_002dof_002danimal-in-detail&quot; rel=&quot;next&quot;&gt;type-of-animal in detail&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if&quot; rel=&quot;up&quot;&gt;if&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
&lt;code&gt;if&lt;/code&gt; in more detail&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bif_002dpart_007d-defined-121&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bthen_002dpart_007d-defined-122&quot;&gt;&lt;/a&gt;An &lt;code&gt;if&lt;/code&gt; expression written in Lisp does not use the word `then&#39;;
the test and the action are the second and third elements of the list
whose first element is &lt;code&gt;if&lt;/code&gt;.  Nonetheless, the test part of an
&lt;code&gt;if&lt;/code&gt; expression is often called the &lt;dfn&gt;if-part&lt;/dfn&gt; and the second
argument is often called the &lt;dfn&gt;then-part&lt;/dfn&gt;.

   &lt;br /&gt;
Also, when an &lt;code&gt;if&lt;/code&gt; expression is written, the true-or-false-test
is usually written on the same line as the symbol &lt;code&gt;if&lt;/code&gt;, but the
action to carry out if the test is true, the “then-part”, is written
on the second and subsequent lines.  This makes the &lt;code&gt;if&lt;/code&gt;
expression easier to read.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if &lt;var&gt;true-or-false-test&lt;/var&gt;
         &lt;var&gt;action-to-carry-out-if-test-is-true&lt;/var&gt;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The true-or-false-test will be an expression that
is evaluated by the Lisp interpreter.

   &lt;/div&gt;
Here is an example that you can evaluate in the usual manner.  The test
is whether the number 5 is greater than the number 4.  Since it is, the
message ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;5 is greater than 4!&lt;/span&gt;&lt;/samp&gt;’ will be printed.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (&amp;gt; 5 4)                             ; &lt;span class=&quot;roman&quot;&gt;if-part&lt;/span&gt;
         (message &quot;5 is greater than 4!&quot;))   ; &lt;span class=&quot;roman&quot;&gt;then-part&lt;/span&gt;
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(The function &lt;code&gt;&amp;gt;&lt;/code&gt; tests whether its first argument is greater than
its second argument and returns true if it is.) 
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_003e-_0028greater-than_0029-123&quot;&gt;&lt;/a&gt;
Of course, in actual use, the test in an &lt;code&gt;if&lt;/code&gt; expression will not
be fixed for all time as it is by the expression &lt;code&gt;(&amp;gt; 5 4)&lt;/code&gt;. 
Instead, at least one of the variables used in the test will be bound to
a value that is not known ahead of time.  (If the value were known ahead
of time, we would not need to run the test!)

   &lt;/div&gt;
For example, the value may be bound to an argument of a function
definition.  In the following function definition, the character of the
animal is a value that is passed to the function.  If the value bound to
&lt;code&gt;characteristic&lt;/code&gt; is &lt;code&gt;fierce&lt;/code&gt;, then the message, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;It&#39;s a
tiger!&lt;/span&gt;&lt;/samp&gt;’ will be printed; otherwise, &lt;code&gt;nil&lt;/code&gt; will be returned.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun type-of-animal (characteristic)
       &quot;Print message in echo area depending on CHARACTERISTIC.
     If the CHARACTERISTIC is the symbol `fierce&#39;,
     then warn of a tiger.&quot;
       (if (equal characteristic &#39;fierce)
           (message &quot;It&#39;s a tiger!&quot;)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If you are reading this inside of GNU Emacs, you can evaluate the
function definition in the usual way to install it in Emacs, and then you
can evaluate the following two expressions to see the results:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (type-of-animal &#39;fierce)
     
     (type-of-animal &#39;zebra)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When you evaluate &lt;code&gt;(type-of-animal &#39;fierce)&lt;/code&gt;, you will see the
following message printed in the echo area: &lt;code&gt;&quot;It&#39;s a tiger!&quot;&lt;/code&gt;; and
when you evaluate &lt;code&gt;(type-of-animal &#39;zebra)&lt;/code&gt; you will see &lt;code&gt;nil&lt;/code&gt;
printed in the echo area.

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;type-of-animal-in-detail&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;type_002dof_002danimal-in-detail&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if-in-more-detail&quot; rel=&quot;previous&quot;&gt;if in more detail&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if&quot; rel=&quot;up&quot;&gt;if&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
3.7.1 The &lt;code&gt;type-of-animal&lt;/code&gt; Function in Detail&lt;/h4&gt;
Let&#39;s look at the &lt;code&gt;type-of-animal&lt;/code&gt; function in detail.

   &lt;br /&gt;
The function definition for &lt;code&gt;type-of-animal&lt;/code&gt; was written by filling
the slots of two templates, one for a function definition as a whole, and
a second for an &lt;code&gt;if&lt;/code&gt; expression.

   &lt;br /&gt;
The template for every function that is not interactive is:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun &lt;var&gt;name-of-function&lt;/var&gt; (&lt;var&gt;argument-list&lt;/var&gt;)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
The parts of the function that match this template look like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun type-of-animal (characteristic)
       &quot;Print message in echo area depending on CHARACTERISTIC.
     If the CHARACTERISTIC is the symbol `fierce&#39;,
     then warn of a tiger.&quot;
       &lt;var&gt;body: the&lt;/var&gt; &lt;code&gt;if&lt;/code&gt; &lt;var&gt;expression&lt;/var&gt;)
&lt;/pre&gt;
The name of function is &lt;code&gt;type-of-animal&lt;/code&gt;; it is passed the value
of one argument.  The argument list is followed by a multi-line
documentation string.  The documentation string is included in the
example because it is a good habit to write documentation string for
every function definition.  The body of the function definition
consists of the &lt;code&gt;if&lt;/code&gt; expression.

   &lt;br /&gt;
The template for an &lt;code&gt;if&lt;/code&gt; expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if &lt;var&gt;true-or-false-test&lt;/var&gt;
         &lt;var&gt;action-to-carry-out-if-the-test-returns-true&lt;/var&gt;)
&lt;/pre&gt;
In the &lt;code&gt;type-of-animal&lt;/code&gt; function, the code for the &lt;code&gt;if&lt;/code&gt;
looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (equal characteristic &#39;fierce)
         (message &quot;It&#39;s a tiger!&quot;)))
&lt;/pre&gt;
Here, the true-or-false-test is the expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (equal characteristic &#39;fierce)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In Lisp, &lt;code&gt;equal&lt;/code&gt; is a function that determines whether its first
argument is equal to its second argument.  The second argument is the
quoted symbol &lt;code&gt;&#39;fierce&lt;/code&gt; and the first argument is the value of the
symbol &lt;code&gt;characteristic&lt;/code&gt;—in other words, the argument passed to
this function.

   &lt;/div&gt;
In the first exercise of &lt;code&gt;type-of-animal&lt;/code&gt;, the argument
&lt;code&gt;fierce&lt;/code&gt; is passed to &lt;code&gt;type-of-animal&lt;/code&gt;.  Since &lt;code&gt;fierce&lt;/code&gt;
is equal to &lt;code&gt;fierce&lt;/code&gt;, the expression, &lt;code&gt;(equal characteristic
&#39;fierce)&lt;/code&gt;, returns a value of true.  When this happens, the &lt;code&gt;if&lt;/code&gt;
evaluates the second argument or then-part of the &lt;code&gt;if&lt;/code&gt;:
&lt;code&gt;(message &quot;It&#39;s tiger!&quot;)&lt;/code&gt;.

   &lt;br /&gt;
On the other hand, in the second exercise of &lt;code&gt;type-of-animal&lt;/code&gt;, the
argument &lt;code&gt;zebra&lt;/code&gt; is passed to &lt;code&gt;type-of-animal&lt;/code&gt;.  &lt;code&gt;zebra&lt;/code&gt;
is not equal to &lt;code&gt;fierce&lt;/code&gt;, so the then-part is not evaluated and
&lt;code&gt;nil&lt;/code&gt; is returned by the &lt;code&gt;if&lt;/code&gt; expression.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;else&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Truth-_0026-Falsehood&quot; rel=&quot;next&quot;&gt;Truth &amp;amp; Falsehood&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if&quot; rel=&quot;previous&quot;&gt;if&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.8 If–then–else Expressions&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Else-124&quot;&gt;&lt;/a&gt;
An &lt;code&gt;if&lt;/code&gt; expression may have an optional third argument, called
the &lt;dfn&gt;else-part&lt;/dfn&gt;, for the case when the true-or-false-test returns
false.  When this happens, the second argument or then-part of the
overall &lt;code&gt;if&lt;/code&gt; expression is &lt;em&gt;not&lt;/em&gt; evaluated, but the third or
else-part &lt;em&gt;is&lt;/em&gt; evaluated.  You might think of this as the cloudy
day alternative for the decision “if it is warm and sunny, then go to
the beach, else read a book!”.

   &lt;br /&gt;
The word “else” is not written in the Lisp code; the else-part of an
&lt;code&gt;if&lt;/code&gt; expression comes after the then-part.  In the written Lisp, the
else-part is usually written to start on a line of its own and is
indented less than the then-part:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if &lt;var&gt;true-or-false-test&lt;/var&gt;
         &lt;var&gt;action-to-carry-out-if-the-test-returns-true&lt;/var&gt;
       &lt;var&gt;action-to-carry-out-if-the-test-returns-false&lt;/var&gt;)
&lt;/pre&gt;
For example, the following &lt;code&gt;if&lt;/code&gt; expression prints the message ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;4
is not greater than 5!&lt;/span&gt;&lt;/samp&gt;’ when you evaluate it in the usual way:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (&amp;gt; 4 5)                               ; &lt;span class=&quot;roman&quot;&gt;if-part&lt;/span&gt;
         (message &quot;4 falsely greater than 5!&quot;) ; &lt;span class=&quot;roman&quot;&gt;then-part&lt;/span&gt;
       (message &quot;4 is not greater than 5!&quot;))   ; &lt;span class=&quot;roman&quot;&gt;else-part&lt;/span&gt;
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Note that the different levels of indentation make it easy to
distinguish the then-part from the else-part.  (GNU Emacs has several
commands that automatically indent &lt;code&gt;if&lt;/code&gt; expressions correctly. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Typing-Lists&quot;&gt;GNU Emacs Helps You Type Lists&lt;/a&gt;.)

   &lt;/div&gt;
We can extend the &lt;code&gt;type-of-animal&lt;/code&gt; function to include an
else-part by simply incorporating an additional part to the &lt;code&gt;if&lt;/code&gt;
expression.

   &lt;br /&gt;
You can see the consequences of doing this if you evaluate the following
version of the &lt;code&gt;type-of-animal&lt;/code&gt; function definition to install it
and then evaluate the two subsequent expressions to pass different
arguments to the function.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun type-of-animal (characteristic)  ; &lt;span class=&quot;roman&quot;&gt;Second version.&lt;/span&gt;
       &quot;Print message in echo area depending on CHARACTERISTIC.
     If the CHARACTERISTIC is the symbol `fierce&#39;,
     then warn of a tiger;
     else say it&#39;s not fierce.&quot;
       (if (equal characteristic &#39;fierce)
           (message &quot;It&#39;s a tiger!&quot;)
         (message &quot;It&#39;s not fierce!&quot;)))
&lt;/pre&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (type-of-animal &#39;fierce)
     
     (type-of-animal &#39;zebra)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When you evaluate &lt;code&gt;(type-of-animal &#39;fierce)&lt;/code&gt;, you will see the
following message printed in the echo area: &lt;code&gt;&quot;It&#39;s a tiger!&quot;&lt;/code&gt;; but
when you evaluate &lt;code&gt;(type-of-animal &#39;zebra)&lt;/code&gt;, you will see
&lt;code&gt;&quot;It&#39;s not fierce!&quot;&lt;/code&gt;.

   &lt;/div&gt;
(Of course, if the &lt;var&gt;characteristic&lt;/var&gt; were &lt;code&gt;ferocious&lt;/code&gt;, the
message &lt;code&gt;&quot;It&#39;s not fierce!&quot;&lt;/code&gt; would be printed; and it would be
misleading!  When you write code, you need to take into account the
possibility that some such argument will be tested by the &lt;code&gt;if&lt;/code&gt;
and write your program accordingly.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Truth-&amp;amp;-Falsehood&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Truth-_0026-Falsehood&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002dexcursion&quot; rel=&quot;next&quot;&gt;save-excursion&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#else&quot; rel=&quot;previous&quot;&gt;else&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.9 Truth and Falsehood in Emacs Lisp&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Truth-and-falsehood-in-Emacs-Lisp-125&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Falsehood-and-truth-in-Emacs-Lisp-126&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-nil-127&quot;&gt;&lt;/a&gt;
There is an important aspect to the truth test in an &lt;code&gt;if&lt;/code&gt;
expression.  So far, we have spoken of `true&#39; and `false&#39; as values of
predicates as if they were new kinds of Emacs Lisp objects.  In fact,
`false&#39; is just our old friend &lt;code&gt;nil&lt;/code&gt;.  Anything else—anything
at all—is `true&#39;.

   &lt;br /&gt;
The expression that tests for truth is interpreted as &lt;dfn&gt;true&lt;/dfn&gt;
if the result of evaluating it is a value that is not &lt;code&gt;nil&lt;/code&gt;.  In
other words, the result of the test is considered true if the value
returned is a number such as 47, a string such as &lt;code&gt;&quot;hello&quot;&lt;/code&gt;, or a
symbol (other than &lt;code&gt;nil&lt;/code&gt;) such as &lt;code&gt;flowers&lt;/code&gt;, or a list (so
long as it is not empty), or even a buffer!

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nil-explained&quot;&gt;nil explained&lt;/a&gt;:                &lt;code&gt;nil&lt;/code&gt; has two meanings. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;nil-explained&quot;&gt;&lt;/a&gt;

Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Truth-_0026-Falsehood&quot; rel=&quot;up&quot;&gt;Truth &amp;amp; Falsehood&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
An explanation of &lt;code&gt;nil&lt;/code&gt;&lt;/h4&gt;
Before illustrating a test for truth, we need an explanation of &lt;code&gt;nil&lt;/code&gt;.

   &lt;br /&gt;
In Emacs Lisp, the symbol &lt;code&gt;nil&lt;/code&gt; has two meanings.  First, it means the
empty list.  Second, it means false and is the value returned when a
true-or-false-test tests false.  &lt;code&gt;nil&lt;/code&gt; can be written as an empty
list, &lt;code&gt;()&lt;/code&gt;, or as &lt;code&gt;nil&lt;/code&gt;.  As far as the Lisp interpreter is
concerned, &lt;code&gt;()&lt;/code&gt; and &lt;code&gt;nil&lt;/code&gt; are the same.  Humans, however, tend
to use &lt;code&gt;nil&lt;/code&gt; for false and &lt;code&gt;()&lt;/code&gt; for the empty list.

   &lt;br /&gt;
In Emacs Lisp, any value that is not &lt;code&gt;nil&lt;/code&gt;—is not the empty
list—is considered true.  This means that if an evaluation returns
something that is not an empty list, an &lt;code&gt;if&lt;/code&gt; expression will test
true.  For example, if a number is put in the slot for the test, it
will be evaluated and will return itself, since that is what numbers
do when evaluated.  In this conditional, the &lt;code&gt;if&lt;/code&gt; expression will
test true.  The expression tests false only when &lt;code&gt;nil&lt;/code&gt;, an empty
list, is returned by evaluating the expression.

   &lt;br /&gt;
You can see this by evaluating the two expressions in the following examples.

   &lt;br /&gt;
In the first example, the number 4 is evaluated as the test in the
&lt;code&gt;if&lt;/code&gt; expression and returns itself; consequently, the then-part
of the expression is evaluated and returned: ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;true&lt;/span&gt;&lt;/samp&gt;’ appears in
the echo area.  In the second example, the &lt;code&gt;nil&lt;/code&gt; indicates false;
consequently, the else-part of the expression is evaluated and
returned: ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;false&lt;/span&gt;&lt;/samp&gt;’ appears in the echo area.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if 4
         &#39;true
       &#39;false)
     
     (if nil
         &#39;true
       &#39;false)
&lt;/pre&gt;
Incidentally, if some other useful value is not available for a test that
returns true, then the Lisp interpreter will return the symbol &lt;code&gt;t&lt;/code&gt;
for true.  For example, the expression &lt;code&gt;(&amp;gt; 5 4)&lt;/code&gt; returns &lt;code&gt;t&lt;/code&gt;
when evaluated, as you can see by evaluating it in the usual way:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (&amp;gt; 5 4)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
On the other hand, this function returns &lt;code&gt;nil&lt;/code&gt; if the test is false.

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (&amp;gt; 4 5)
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;save-excursion&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;save_002dexcursion&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Review&quot; rel=&quot;next&quot;&gt;Review&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Truth-_0026-Falsehood&quot; rel=&quot;previous&quot;&gt;Truth &amp;amp; Falsehood&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.10 &lt;code&gt;save-excursion&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-save_002dexcursion-128&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Region_002c-what-it-is-129&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Preserving-point_002c-mark_002c-and-buffer-130&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Point_002c-mark_002c-buffer-preservation-131&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-point-132&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-mark-133&quot;&gt;&lt;/a&gt;
The &lt;code&gt;save-excursion&lt;/code&gt; function is the fourth and final special form
that we will discuss in this chapter.

   &lt;br /&gt;
In Emacs Lisp programs used for editing, the &lt;code&gt;save-excursion&lt;/code&gt;
function is very common.  It saves the location of point and mark,
executes the body of the function, and then restores point and mark to
their previous positions if their locations were changed.  Its primary
purpose is to keep the user from being surprised and disturbed by
unexpected movement of point or mark.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Point-and-mark&quot;&gt;Point and mark&lt;/a&gt;:               A review of various locations. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Template-for-save_002dexcursion&quot;&gt;Template for save-excursion&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Point-and-mark&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Template-for-save_002dexcursion&quot; rel=&quot;next&quot;&gt;Template for save-excursion&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002dexcursion&quot; rel=&quot;up&quot;&gt;save-excursion&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
Point and Mark&lt;/h4&gt;
Before discussing &lt;code&gt;save-excursion&lt;/code&gt;, however, it may be useful
first to review what point and mark are in GNU Emacs.  &lt;dfn&gt;Point&lt;/dfn&gt; is
the current location of the cursor.  Wherever the cursor
is, that is point.  More precisely, on terminals where the cursor
appears to be on top of a character, point is immediately before the
character.  In Emacs Lisp, point is an integer.  The first character in
a buffer is number one, the second is number two, and so on.  The
function &lt;code&gt;point&lt;/code&gt; returns the current position of the cursor as a
number.  Each buffer has its own value for point.

   &lt;br /&gt;
The &lt;dfn&gt;mark&lt;/dfn&gt; is another position in the buffer; its value can be set
with a command such as &lt;kbd&gt;C-&amp;lt;SPC&amp;gt;&lt;/kbd&gt; (&lt;code&gt;set-mark-command&lt;/code&gt;).  If
a mark has been set, you can use the command &lt;kbd&gt;C-x C-x&lt;/kbd&gt;
(&lt;code&gt;exchange-point-and-mark&lt;/code&gt;) to cause the cursor to jump to the mark
and set the mark to be the previous position of point.  In addition, if
you set another mark, the position of the previous mark is saved in the
mark ring.  Many mark positions can be saved this way.  You can jump the
cursor to a saved mark by typing &lt;kbd&gt;C-u C-&amp;lt;SPC&amp;gt;&lt;/kbd&gt; one or more
times.

   &lt;br /&gt;
The part of the buffer between point and mark is called &lt;dfn&gt;the
region&lt;/dfn&gt;.  Numerous commands work on the region, including
&lt;code&gt;center-region&lt;/code&gt;, &lt;code&gt;count-lines-region&lt;/code&gt;, &lt;code&gt;kill-region&lt;/code&gt;, and
&lt;code&gt;print-region&lt;/code&gt;.

   &lt;br /&gt;
The &lt;code&gt;save-excursion&lt;/code&gt; special form saves the locations of point and
mark and restores those positions after the code within the body of the
special form is evaluated by the Lisp interpreter.  Thus, if point were
in the beginning of a piece of text and some code moved point to the end
of the buffer, the &lt;code&gt;save-excursion&lt;/code&gt; would put point back to where
it was before, after the expressions in the body of the function were
evaluated.

   &lt;br /&gt;
In Emacs, a function frequently moves point as part of its internal
workings even though a user would not expect this.  For example,
&lt;code&gt;count-lines-region&lt;/code&gt; moves point.  To prevent the user from being
bothered by jumps that are both unexpected and (from the user&#39;s point of
view) unnecessary, &lt;code&gt;save-excursion&lt;/code&gt; is often used to keep point and
mark in the location expected by the user.  The use of
&lt;code&gt;save-excursion&lt;/code&gt; is good housekeeping.

   &lt;br /&gt;
To make sure the house stays clean, &lt;code&gt;save-excursion&lt;/code&gt; restores the
values of point and mark even if something goes wrong in the code inside
of it (or, to be more precise and to use the proper jargon, “in case of
abnormal exit”).  This feature is very helpful.

   &lt;br /&gt;
In addition to recording the values of point and mark,
&lt;code&gt;save-excursion&lt;/code&gt; keeps track of the current buffer, and restores
it, too.  This means you can write code that will change the buffer and
have &lt;code&gt;save-excursion&lt;/code&gt; switch you back to the original buffer. 
This is how &lt;code&gt;save-excursion&lt;/code&gt; is used in &lt;code&gt;append-to-buffer&lt;/code&gt;. 
(See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot;&gt;The Definition of &lt;code&gt;append-to-buffer&lt;/code&gt;&lt;/a&gt;.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Template-for-save-excursion&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Template-for-save_002dexcursion&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Point-and-mark&quot; rel=&quot;previous&quot;&gt;Point and mark&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002dexcursion&quot; rel=&quot;up&quot;&gt;save-excursion&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
3.10.1 Template for a &lt;code&gt;save-excursion&lt;/code&gt; Expression&lt;/h4&gt;
The template for code using &lt;code&gt;save-excursion&lt;/code&gt; is simple:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (save-excursion
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The body of the function is one or more expressions that will be
evaluated in sequence by the Lisp interpreter.  If there is more than
one expression in the body, the value of the last one will be returned
as the value of the &lt;code&gt;save-excursion&lt;/code&gt; function.  The other
expressions in the body are evaluated only for their side effects; and
&lt;code&gt;save-excursion&lt;/code&gt; itself is used only for its side effect (which
is restoring the positions of point and mark).

   &lt;/div&gt;
In more detail, the template for a &lt;code&gt;save-excursion&lt;/code&gt; expression
looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (save-excursion
       &lt;var&gt;first-expression-in-body&lt;/var&gt;
       &lt;var&gt;second-expression-in-body&lt;/var&gt;
       &lt;var&gt;third-expression-in-body&lt;/var&gt;
        ...
       &lt;var&gt;last-expression-in-body&lt;/var&gt;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
An expression, of course, may be a symbol on its own or a list.

   &lt;/div&gt;
In Emacs Lisp code, a &lt;code&gt;save-excursion&lt;/code&gt; expression often occurs
within the body of a &lt;code&gt;let&lt;/code&gt; expression.  It looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let &lt;var&gt;varlist&lt;/var&gt;
       (save-excursion
         &lt;var&gt;body&lt;/var&gt;...))
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Review&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defun-Exercises&quot; rel=&quot;next&quot;&gt;defun Exercises&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002dexcursion&quot; rel=&quot;previous&quot;&gt;save-excursion&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.11 Review&lt;/h3&gt;
In the last few chapters we have introduced a fair number of functions
and special forms.  Here they are described in brief, along with a few
similar functions that have not been mentioned yet.

     &lt;br /&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;eval-last-sexp&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Evaluate the last symbolic expression before the current location of
point.  The value is printed in the echo area unless the function is
invoked with an argument; in that case, the output is printed in the
current buffer.  This command is normally bound to &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;defun&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Define function.  This special form has up to five parts: the name,
a template for the arguments that will be passed to the function,
documentation, an optional interactive declaration, and the body of the
definition.

     For example, in an early version of Emacs, the function definition was
as follows.  (It is slightly more complex now that it seeks the first
non-whitespace character rather than the first visible character.)

     &lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;          (defun back-to-indentation ()
            &quot;Move point to first visible character on line.&quot;
            (interactive)
            (beginning-of-line 1)
            (skip-chars-forward &quot; \t&quot;))
&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;interactive&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Declare to the interpreter that the function can be used
interactively.  This special form may be followed by a string with one
or more parts that pass the information to the arguments of the
function, in sequence.  These parts may also tell the interpreter to
prompt for information.  Parts of the string are separated by
newlines, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;\n&lt;/span&gt;&lt;/samp&gt;’.

     Common code characters are:

          &lt;br /&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;b&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The name of an existing buffer.

          &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;f&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The name of an existing file.

          &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;p&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The numeric prefix argument.  (Note that this `p&#39; is lower case.)

          &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;r&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Point and the mark, as two numeric arguments, smallest first.  This
is the only code letter that specifies two successive arguments
rather than one. 
&lt;/dd&gt;&lt;/dl&gt;
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Interactive-Codes&quot;&gt;Code Characters for ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;interactive&lt;/span&gt;&lt;/samp&gt;’&lt;/a&gt;, for a complete list of
code characters.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;let&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Declare that a list of variables is for use within the body of the
&lt;code&gt;let&lt;/code&gt; and give them an initial value, either &lt;code&gt;nil&lt;/code&gt; or a
specified value; then evaluate the rest of the expressions in the body
of the &lt;code&gt;let&lt;/code&gt; and return the value of the last one.  Inside the
body of the &lt;code&gt;let&lt;/code&gt;, the Lisp interpreter does not see the values of
the variables of the same names that are bound outside of the
&lt;code&gt;let&lt;/code&gt;.

     For example,

     &lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;          (let ((foo (buffer-name))
                (bar (buffer-size)))
            (message
             &quot;This buffer is %s and has %d characters.&quot;
             foo bar))
&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;save-excursion&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Record the values of point and mark and the current buffer before
evaluating the body of this special form.  Restore the values of point
and mark and buffer afterward.

     For example,

     &lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;          (message &quot;We are %d characters into this buffer.&quot;
                   (- (point)
                      (save-excursion
                        (goto-char (point-min)) (point))))
&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;if&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Evaluate the first argument to the function; if it is true, evaluate
the second argument; else evaluate the third argument, if there is one.

     The &lt;code&gt;if&lt;/code&gt; special form is called a &lt;dfn&gt;conditional&lt;/dfn&gt;.  There are
other conditionals in Emacs Lisp, but &lt;code&gt;if&lt;/code&gt; is perhaps the most
commonly used.

     &lt;br /&gt;
For example,

     &lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;          (if (= 22 emacs-major-version)
              (message &quot;This is version 22 Emacs&quot;)
            (message &quot;This is not version 22 Emacs&quot;))
&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;&amp;lt;=&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;&amp;gt;=&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The &lt;code&gt;&amp;lt;&lt;/code&gt; function tests whether its first argument is smaller than
its second argument.  A corresponding function, &lt;code&gt;&amp;gt;&lt;/code&gt;, tests whether
the first argument is greater than the second.  Likewise, &lt;code&gt;&amp;lt;=&lt;/code&gt;
tests whether the first argument is less than or equal to the second and
&lt;code&gt;&amp;gt;=&lt;/code&gt; tests whether the first argument is greater than or equal to
the second.  In all cases, both arguments must be numbers or markers
(markers indicate positions in buffers).

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;=&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The &lt;code&gt;=&lt;/code&gt; function tests whether two arguments, both numbers or
markers, are equal.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;equal&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;eq&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Test whether two objects are the same.  &lt;code&gt;equal&lt;/code&gt; uses one meaning
of the word `same&#39; and &lt;code&gt;eq&lt;/code&gt; uses another:  &lt;code&gt;equal&lt;/code&gt; returns
true if the two objects have a similar structure and contents, such as
two copies of the same book.  On the other hand, &lt;code&gt;eq&lt;/code&gt;, returns
true if both arguments are actually the same object. 
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-equal-134&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-eq-135&quot;&gt;&lt;/a&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;string&amp;lt;&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;string-lessp&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;string=&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;string-equal&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The &lt;code&gt;string-lessp&lt;/code&gt; function tests whether its first argument is
smaller than the second argument.  A shorter, alternative name for the
same function (a &lt;code&gt;defalias&lt;/code&gt;) is &lt;code&gt;string&amp;lt;&lt;/code&gt;.

     The arguments to &lt;code&gt;string-lessp&lt;/code&gt; must be strings or symbols; the
ordering is lexicographic, so case is significant.  The print names of
symbols are used instead of the symbols themselves.

     &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040samp_007bempty-string_007d-defined-136&quot;&gt;&lt;/a&gt;An empty string, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/samp&gt;’, a string with no characters in it, is
smaller than any string of characters.

     &lt;br /&gt;
&lt;code&gt;string-equal&lt;/code&gt; provides the corresponding test for equality.  Its
shorter, alternative name is &lt;code&gt;string=&lt;/code&gt;.  There are no string test
functions that correspond to &lt;var&gt;&amp;gt;&lt;/var&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;, or &lt;code&gt;&amp;lt;=&lt;/code&gt;.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;message&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Print a message in the echo area. The first argument is a string that
can contain ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’, or ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%c&lt;/span&gt;&lt;/samp&gt;’ to print the value of
arguments that follow the string.  The argument used by ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%s&lt;/span&gt;&lt;/samp&gt;’ must
be a string or a symbol; the argument used by ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’ must be a
number.  The argument used by ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%c&lt;/span&gt;&lt;/samp&gt;’ must be an &lt;span class=&quot;sc&quot;&gt;ascii&lt;/span&gt; code
number; it will be printed as the character with that &lt;span class=&quot;sc&quot;&gt;ascii&lt;/span&gt; code. 
(Various other %-sequences have not been mentioned.)

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;setq&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;set&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The &lt;code&gt;setq&lt;/code&gt; function sets the value of its first argument to the
value of the second argument.  The first argument is automatically
quoted by &lt;code&gt;setq&lt;/code&gt;.  It does the same for succeeding pairs of
arguments.  Another function, &lt;code&gt;set&lt;/code&gt;, takes only two arguments and
evaluates both of them before setting the value returned by its first
argument to the value returned by its second argument.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;buffer-name&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Without an argument, return the name of the buffer, as a string.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;buffer-file-name&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Without an argument, return the name of the file the buffer is
visiting.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;current-buffer&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Return the buffer in which Emacs is active; it may not be
the buffer that is visible on the screen.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;other-buffer&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Return the most recently selected buffer (other than the buffer passed
to &lt;code&gt;other-buffer&lt;/code&gt; as an argument and other than the current
buffer).

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;switch-to-buffer&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Select a buffer for Emacs to be active in and display it in the current
window so users can look at it.  Usually bound to &lt;kbd&gt;C-x b&lt;/kbd&gt;.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;set-buffer&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Switch Emacs&#39;s attention to a buffer on which programs will run.  Don&#39;t
alter what the window is showing.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;buffer-size&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Return the number of characters in the current buffer.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;point&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Return the value of the current position of the cursor, as an
integer counting the number of characters from the beginning of the
buffer.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;point-min&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Return the minimum permissible value of point in
the current buffer.  This is 1, unless narrowing is in effect.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;point-max&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Return the value of the maximum permissible value of point in the
current buffer.  This is the end of the buffer, unless narrowing is in
effect. 
&lt;/dd&gt;&lt;/dl&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;defun-Exercises&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Review&quot; rel=&quot;previous&quot;&gt;Review&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;up&quot;&gt;Writing Defuns&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
3.12 Exercises&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Write a non-interactive function that doubles the value of its
argument, a number.  Make that function interactive.

     &lt;/li&gt;
&lt;li&gt;Write a function that tests whether the current value of
&lt;code&gt;fill-column&lt;/code&gt; is greater than the argument passed to the function,
and if so, prints an appropriate message. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Buffer-Walk-Through&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#More-Complex&quot; rel=&quot;next&quot;&gt;More Complex&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Writing-Defuns&quot; rel=&quot;previous&quot;&gt;Writing Defuns&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
4 A Few Buffer–Related Functions&lt;/h2&gt;
In this chapter we study in detail several of the functions used in GNU
Emacs.  This is called a “walk-through”.  These functions are used as
examples of Lisp code, but are not imaginary examples; with the
exception of the first, simplified function definition, these functions
show the actual code used in GNU Emacs.  You can learn a great deal from
these definitions.  The functions described here are all related to
buffers.  Later, we will study other functions.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Finding-More&quot;&gt;Finding More&lt;/a&gt;:                 How to find more information. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#simplified_002dbeginning_002dof_002dbuffer&quot;&gt;simplified-beginning-of-buffer&lt;/a&gt;:   Shows &lt;code&gt;goto-char&lt;/code&gt;,
                                &lt;code&gt;point-min&lt;/code&gt;, and &lt;code&gt;push-mark&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mark_002dwhole_002dbuffer&quot;&gt;mark-whole-buffer&lt;/a&gt;:            Almost the same as &lt;code&gt;beginning-of-buffer&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot;&gt;append-to-buffer&lt;/a&gt;:             Uses &lt;code&gt;save-excursion&lt;/code&gt; and
                                &lt;code&gt;insert-buffer-substring&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Related-Review&quot;&gt;Buffer Related Review&lt;/a&gt;:        Review. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Exercises&quot;&gt;Buffer Exercises&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Finding-More&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#simplified_002dbeginning_002dof_002dbuffer&quot; rel=&quot;next&quot;&gt;simplified-beginning-of-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Walk-Through&quot; rel=&quot;up&quot;&gt;Buffer Walk Through&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
4.1 Finding More Information&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-describe_002dfunction_002c-_0040r_007bintroduced_007d-137&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Find-function-documentation-138&quot;&gt;&lt;/a&gt;In this walk-through, I will describe each new function as we come to
it, sometimes in detail and sometimes briefly.  If you are interested,
you can get the full documentation of any Emacs Lisp function at any
time by typing &lt;kbd&gt;C-h f&lt;/kbd&gt; and then the name of the function (and then
&amp;lt;RET&amp;gt;).  Similarly, you can get the full documentation for a
variable by typing &lt;kbd&gt;C-h v&lt;/kbd&gt; and then the name of the variable (and
then &amp;lt;RET&amp;gt;).

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Find-source-of-function-139&quot;&gt;&lt;/a&gt;
Also, &lt;code&gt;describe-function&lt;/code&gt; will tell you the location of the
function definition.

   &lt;br /&gt;
Put point into the name of the file that contains the function and
press the &amp;lt;RET&amp;gt; key.  In this case, &amp;lt;RET&amp;gt; means
&lt;code&gt;push-button&lt;/code&gt; rather than `return&#39; or `enter&#39;.  Emacs will take
you directly to the function definition.

   &lt;br /&gt;
More generally, if you want to see a function in its original source
file, you can use the &lt;code&gt;find-tag&lt;/code&gt; function to jump to it. 
&lt;code&gt;find-tag&lt;/code&gt; works with a wide variety of languages, not just
Lisp, and C, and it works with non-programming text as well.  For
example, &lt;code&gt;find-tag&lt;/code&gt; will jump to the various nodes in the
Texinfo source file of this document. 
The &lt;code&gt;find-tag&lt;/code&gt; function depends on `tags tables&#39; that record
the locations of the functions, variables, and other items to which
&lt;code&gt;find-tag&lt;/code&gt; jumps.

   &lt;br /&gt;
To use the &lt;code&gt;find-tag&lt;/code&gt; command, type &lt;kbd&gt;M-.&lt;/kbd&gt;  (i.e., press the
period key while holding down the &amp;lt;META&amp;gt; key, or else type the
&amp;lt;ESC&amp;gt; key and then type the period key), and then, at the prompt,
type in the name of the function whose source code you want to see,
such as &lt;code&gt;mark-whole-buffer&lt;/code&gt;, and then type &amp;lt;RET&amp;gt;.  Emacs will
switch buffers and display the source code for the function on your
screen.  To switch back to your current buffer, type &lt;kbd&gt;C-x b
&amp;lt;RET&amp;gt;&lt;/kbd&gt;.  (On some keyboards, the &amp;lt;META&amp;gt; key is labeled
&amp;lt;ALT&amp;gt;.)


   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-TAGS-table_002c-specifying-140&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-find_002dtag-141&quot;&gt;&lt;/a&gt;Depending on how the initial default values of your copy of Emacs are
set, you may also need to specify the location of your `tags table&#39;,
which is a file called &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;TAGS&lt;/span&gt;&lt;/samp&gt;.  For example, if you are
interested in Emacs sources, the tags table you will most likely want,
if it has already been created for you, will be in a subdirectory of
the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;/usr/local/share/emacs/&lt;/span&gt;&lt;/samp&gt; directory; thus you would use the
&lt;code&gt;M-x visit-tags-table&lt;/code&gt; command and specify a pathname such as
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;/usr/local/share/emacs/22.1.1/lisp/TAGS&lt;/span&gt;&lt;/samp&gt;.  If the tags table
has not already been created, you will have to create it yourself.  It
will be in a file such as &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;/usr/local/src/emacs/src/TAGS&lt;/span&gt;&lt;/samp&gt;.

   &lt;br /&gt;
To create a &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;TAGS&lt;/span&gt;&lt;/samp&gt; file in a specific directory, switch to that
directory in Emacs using &lt;kbd&gt;M-x cd&lt;/kbd&gt; command, or list the directory
with &lt;kbd&gt;C-x d&lt;/kbd&gt; (&lt;code&gt;dired&lt;/code&gt;).  Then run the compile command, with
&lt;code&gt;etags&amp;nbsp;*.el&lt;/code&gt; as the command to execute:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     M-x compile RET etags *.el RET
&lt;/pre&gt;
For more information, see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#etags&quot;&gt;Create Your Own &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;TAGS&lt;/span&gt;&lt;/samp&gt; File&lt;/a&gt;.

   &lt;br /&gt;
After you become more familiar with Emacs Lisp, you will find that you will
frequently use &lt;code&gt;find-tag&lt;/code&gt; to navigate your way around source code;
and you will create your own &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;TAGS&lt;/span&gt;&lt;/samp&gt; tables.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Library_002c-as-term-for-_0060file_0027-142&quot;&gt;&lt;/a&gt;Incidentally, the files that contain Lisp code are conventionally
called &lt;dfn&gt;libraries&lt;/dfn&gt;.  The metaphor is derived from that of a
specialized library, such as a law library or an engineering library,
rather than a general library.  Each library, or file, contains
functions that relate to a particular topic or activity, such as
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;abbrev.el&lt;/span&gt;&lt;/samp&gt; for handling abbreviations and other typing
shortcuts, and &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;help.el&lt;/span&gt;&lt;/samp&gt; for on-line help.  (Sometimes several
libraries provide code for a single activity, as the various
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;rmail...&lt;/span&gt;&lt;/samp&gt; files provide code for reading electronic mail.) 
In &lt;cite&gt;The GNU Emacs Manual&lt;/cite&gt;, you will see sentences such as “The
&lt;kbd&gt;C-h p&lt;/kbd&gt; command lets you search the standard Emacs Lisp libraries
by topic keywords.”

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;simplified-beginning-of-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;simplified_002dbeginning_002dof_002dbuffer&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mark_002dwhole_002dbuffer&quot; rel=&quot;next&quot;&gt;mark-whole-buffer&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Finding-More&quot; rel=&quot;previous&quot;&gt;Finding More&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Walk-Through&quot; rel=&quot;up&quot;&gt;Buffer Walk Through&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
4.2 A Simplified &lt;code&gt;beginning-of-buffer&lt;/code&gt; Definition&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-simplified_002dbeginning_002dof_002dbuffer-143&quot;&gt;&lt;/a&gt;
The &lt;code&gt;beginning-of-buffer&lt;/code&gt; command is a good function to start with
since you are likely to be familiar with it and it is easy to
understand.  Used as an interactive command, &lt;code&gt;beginning-of-buffer&lt;/code&gt;
moves the cursor to the beginning of the buffer, leaving the mark at the
previous position.  It is generally bound to &lt;kbd&gt;M-&amp;lt;&lt;/kbd&gt;.

   &lt;br /&gt;
In this section, we will discuss a shortened version of the function
that shows how it is most frequently used.  This shortened function
works as written, but it does not contain the code for a complex option. 
In another section, we will describe the entire function. 
(See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer&quot;&gt;Complete Definition of &lt;code&gt;beginning-of-buffer&lt;/code&gt;&lt;/a&gt;.)

   &lt;br /&gt;
Before looking at the code, let&#39;s consider what the function
definition has to contain: it must include an expression that makes
the function interactive so it can be called by typing &lt;kbd&gt;M-x
beginning-of-buffer&lt;/kbd&gt; or by typing a keychord such as &lt;kbd&gt;M-&amp;lt;&lt;/kbd&gt;; it
must include code to leave a mark at the original position in the
buffer; and it must include code to move the cursor to the beginning
of the buffer.

   &lt;br /&gt;
Here is the complete text of the shortened version of the function:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun simplified-beginning-of-buffer ()
       &quot;Move point to the beginning of the buffer;
     leave mark at previous position.&quot;
       (interactive)
       (push-mark)
       (goto-char (point-min)))
&lt;/pre&gt;
Like all function definitions, this definition has five parts following
the special form &lt;code&gt;defun&lt;/code&gt;:

     &lt;br /&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li&gt;The name: in this example, &lt;code&gt;simplified-beginning-of-buffer&lt;/code&gt;.

     &lt;/li&gt;
&lt;li&gt;A list of the arguments: in this example, an empty list, &lt;code&gt;()&lt;/code&gt;,

     &lt;/li&gt;
&lt;li&gt;The documentation string.

     &lt;/li&gt;
&lt;li&gt;The interactive expression.

     &lt;/li&gt;
&lt;li&gt;The body.
        &lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;noindent&quot;&gt;
In this function definition, the argument list is empty; this means that
this function does not require any arguments.  (When we look at the
definition for the complete function, we will see that it may be passed
an optional argument.)

   &lt;/div&gt;
The interactive expression tells Emacs that the function is intended to
be used interactively.  In this example, &lt;code&gt;interactive&lt;/code&gt; does not have
an argument because &lt;code&gt;simplified-beginning-of-buffer&lt;/code&gt; does not
require one.

   &lt;br /&gt;
The body of the function consists of the two lines:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (push-mark)
     (goto-char (point-min))
&lt;/pre&gt;
The first of these lines is the expression, &lt;code&gt;(push-mark)&lt;/code&gt;.  When
this expression is evaluated by the Lisp interpreter, it sets a mark at
the current position of the cursor, wherever that may be.  The position
of this mark is saved in the mark ring.

   &lt;br /&gt;
The next line is &lt;code&gt;(goto-char (point-min))&lt;/code&gt;.  This expression
jumps the cursor to the minimum point in the buffer, that is, to the
beginning of the buffer (or to the beginning of the accessible portion
of the buffer if it is narrowed.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot;&gt;Narrowing and Widening&lt;/a&gt;.)

   &lt;br /&gt;
The &lt;code&gt;push-mark&lt;/code&gt; command sets a mark at the place where the cursor
was located before it was moved to the beginning of the buffer by the
&lt;code&gt;(goto-char (point-min))&lt;/code&gt; expression.  Consequently, you can, if
you wish, go back to where you were originally by typing &lt;kbd&gt;C-x C-x&lt;/kbd&gt;.

   &lt;br /&gt;
That is all there is to the function definition!

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-describe_002dfunction-144&quot;&gt;&lt;/a&gt;When you are reading code such as this and come upon an unfamiliar
function, such as &lt;code&gt;goto-char&lt;/code&gt;, you can find out what it does by
using the &lt;code&gt;describe-function&lt;/code&gt; command.  To use this command, type
&lt;kbd&gt;C-h f&lt;/kbd&gt; and then type in the name of the function and press
&amp;lt;RET&amp;gt;.  The &lt;code&gt;describe-function&lt;/code&gt; command will print the
function&#39;s documentation string in a &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*Help*&lt;/span&gt;&lt;/samp&gt; window.  For
example, the documentation for &lt;code&gt;goto-char&lt;/code&gt; is:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     Set point to POSITION, a number or marker.
     Beginning of buffer is position (point-min), end is (point-max).
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The function&#39;s one argument is the desired position.

&lt;/div&gt;
&lt;div class=&quot;noindent&quot;&gt;
(The prompt for &lt;code&gt;describe-function&lt;/code&gt; will offer you the symbol
under or preceding the cursor, so you can save typing by positioning
the cursor right over or after the function and then typing &lt;kbd&gt;C-h f
&amp;lt;RET&amp;gt;&lt;/kbd&gt;.)

   &lt;/div&gt;
The &lt;code&gt;end-of-buffer&lt;/code&gt; function definition is written in the same way as
the &lt;code&gt;beginning-of-buffer&lt;/code&gt; definition except that the body of the
function contains the expression &lt;code&gt;(goto-char (point-max))&lt;/code&gt; in place
of &lt;code&gt;(goto-char (point-min))&lt;/code&gt;.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;mark-whole-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;mark_002dwhole_002dbuffer&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot; rel=&quot;next&quot;&gt;append-to-buffer&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#simplified_002dbeginning_002dof_002dbuffer&quot; rel=&quot;previous&quot;&gt;simplified-beginning-of-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Walk-Through&quot; rel=&quot;up&quot;&gt;Buffer Walk Through&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
4.3 The Definition of &lt;code&gt;mark-whole-buffer&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-mark_002dwhole_002dbuffer-145&quot;&gt;&lt;/a&gt;
The &lt;code&gt;mark-whole-buffer&lt;/code&gt; function is no harder to understand than the
&lt;code&gt;simplified-beginning-of-buffer&lt;/code&gt; function.  In this case, however,
we will look at the complete function, not a shortened version.

   &lt;br /&gt;
The &lt;code&gt;mark-whole-buffer&lt;/code&gt; function is not as commonly used as the
&lt;code&gt;beginning-of-buffer&lt;/code&gt; function, but is useful nonetheless: it
marks a whole buffer as a region by putting point at the beginning and
a mark at the end of the buffer.  It is generally bound to &lt;kbd&gt;C-x
h&lt;/kbd&gt;.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mark_002dwhole_002dbuffer-overview&quot;&gt;mark-whole-buffer overview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Body-of-mark_002dwhole_002dbuffer&quot;&gt;Body of mark-whole-buffer&lt;/a&gt;:    Only three lines of code. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;mark-whole-buffer-overview&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;mark_002dwhole_002dbuffer-overview&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Body-of-mark_002dwhole_002dbuffer&quot; rel=&quot;next&quot;&gt;Body of mark-whole-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mark_002dwhole_002dbuffer&quot; rel=&quot;up&quot;&gt;mark-whole-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
An overview of &lt;code&gt;mark-whole-buffer&lt;/code&gt;&lt;/h4&gt;
In GNU Emacs 22, the code for the complete function looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun mark-whole-buffer ()
       &quot;Put point at beginning and mark at end of buffer.
     You probably should not use this function in Lisp programs;
     it is usually a mistake for a Lisp function to use any subroutine
     that uses or sets the mark.&quot;
       (interactive)
       (push-mark (point))
       (push-mark (point-max) nil t)
       (goto-char (point-min)))
&lt;/pre&gt;
Like all other functions, the &lt;code&gt;mark-whole-buffer&lt;/code&gt; function fits
into the template for a function definition.  The template looks like
this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun &lt;var&gt;name-of-function&lt;/var&gt; (&lt;var&gt;argument-list&lt;/var&gt;)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       (&lt;var&gt;interactive-expression&lt;/var&gt;...)
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
Here is how the function works: the name of the function is
&lt;code&gt;mark-whole-buffer&lt;/code&gt;; it is followed by an empty argument list,
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;()&lt;/span&gt;&lt;/samp&gt;’, which means that the function does not require arguments. 
The documentation comes next.

   &lt;br /&gt;
The next line is an &lt;code&gt;(interactive)&lt;/code&gt; expression that tells Emacs
that the function will be used interactively.  These details are similar
to the &lt;code&gt;simplified-beginning-of-buffer&lt;/code&gt; function described in the
previous section.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Body-of-mark-whole-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Body-of-mark_002dwhole_002dbuffer&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mark_002dwhole_002dbuffer-overview&quot; rel=&quot;previous&quot;&gt;mark-whole-buffer overview&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mark_002dwhole_002dbuffer&quot; rel=&quot;up&quot;&gt;mark-whole-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
4.3.1 Body of &lt;code&gt;mark-whole-buffer&lt;/code&gt;&lt;/h4&gt;
The body of the &lt;code&gt;mark-whole-buffer&lt;/code&gt; function consists of three
lines of code:


&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (push-mark (point))
     (push-mark (point-max) nil t)
     (goto-char (point-min))
&lt;/pre&gt;
The first of these lines is the expression, &lt;code&gt;(push-mark (point))&lt;/code&gt;.

   &lt;br /&gt;
This line does exactly the same job as the first line of the body of
the &lt;code&gt;simplified-beginning-of-buffer&lt;/code&gt; function, which is written
&lt;code&gt;(push-mark)&lt;/code&gt;.  In both cases, the Lisp interpreter sets a mark
at the current position of the cursor.

   &lt;br /&gt;
I don&#39;t know why the expression in &lt;code&gt;mark-whole-buffer&lt;/code&gt; is written
&lt;code&gt;(push-mark (point))&lt;/code&gt; and the expression in
&lt;code&gt;beginning-of-buffer&lt;/code&gt; is written &lt;code&gt;(push-mark)&lt;/code&gt;.  Perhaps
whoever wrote the code did not know that the arguments for
&lt;code&gt;push-mark&lt;/code&gt; are optional and that if &lt;code&gt;push-mark&lt;/code&gt; is not
passed an argument, the function automatically sets mark at the
location of point by default.  Or perhaps the expression was written
so as to parallel the structure of the next line.  In any case, the
line causes Emacs to determine the position of point and set a mark
there.

   &lt;br /&gt;
In earlier versions of GNU Emacs, the next line of
&lt;code&gt;mark-whole-buffer&lt;/code&gt; was &lt;code&gt;(push-mark (point-max))&lt;/code&gt;.  This
expression sets a mark at the point in the buffer that has the highest
number.  This will be the end of the buffer (or, if the buffer is
narrowed, the end of the accessible portion of the buffer. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot;&gt;Narrowing and Widening&lt;/a&gt;, for more about
narrowing.)  After this mark has been set, the previous mark, the one
set at point, is no longer set, but Emacs remembers its position, just
as all other recent marks are always remembered.  This means that you
can, if you wish, go back to that position by typing &lt;kbd&gt;C-u
C-&amp;lt;SPC&amp;gt;&lt;/kbd&gt; twice.

   &lt;br /&gt;
In GNU Emacs 22, the &lt;code&gt;(point-max)&lt;/code&gt; is slightly more complicated. 
The line reads

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (push-mark (point-max) nil t)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The expression works nearly the same as before.  It sets a mark at the
highest numbered place in the buffer that it can.  However, in this
version, &lt;code&gt;push-mark&lt;/code&gt; has two additional arguments.  The second
argument to &lt;code&gt;push-mark&lt;/code&gt; is &lt;code&gt;nil&lt;/code&gt;.  This tells the function
it &lt;em&gt;should&lt;/em&gt; display a message that says `Mark set&#39; when it pushes
the mark.  The third argument is &lt;code&gt;t&lt;/code&gt;.  This tells
&lt;code&gt;push-mark&lt;/code&gt; to activate the mark when Transient Mark mode is
turned on.  Transient Mark mode highlights the currently active
region.  It is often turned off.

   &lt;/div&gt;
Finally, the last line of the function is &lt;code&gt;(goto-char
(point-min)))&lt;/code&gt;.  This is written exactly the same way as it is written
in &lt;code&gt;beginning-of-buffer&lt;/code&gt;.  The expression moves the cursor to
the minimum point in the buffer, that is, to the beginning of the buffer
(or to the beginning of the accessible portion of the buffer).  As a
result of this, point is placed at the beginning of the buffer and mark
is set at the end of the buffer.  The whole buffer is, therefore, the
region.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;append-to-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;append_002dto_002dbuffer&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Related-Review&quot; rel=&quot;next&quot;&gt;Buffer Related Review&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#mark_002dwhole_002dbuffer&quot; rel=&quot;previous&quot;&gt;mark-whole-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Walk-Through&quot; rel=&quot;up&quot;&gt;Buffer Walk Through&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
4.4 The Definition of &lt;code&gt;append-to-buffer&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-append_002dto_002dbuffer-146&quot;&gt;&lt;/a&gt;
The &lt;code&gt;append-to-buffer&lt;/code&gt; command is more complex than the
&lt;code&gt;mark-whole-buffer&lt;/code&gt; command.  What it does is copy the region
(that is, the part of the buffer between point and mark) from the
current buffer to a specified buffer.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer-overview&quot;&gt;append-to-buffer overview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append-interactive&quot;&gt;append interactive&lt;/a&gt;:           A two part interactive expression. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer-body&quot;&gt;append-to-buffer body&lt;/a&gt;:        Incorporates a &lt;code&gt;let&lt;/code&gt; expression. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append-save_002dexcursion&quot;&gt;append save-excursion&lt;/a&gt;:        How the &lt;code&gt;save-excursion&lt;/code&gt; works. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;append-to-buffer-overview&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;append_002dto_002dbuffer-overview&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append-interactive&quot; rel=&quot;next&quot;&gt;append interactive&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot; rel=&quot;up&quot;&gt;append-to-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
An Overview of &lt;code&gt;append-to-buffer&lt;/code&gt;&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-insert_002dbuffer_002dsubstring-147&quot;&gt;&lt;/a&gt;The &lt;code&gt;append-to-buffer&lt;/code&gt; command uses the
&lt;code&gt;insert-buffer-substring&lt;/code&gt; function to copy the region. 
&lt;code&gt;insert-buffer-substring&lt;/code&gt; is described by its name: it takes a
string of characters from part of a buffer, a “substring”, and
inserts them into another buffer.

   &lt;br /&gt;
Most of &lt;code&gt;append-to-buffer&lt;/code&gt; is
concerned with setting up the conditions for
&lt;code&gt;insert-buffer-substring&lt;/code&gt; to work: the code must specify both the
buffer to which the text will go, the window it comes from and goes
to, and the region that will be copied.

   &lt;br /&gt;
Here is the complete text of the function:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun append-to-buffer (buffer start end)
       &quot;Append to specified buffer the text of the region.
     It is inserted into that buffer before its point.
     
     When calling from a program, give three arguments:
     BUFFER (or buffer name), START and END.
     START and END specify the portion of the current buffer to be copied.&quot;
       (interactive
        (list (read-buffer &quot;Append to buffer: &quot; (other-buffer
                                                 (current-buffer) t))
              (region-beginning) (region-end)))
       (let ((oldbuf (current-buffer)))
         (save-excursion
           (let* ((append-to (get-buffer-create buffer))
                  (windows (get-buffer-window-list append-to t t))
                  point)
             (set-buffer append-to)
             (setq point (point))
             (barf-if-buffer-read-only)
             (insert-buffer-substring oldbuf start end)
             (dolist (window windows)
               (when (= (window-point window) point)
                 (set-window-point window (point))))))))
&lt;/pre&gt;
The function can be understood by looking at it as a series of
filled-in templates.

   &lt;br /&gt;
The outermost template is for the function definition.  In this
function, it looks like this (with several slots filled in):

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun append-to-buffer (buffer start end)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       (interactive ...)
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
The first line of the function includes its name and three arguments. 
The arguments are the &lt;code&gt;buffer&lt;/code&gt; to which the text will be copied, and
the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; of the region in the current buffer that
will be copied.

   &lt;br /&gt;
The next part of the function is the documentation, which is clear and
complete.  As is conventional, the three arguments are written in
upper case so you will notice them easily.  Even better, they are
described in the same order as in the argument list.

   &lt;br /&gt;
Note that the documentation distinguishes between a buffer and its
name.  (The function can handle either.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;append-interactive&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer-body&quot; rel=&quot;next&quot;&gt;append-to-buffer body&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer-overview&quot; rel=&quot;previous&quot;&gt;append-to-buffer overview&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot; rel=&quot;up&quot;&gt;append-to-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
4.4.1 The &lt;code&gt;append-to-buffer&lt;/code&gt; Interactive Expression&lt;/h4&gt;
Since the &lt;code&gt;append-to-buffer&lt;/code&gt; function will be used interactively,
the function must have an &lt;code&gt;interactive&lt;/code&gt; expression.  (For a
review of &lt;code&gt;interactive&lt;/code&gt;, see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Interactive&quot;&gt;Making a Function Interactive&lt;/a&gt;.)  The expression reads as follows:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (interactive
      (list (read-buffer
             &quot;Append to buffer: &quot;
             (other-buffer (current-buffer) t))
            (region-beginning)
            (region-end)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
This expression is not one with letters standing for parts, as
described earlier.  Instead, it starts a list with these parts:

   &lt;/div&gt;
The first part of the list is an expression to read the name of a
buffer and return it as a string.  That is &lt;code&gt;read-buffer&lt;/code&gt;.  The
function requires a prompt as its first argument, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;&quot;Append to
buffer: &quot;&lt;/span&gt;&lt;/samp&gt;’.  Its second argument tells the command what value to
provide if you don&#39;t specify anything.

   &lt;br /&gt;
In this case that second argument is an expression containing the
function &lt;code&gt;other-buffer&lt;/code&gt;, an exception, and a ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;t&lt;/span&gt;&lt;/samp&gt;’, standing
for true.

   &lt;br /&gt;
The first argument to &lt;code&gt;other-buffer&lt;/code&gt;, the exception, is yet
another function, &lt;code&gt;current-buffer&lt;/code&gt;.  That is not going to be
returned.  The second argument is the symbol for true, &lt;code&gt;t&lt;/code&gt;. that
tells &lt;code&gt;other-buffer&lt;/code&gt; that it may show visible buffers (except in
this case, it will not show the current buffer, which makes sense).

   &lt;br /&gt;
The expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (other-buffer (current-buffer) t)
&lt;/pre&gt;
The second and third arguments to the &lt;code&gt;list&lt;/code&gt; expression are
&lt;code&gt;(region-beginning)&lt;/code&gt; and &lt;code&gt;(region-end)&lt;/code&gt;.  These two
functions specify the beginning and end of the text to be appended.

   &lt;br /&gt;
Originally, the command used the letters ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;B&lt;/span&gt;&lt;/samp&gt;’ and ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;r&lt;/span&gt;&lt;/samp&gt;’. 
The whole &lt;code&gt;interactive&lt;/code&gt; expression looked like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (interactive &quot;BAppend to buffer: \nr&quot;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
But when that was done, the default value of the buffer switched to
was invisible.  That was not wanted.

   &lt;/div&gt;
(The prompt was separated from the second argument with a newline,
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;\n&lt;/span&gt;&lt;/samp&gt;’.  It was followed by an ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;r&lt;/span&gt;&lt;/samp&gt;’ that told Emacs to bind the
two arguments that follow the symbol &lt;code&gt;buffer&lt;/code&gt; in the function&#39;s
argument list (that is, &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt;) to the values of
point and mark.  That argument worked fine.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;append-to-buffer-body&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;append_002dto_002dbuffer-body&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append-save_002dexcursion&quot; rel=&quot;next&quot;&gt;append save-excursion&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append-interactive&quot; rel=&quot;previous&quot;&gt;append interactive&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot; rel=&quot;up&quot;&gt;append-to-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
4.4.2 The Body of &lt;code&gt;append-to-buffer&lt;/code&gt;&lt;/h4&gt;
The body of the &lt;code&gt;append-to-buffer&lt;/code&gt; function begins with &lt;code&gt;let&lt;/code&gt;.

   &lt;br /&gt;
As we have seen before (see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#let&quot;&gt;&lt;code&gt;let&lt;/code&gt;&lt;/a&gt;), the purpose of a
&lt;code&gt;let&lt;/code&gt; expression is to create and give initial values to one or
more variables that will only be used within the body of the
&lt;code&gt;let&lt;/code&gt;.  This means that such a variable will not be confused with
any variable of the same name outside the &lt;code&gt;let&lt;/code&gt; expression.

   &lt;br /&gt;
We can see how the &lt;code&gt;let&lt;/code&gt; expression fits into the function as a
whole by showing a template for &lt;code&gt;append-to-buffer&lt;/code&gt; with the
&lt;code&gt;let&lt;/code&gt; expression in outline:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun append-to-buffer (buffer start end)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       (interactive ...)
       (let ((&lt;var&gt;variable&lt;/var&gt; &lt;var&gt;value&lt;/var&gt;))
             &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
The &lt;code&gt;let&lt;/code&gt; expression has three elements:

     &lt;br /&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li&gt;The symbol &lt;code&gt;let&lt;/code&gt;;

     &lt;/li&gt;
&lt;li&gt;A varlist containing, in this case, a single two-element list,
&lt;code&gt;(&lt;/code&gt;&lt;var&gt;variable&lt;/var&gt; &lt;var&gt;value&lt;/var&gt;&lt;code&gt;)&lt;/code&gt;;

     &lt;/li&gt;
&lt;li&gt;The body of the &lt;code&gt;let&lt;/code&gt; expression.
        &lt;/li&gt;
&lt;/ol&gt;
In the &lt;code&gt;append-to-buffer&lt;/code&gt; function, the varlist looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (oldbuf (current-buffer))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In this part of the &lt;code&gt;let&lt;/code&gt; expression, the one variable,
&lt;code&gt;oldbuf&lt;/code&gt;, is bound to the value returned by the
&lt;code&gt;(current-buffer)&lt;/code&gt; expression.  The variable, &lt;code&gt;oldbuf&lt;/code&gt;, is
used to keep track of the buffer in which you are working and from
which you will copy.

   &lt;/div&gt;
The element or elements of a varlist are surrounded by a set of
parentheses so the Lisp interpreter can distinguish the varlist from
the body of the &lt;code&gt;let&lt;/code&gt;.  As a consequence, the two-element list
within the varlist is surrounded by a circumscribing set of parentheses. 
The line looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let ((oldbuf (current-buffer)))
       ... )
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The two parentheses before &lt;code&gt;oldbuf&lt;/code&gt; might surprise you if you did
not realize that the first parenthesis before &lt;code&gt;oldbuf&lt;/code&gt; marks the
boundary of the varlist and the second parenthesis marks the beginning
of the two-element list, &lt;code&gt;(oldbuf (current-buffer))&lt;/code&gt;.

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;append-save-excursion&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;append-save_002dexcursion&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer-body&quot; rel=&quot;previous&quot;&gt;append-to-buffer body&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot; rel=&quot;up&quot;&gt;append-to-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
4.4.3 &lt;code&gt;save-excursion&lt;/code&gt; in &lt;code&gt;append-to-buffer&lt;/code&gt;&lt;/h4&gt;
The body of the &lt;code&gt;let&lt;/code&gt; expression in &lt;code&gt;append-to-buffer&lt;/code&gt;
consists of a &lt;code&gt;save-excursion&lt;/code&gt; expression.

   &lt;br /&gt;
The &lt;code&gt;save-excursion&lt;/code&gt; function saves the locations of point and
mark, and restores them to those positions after the expressions in the
body of the &lt;code&gt;save-excursion&lt;/code&gt; complete execution.  In addition,
&lt;code&gt;save-excursion&lt;/code&gt; keeps track of the original buffer, and
restores it.  This is how &lt;code&gt;save-excursion&lt;/code&gt; is used in
&lt;code&gt;append-to-buffer&lt;/code&gt;.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Indentation-for-formatting-148&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Formatting-convention-149&quot;&gt;&lt;/a&gt;Incidentally, it is worth noting here that a Lisp function is normally
formatted so that everything that is enclosed in a multi-line spread is
indented more to the right than the first symbol.  In this function
definition, the &lt;code&gt;let&lt;/code&gt; is indented more than the &lt;code&gt;defun&lt;/code&gt;, and
the &lt;code&gt;save-excursion&lt;/code&gt; is indented more than the &lt;code&gt;let&lt;/code&gt;, like
this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun ...
       ...
       ...
       (let...
         (save-excursion
           ...
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
This formatting convention makes it easy to see that the lines in
the body of the &lt;code&gt;save-excursion&lt;/code&gt; are enclosed by the parentheses
associated with &lt;code&gt;save-excursion&lt;/code&gt;, just as the
&lt;code&gt;save-excursion&lt;/code&gt; itself is enclosed by the parentheses associated
with the &lt;code&gt;let&lt;/code&gt;:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let ((oldbuf (current-buffer)))
       (save-excursion
         ...
         (set-buffer ...)
         (insert-buffer-substring oldbuf start end)
         ...))
&lt;/pre&gt;
The use of the &lt;code&gt;save-excursion&lt;/code&gt; function can be viewed as a process
of filling in the slots of a template:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (save-excursion
       &lt;var&gt;first-expression-in-body&lt;/var&gt;
       &lt;var&gt;second-expression-in-body&lt;/var&gt;
        ...
       &lt;var&gt;last-expression-in-body&lt;/var&gt;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In this function, the body of the &lt;code&gt;save-excursion&lt;/code&gt; contains only
one expression, the &lt;code&gt;let*&lt;/code&gt; expression.  You know about a
&lt;code&gt;let&lt;/code&gt; function.  The &lt;code&gt;let*&lt;/code&gt; function is different.  It has a
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;*&lt;/span&gt;&lt;/samp&gt;’ in its name.  It enables Emacs to set each variable in its
varlist in sequence, one after another.

   &lt;/div&gt;
Its critical feature is that variables later in the varlist can make
use of the values to which Emacs set variables earlier in the varlist. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fwd_002dpara-let&quot;&gt;The &lt;code&gt;let*&lt;/code&gt; expression&lt;/a&gt;.

   &lt;br /&gt;
We will skip functions like &lt;code&gt;let*&lt;/code&gt; and focus on two: the
&lt;code&gt;set-buffer&lt;/code&gt; function and the &lt;code&gt;insert-buffer-substring&lt;/code&gt;
function.

   &lt;br /&gt;
In the old days, the &lt;code&gt;set-buffer&lt;/code&gt; expression was simply

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (set-buffer (get-buffer-create buffer))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
but now it is

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (set-buffer append-to)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
&lt;code&gt;append-to&lt;/code&gt; is bound to &lt;code&gt;(get-buffer-create buffer)&lt;/code&gt; earlier
on in the &lt;code&gt;let*&lt;/code&gt; expression.  That extra binding would not be
necessary except for that &lt;code&gt;append-to&lt;/code&gt; is used later in the
varlist as an argument to &lt;code&gt;get-buffer-window-list&lt;/code&gt;.

   &lt;/div&gt;
The &lt;code&gt;append-to-buffer&lt;/code&gt; function definition inserts text from the
buffer in which you are currently to a named buffer.  It happens that
&lt;code&gt;insert-buffer-substring&lt;/code&gt; copies text from another buffer to the
current buffer, just the reverse—that is why the
&lt;code&gt;append-to-buffer&lt;/code&gt; definition starts out with a &lt;code&gt;let&lt;/code&gt; that
binds the local symbol &lt;code&gt;oldbuf&lt;/code&gt; to the value returned by
&lt;code&gt;current-buffer&lt;/code&gt;.

   &lt;br /&gt;
The &lt;code&gt;insert-buffer-substring&lt;/code&gt; expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (insert-buffer-substring oldbuf start end)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The &lt;code&gt;insert-buffer-substring&lt;/code&gt; function copies a string
&lt;em&gt;from&lt;/em&gt; the buffer specified as its first argument and inserts the
string into the present buffer.  In this case, the argument to
&lt;code&gt;insert-buffer-substring&lt;/code&gt; is the value of the variable created
and bound by the &lt;code&gt;let&lt;/code&gt;, namely the value of &lt;code&gt;oldbuf&lt;/code&gt;, which
was the current buffer when you gave the &lt;code&gt;append-to-buffer&lt;/code&gt;
command.

   &lt;/div&gt;
After &lt;code&gt;insert-buffer-substring&lt;/code&gt; has done its work,
&lt;code&gt;save-excursion&lt;/code&gt; will restore the action to the original buffer
and &lt;code&gt;append-to-buffer&lt;/code&gt; will have done its job.

   &lt;br /&gt;
Written in skeletal form, the workings of the body look like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let (&lt;var&gt;bind-&lt;/var&gt;&lt;code&gt;oldbuf&lt;/code&gt;&lt;var&gt;-to-value-of-&lt;/var&gt;&lt;code&gt;current-buffer&lt;/code&gt;)
       (save-excursion                       ; &lt;span class=&quot;roman&quot;&gt;Keep track of buffer.&lt;/span&gt;
         &lt;var&gt;change-buffer&lt;/var&gt;
         &lt;var&gt;insert-substring-from-&lt;/var&gt;&lt;code&gt;oldbuf&lt;/code&gt;&lt;var&gt;-into-buffer&lt;/var&gt;)
     
       &lt;var&gt;change-back-to-original-buffer-when-finished&lt;/var&gt;
     &lt;var&gt;let-the-local-meaning-of-&lt;/var&gt;&lt;code&gt;oldbuf&lt;/code&gt;&lt;var&gt;-disappear-when-finished&lt;/var&gt;
&lt;/pre&gt;
In summary, &lt;code&gt;append-to-buffer&lt;/code&gt; works as follows: it saves the
value of the current buffer in the variable called &lt;code&gt;oldbuf&lt;/code&gt;.  It
gets the new buffer (creating one if need be) and switches Emacs&#39;s
attention to it.  Using the value of &lt;code&gt;oldbuf&lt;/code&gt;, it inserts the
region of text from the old buffer into the new buffer; and then using
&lt;code&gt;save-excursion&lt;/code&gt;, it brings you back to your original buffer.

   &lt;br /&gt;
In looking at &lt;code&gt;append-to-buffer&lt;/code&gt;, you have explored a fairly
complex function.  It shows how to use &lt;code&gt;let&lt;/code&gt; and
&lt;code&gt;save-excursion&lt;/code&gt;, and how to change to and come back from another
buffer.  Many function definitions use &lt;code&gt;let&lt;/code&gt;,
&lt;code&gt;save-excursion&lt;/code&gt;, and &lt;code&gt;set-buffer&lt;/code&gt; this way.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Buffer-Related-Review&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Exercises&quot; rel=&quot;next&quot;&gt;Buffer Exercises&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot; rel=&quot;previous&quot;&gt;append-to-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Walk-Through&quot; rel=&quot;up&quot;&gt;Buffer Walk Through&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
4.5 Review&lt;/h3&gt;
Here is a brief summary of the various functions discussed in this chapter.

     &lt;br /&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;describe-function&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;describe-variable&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Print the documentation for a function or variable. 
Conventionally bound to &lt;kbd&gt;C-h f&lt;/kbd&gt; and &lt;kbd&gt;C-h v&lt;/kbd&gt;.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;find-tag&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Find the file containing the source for a function or variable and
switch buffers to it, positioning point at the beginning of the item. 
Conventionally bound to &lt;kbd&gt;M-.&lt;/kbd&gt; (that&#39;s a period following the
&amp;lt;META&amp;gt; key).

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;save-excursion&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Save the location of point and mark and restore their values after the
arguments to &lt;code&gt;save-excursion&lt;/code&gt; have been evaluated.  Also, remember
the current buffer and return to it.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;push-mark&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Set mark at a location and record the value of the previous mark on the
mark ring.  The mark is a location in the buffer that will keep its
relative position even if text is added to or removed from the buffer.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;goto-char&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Set point to the location specified by the value of the argument, which
can be a number, a marker,  or an expression that returns the number of
a position, such as &lt;code&gt;(point-min)&lt;/code&gt;.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;insert-buffer-substring&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Copy a region of text from a buffer that is passed to the function as
an argument and insert the region into the current buffer.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;mark-whole-buffer&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Mark the whole buffer as a region.  Normally bound to &lt;kbd&gt;C-x h&lt;/kbd&gt;.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;set-buffer&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Switch the attention of Emacs to another buffer, but do not change the
window being displayed.  Used when the program rather than a human is
to work on a different buffer.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;get-buffer-create&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;get-buffer&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Find a named buffer or create one if a buffer of that name does not
exist.  The &lt;code&gt;get-buffer&lt;/code&gt; function returns &lt;code&gt;nil&lt;/code&gt; if the named
buffer does not exist. 
&lt;/dd&gt;&lt;/dl&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Buffer-Exercises&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Related-Review&quot; rel=&quot;previous&quot;&gt;Buffer Related Review&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Walk-Through&quot; rel=&quot;up&quot;&gt;Buffer Walk Through&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
4.6 Exercises&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Write your own &lt;code&gt;simplified-end-of-buffer&lt;/code&gt; function definition;
then test it to see whether it works.

     &lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;get-buffer&lt;/code&gt; to write a function that prints a
message telling you whether a buffer exists.

     &lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;find-tag&lt;/code&gt;, find the source for the &lt;code&gt;copy-to-buffer&lt;/code&gt;
function. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;More-Complex&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot; rel=&quot;next&quot;&gt;Narrowing &amp;amp; Widening&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Buffer-Walk-Through&quot; rel=&quot;previous&quot;&gt;Buffer Walk Through&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
5 A Few More Complex Functions&lt;/h2&gt;
In this chapter, we build on what we have learned in previous chapters
by looking at more complex functions.  The &lt;code&gt;copy-to-buffer&lt;/code&gt;
function illustrates use of two &lt;code&gt;save-excursion&lt;/code&gt; expressions in
one definition, while the &lt;code&gt;insert-buffer&lt;/code&gt; function illustrates
use of an asterisk in an &lt;code&gt;interactive&lt;/code&gt; expression, use of
&lt;code&gt;or&lt;/code&gt;, and the important distinction between a name and the object
to which the name refers.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dto_002dbuffer&quot;&gt;copy-to-buffer&lt;/a&gt;:               With &lt;code&gt;set-buffer&lt;/code&gt;, &lt;code&gt;get-buffer-create&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot;&gt;insert-buffer&lt;/a&gt;:                Read-only, and with &lt;code&gt;or&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer&quot;&gt;beginning-of-buffer&lt;/a&gt;:          Shows &lt;code&gt;goto-char&lt;/code&gt;,
                                &lt;code&gt;point-min&lt;/code&gt;, and &lt;code&gt;push-mark&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Second-Buffer-Related-Review&quot;&gt;Second Buffer Related Review&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#optional-Exercise&quot;&gt;optional Exercise&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;copy-to-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;copy_002dto_002dbuffer&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot; rel=&quot;next&quot;&gt;insert-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#More-Complex&quot; rel=&quot;up&quot;&gt;More Complex&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
5.1 The Definition of &lt;code&gt;copy-to-buffer&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-copy_002dto_002dbuffer-150&quot;&gt;&lt;/a&gt;
After understanding how &lt;code&gt;append-to-buffer&lt;/code&gt; works, it is easy to
understand &lt;code&gt;copy-to-buffer&lt;/code&gt;.  This function copies text into a
buffer, but instead of adding to the second buffer, it replaces all the
previous text in the second buffer.

   &lt;br /&gt;
The body of &lt;code&gt;copy-to-buffer&lt;/code&gt; looks like this,

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     ...
     (interactive &quot;BCopy to buffer: \nr&quot;)
     (let ((oldbuf (current-buffer)))
       (with-current-buffer (get-buffer-create buffer)
         (barf-if-buffer-read-only)
         (erase-buffer)
         (save-excursion
           (insert-buffer-substring oldbuf start end)))))
&lt;/pre&gt;
The &lt;code&gt;copy-to-buffer&lt;/code&gt; function has a simpler &lt;code&gt;interactive&lt;/code&gt;
expression than &lt;code&gt;append-to-buffer&lt;/code&gt;.

   &lt;br /&gt;
The definition then says

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (with-current-buffer (get-buffer-create buffer) ...
&lt;/pre&gt;
First, look at the earliest inner expression; that is evaluated first. 
That expression starts with &lt;code&gt;get-buffer-create buffer&lt;/code&gt;.  The
function tells the computer to use the buffer with the name specified
as the one to which you are copying, or if such a buffer does not
exist, to create it.  Then, the &lt;code&gt;with-current-buffer&lt;/code&gt; function
evaluates its body with that buffer temporarily current.

   &lt;br /&gt;
(This demonstrates another way to shift the computer&#39;s attention but
not the user&#39;s.  The &lt;code&gt;append-to-buffer&lt;/code&gt; function showed how to do
the same with &lt;code&gt;save-excursion&lt;/code&gt; and &lt;code&gt;set-buffer&lt;/code&gt;. 
&lt;code&gt;with-current-buffer&lt;/code&gt; is a newer, and arguably easier,
mechanism.)

   &lt;br /&gt;
The &lt;code&gt;barf-if-buffer-read-only&lt;/code&gt; function sends you an error
message saying the buffer is read-only if you cannot modify it.

   &lt;br /&gt;
The next line has the &lt;code&gt;erase-buffer&lt;/code&gt; function as its sole
contents.  That function erases the buffer.

   &lt;br /&gt;
Finally, the last two lines contain the &lt;code&gt;save-excursion&lt;/code&gt;
expression with &lt;code&gt;insert-buffer-substring&lt;/code&gt; as its body. 
The  &lt;code&gt;insert-buffer-substring&lt;/code&gt; expression copies the text from
the buffer you are in (and you have not seen the computer shift its
attention, so you don&#39;t know that that buffer is now called
&lt;code&gt;oldbuf&lt;/code&gt;).

   &lt;br /&gt;
Incidentally, this is what is meant by `replacement&#39;.  To replace text,
Emacs erases the previous text and then inserts new text.

   &lt;br /&gt;
In outline, the body of &lt;code&gt;copy-to-buffer&lt;/code&gt; looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let (&lt;var&gt;bind-&lt;/var&gt;&lt;code&gt;oldbuf&lt;/code&gt;&lt;var&gt;-to-value-of-&lt;/var&gt;&lt;code&gt;current-buffer&lt;/code&gt;)
         (&lt;var&gt;with-the-buffer-you-are-copying-to&lt;/var&gt;
           (&lt;var&gt;but-do-not-erase-or-copy-to-a-read-only-buffer&lt;/var&gt;)
           (erase-buffer)
           (save-excursion
             &lt;var&gt;insert-substring-from-&lt;/var&gt;&lt;code&gt;oldbuf&lt;/code&gt;&lt;var&gt;-into-buffer&lt;/var&gt;)))
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;insert-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;insert_002dbuffer&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer&quot; rel=&quot;next&quot;&gt;beginning-of-buffer&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dto_002dbuffer&quot; rel=&quot;previous&quot;&gt;copy-to-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#More-Complex&quot; rel=&quot;up&quot;&gt;More Complex&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
5.2 The Definition of &lt;code&gt;insert-buffer&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-insert_002dbuffer-151&quot;&gt;&lt;/a&gt;
&lt;code&gt;insert-buffer&lt;/code&gt; is yet another buffer-related function.  This
command copies another buffer &lt;em&gt;into&lt;/em&gt; the current buffer.  It is the
reverse of &lt;code&gt;append-to-buffer&lt;/code&gt; or &lt;code&gt;copy-to-buffer&lt;/code&gt;, since they
copy a region of text &lt;em&gt;from&lt;/em&gt; the current buffer to another buffer.

   &lt;br /&gt;
Here is a discussion based on the original code.  The code was
simplified in 2003 and is harder to understand.

   &lt;br /&gt;
(See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#New-insert_002dbuffer&quot;&gt;New Body for &lt;code&gt;insert-buffer&lt;/code&gt;&lt;/a&gt;, to see
a discussion of the new body.)

   &lt;br /&gt;
In addition, this code illustrates the use of &lt;code&gt;interactive&lt;/code&gt; with a
buffer that might be &lt;dfn&gt;read-only&lt;/dfn&gt; and the important distinction
between the name of an object and the object actually referred to.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-code&quot;&gt;insert-buffer code&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-interactive&quot;&gt;insert-buffer interactive&lt;/a&gt;:    When you can read, but not write. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-body&quot;&gt;insert-buffer body&lt;/a&gt;:           The body has an &lt;code&gt;or&lt;/code&gt; and a &lt;code&gt;let&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if-_0026-or&quot;&gt;if &amp;amp; or&lt;/a&gt;:                      Using an &lt;code&gt;if&lt;/code&gt; instead of an &lt;code&gt;or&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Insert-or&quot;&gt;Insert or&lt;/a&gt;:                    How the &lt;code&gt;or&lt;/code&gt; expression works. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Insert-let&quot;&gt;Insert let&lt;/a&gt;:                   Two &lt;code&gt;save-excursion&lt;/code&gt; expressions. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;7&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#New-insert_002dbuffer&quot;&gt;New insert-buffer&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;insert-buffer-code&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;insert_002dbuffer-code&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-interactive&quot; rel=&quot;next&quot;&gt;insert-buffer interactive&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot; rel=&quot;up&quot;&gt;insert-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
The Code for &lt;code&gt;insert-buffer&lt;/code&gt;&lt;/h4&gt;
Here is the earlier code:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun insert-buffer (buffer)
       &quot;Insert after point the contents of BUFFER.
     Puts mark after the inserted text.
     BUFFER may be a buffer or a buffer name.&quot;
       (interactive &quot;*bInsert buffer: &quot;)
       (or (bufferp buffer)
           (setq buffer (get-buffer buffer)))
       (let (start end newmark)
         (save-excursion
           (save-excursion
             (set-buffer buffer)
             (setq start (point-min) end (point-max)))
           (insert-buffer-substring buffer start end)
           (setq newmark (point)))
         (push-mark newmark)))
&lt;/pre&gt;
As with other function definitions, you can use a template to see an
outline of the function:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun insert-buffer (buffer)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       (interactive &quot;*bInsert buffer: &quot;)
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;insert-buffer-interactive&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;insert_002dbuffer-interactive&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-body&quot; rel=&quot;next&quot;&gt;insert-buffer body&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-code&quot; rel=&quot;previous&quot;&gt;insert-buffer code&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot; rel=&quot;up&quot;&gt;insert-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
5.2.1 The Interactive Expression in &lt;code&gt;insert-buffer&lt;/code&gt;&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-interactive_002c-_0040r_007bexample-use-of_007d-152&quot;&gt;&lt;/a&gt;
In &lt;code&gt;insert-buffer&lt;/code&gt;, the argument to the &lt;code&gt;interactive&lt;/code&gt;
declaration has two parts, an asterisk, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;*&lt;/span&gt;&lt;/samp&gt;’, and ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;bInsert
buffer: &lt;/span&gt;&lt;/samp&gt;’.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Read_002donly-buffer&quot;&gt;Read-only buffer&lt;/a&gt;:             When a buffer cannot be modified. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#b-for-interactive&quot;&gt;b for interactive&lt;/a&gt;:            An existing buffer or else its name. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Read-only-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Read_002donly-buffer&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#b-for-interactive&quot; rel=&quot;next&quot;&gt;b for interactive&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-interactive&quot; rel=&quot;up&quot;&gt;insert-buffer interactive&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
A Read-only Buffer&lt;/h5&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Read_002donly-buffer-153&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Asterisk-for-read_002donly-buffer-154&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_002a-_0040r_007bfor-read_002donly-buffer_007d-155&quot;&gt;&lt;/a&gt;
The asterisk is for the situation when the current buffer is a
read-only buffer—a buffer that cannot be modified.  If
&lt;code&gt;insert-buffer&lt;/code&gt; is called when the current buffer is read-only, a
message to this effect is printed in the echo area and the terminal
may beep or blink at you; you will not be permitted to insert anything
into current buffer.  The asterisk does not need to be followed by a
newline to separate it from the next argument.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;b-for-interactive&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Read_002donly-buffer&quot; rel=&quot;previous&quot;&gt;Read-only buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-interactive&quot; rel=&quot;up&quot;&gt;insert-buffer interactive&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;b&lt;/span&gt;&lt;/samp&gt;’ in an Interactive Expression&lt;/h5&gt;
The next argument in the interactive expression starts with a lower
case ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;b&lt;/span&gt;&lt;/samp&gt;’.  (This is different from the code for
&lt;code&gt;append-to-buffer&lt;/code&gt;, which uses an upper-case ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;B&lt;/span&gt;&lt;/samp&gt;’. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#append_002dto_002dbuffer&quot;&gt;The Definition of &lt;code&gt;append-to-buffer&lt;/code&gt;&lt;/a&gt;.) 
The lower-case ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;b&lt;/span&gt;&lt;/samp&gt;’ tells the Lisp interpreter that the argument
for &lt;code&gt;insert-buffer&lt;/code&gt; should be an existing buffer or else its
name.  (The upper-case ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;B&lt;/span&gt;&lt;/samp&gt;’ option provides for the possibility
that the buffer does not exist.)  Emacs will prompt you for the name
of the buffer, offering you a default buffer, with name completion
enabled.  If the buffer does not exist, you receive a message that
says “No match”; your terminal may beep at you as well.

   &lt;br /&gt;
The new and simplified code generates a list for &lt;code&gt;interactive&lt;/code&gt;. 
It uses the &lt;code&gt;barf-if-buffer-read-only&lt;/code&gt; and &lt;code&gt;read-buffer&lt;/code&gt;
functions with which we are already familiar and the &lt;code&gt;progn&lt;/code&gt;
special form with which we are not.  (It will be described later.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;insert-buffer-body&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;insert_002dbuffer-body&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if-_0026-or&quot; rel=&quot;next&quot;&gt;if &amp;amp; or&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-interactive&quot; rel=&quot;previous&quot;&gt;insert-buffer interactive&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot; rel=&quot;up&quot;&gt;insert-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
5.2.2 The Body of the &lt;code&gt;insert-buffer&lt;/code&gt; Function&lt;/h4&gt;
The body of the &lt;code&gt;insert-buffer&lt;/code&gt; function has two major parts: an
&lt;code&gt;or&lt;/code&gt; expression and a &lt;code&gt;let&lt;/code&gt; expression.  The purpose of the
&lt;code&gt;or&lt;/code&gt; expression is to ensure that the argument &lt;code&gt;buffer&lt;/code&gt; is
bound to a buffer and not just the name of a buffer.  The body of the
&lt;code&gt;let&lt;/code&gt; expression contains the code which copies the other buffer
into the current buffer.

   &lt;br /&gt;
In outline, the two expressions fit into the &lt;code&gt;insert-buffer&lt;/code&gt;
function like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun insert-buffer (buffer)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       (interactive &quot;*bInsert buffer: &quot;)
       (or ...
           ...
       (let (&lt;var&gt;varlist&lt;/var&gt;)
           &lt;var&gt;body-of-&lt;/var&gt;&lt;code&gt;let&lt;/code&gt;... )
&lt;/pre&gt;
To understand how the &lt;code&gt;or&lt;/code&gt; expression ensures that the argument
&lt;code&gt;buffer&lt;/code&gt; is bound to a buffer and not to the name of a buffer, it
is first necessary to understand the &lt;code&gt;or&lt;/code&gt; function.

   &lt;br /&gt;
Before doing this, let me rewrite this part of the function using
&lt;code&gt;if&lt;/code&gt; so that you can see what is done in a manner that will be familiar.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;if-&amp;amp;-or&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;if-_0026-or&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Insert-or&quot; rel=&quot;next&quot;&gt;Insert or&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer-body&quot; rel=&quot;previous&quot;&gt;insert-buffer body&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot; rel=&quot;up&quot;&gt;insert-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
5.2.3 &lt;code&gt;insert-buffer&lt;/code&gt; With an &lt;code&gt;if&lt;/code&gt; Instead of an &lt;code&gt;or&lt;/code&gt;&lt;/h4&gt;
The job to be done is to make sure the value of &lt;code&gt;buffer&lt;/code&gt; is a
buffer itself and not the name of a buffer.  If the value is the name,
then the buffer itself must be got.

   &lt;br /&gt;
You can imagine yourself at a conference where an usher is wandering
around holding a list with your name on it and looking for you: the
usher is “bound” to your name, not to you; but when the usher finds
you and takes your arm, the usher becomes “bound” to you.

   &lt;br /&gt;
In Lisp, you might describe this situation like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (not (holding-on-to-guest))
         (find-and-take-arm-of-guest))
&lt;/pre&gt;
We want to do the same thing with a buffer—if we do not have the
buffer itself, we want to get it.

   &lt;br /&gt;
Using a predicate called &lt;code&gt;bufferp&lt;/code&gt; that tells us whether we have a
buffer (rather than its name), we can write the code like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (not (bufferp buffer))              ; &lt;span class=&quot;roman&quot;&gt;if-part&lt;/span&gt;
         (setq buffer (get-buffer buffer)))  ; &lt;span class=&quot;roman&quot;&gt;then-part&lt;/span&gt;
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Here, the true-or-false-test of the &lt;code&gt;if&lt;/code&gt; expression is
&lt;code&gt;(not&amp;nbsp;(bufferp&amp;nbsp;buffer))&lt;/code&gt;; and the then-part is the expression
&lt;code&gt;(setq&amp;nbsp;buffer&amp;nbsp;(get-buffer&amp;nbsp;buffer))&lt;/code&gt;.

   &lt;/div&gt;
In the test, the function &lt;code&gt;bufferp&lt;/code&gt; returns true if its argument is
a buffer—but false if its argument is the name of the buffer.  (The
last character of the function name &lt;code&gt;bufferp&lt;/code&gt; is the character
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’; as we saw earlier, such use of ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’ is a convention that
indicates that the function is a predicate, which is a term that means
that the function will determine whether some property is true or false. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Wrong-Type-of-Argument&quot;&gt;Using the Wrong Type Object as an Argument&lt;/a&gt;.)

   &lt;br /&gt;
The function &lt;code&gt;not&lt;/code&gt; precedes the expression &lt;code&gt;(bufferp buffer)&lt;/code&gt;,
so the true-or-false-test looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (not (bufferp buffer))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
&lt;code&gt;not&lt;/code&gt; is a function that returns true if its argument is false
and false if its argument is true.  So if &lt;code&gt;(bufferp buffer)&lt;/code&gt;
returns true, the &lt;code&gt;not&lt;/code&gt; expression returns false and vice-verse:
what is “not true” is false and what is “not false” is true.

   &lt;/div&gt;
Using this test, the &lt;code&gt;if&lt;/code&gt; expression works as follows: when the
value of the variable &lt;code&gt;buffer&lt;/code&gt; is actually a buffer rather than
its name, the true-or-false-test returns false and the &lt;code&gt;if&lt;/code&gt;
expression does not evaluate the then-part.  This is fine, since we do
not need to do anything to the variable &lt;code&gt;buffer&lt;/code&gt; if it really is
a buffer.

   &lt;br /&gt;
On the other hand, when the value of &lt;code&gt;buffer&lt;/code&gt; is not a buffer
itself, but the name of a buffer, the true-or-false-test returns true
and the then-part of the expression is evaluated.  In this case, the
then-part is &lt;code&gt;(setq buffer (get-buffer buffer))&lt;/code&gt;.  This
expression uses the &lt;code&gt;get-buffer&lt;/code&gt; function to return an actual
buffer itself, given its name.  The &lt;code&gt;setq&lt;/code&gt; then sets the variable
&lt;code&gt;buffer&lt;/code&gt; to the value of the buffer itself, replacing its previous
value (which was the name of the buffer).

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Insert-or&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Insert-let&quot; rel=&quot;next&quot;&gt;Insert let&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#if-_0026-or&quot; rel=&quot;previous&quot;&gt;if &amp;amp; or&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot; rel=&quot;up&quot;&gt;insert-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
5.2.4 The &lt;code&gt;or&lt;/code&gt; in the Body&lt;/h4&gt;
The purpose of the &lt;code&gt;or&lt;/code&gt; expression in the &lt;code&gt;insert-buffer&lt;/code&gt;
function is to ensure that the argument &lt;code&gt;buffer&lt;/code&gt; is bound to a
buffer and not just to the name of a buffer.  The previous section shows
how the job could have been done using an &lt;code&gt;if&lt;/code&gt; expression. 
However, the &lt;code&gt;insert-buffer&lt;/code&gt; function actually uses &lt;code&gt;or&lt;/code&gt;. 
To understand this, it is necessary to understand how &lt;code&gt;or&lt;/code&gt; works.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-or-156&quot;&gt;&lt;/a&gt;An &lt;code&gt;or&lt;/code&gt; function can have any number of arguments.  It evaluates
each argument in turn and returns the value of the first of its
arguments that is not &lt;code&gt;nil&lt;/code&gt;.  Also, and this is a crucial feature
of &lt;code&gt;or&lt;/code&gt;, it does not evaluate any subsequent arguments after
returning the first non-&lt;code&gt;nil&lt;/code&gt; value.

   &lt;br /&gt;
The &lt;code&gt;or&lt;/code&gt; expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (or (bufferp buffer)
         (setq buffer (get-buffer buffer)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The first argument to &lt;code&gt;or&lt;/code&gt; is the expression &lt;code&gt;(bufferp buffer)&lt;/code&gt;. 
This expression returns true (a non-&lt;code&gt;nil&lt;/code&gt; value) if the buffer is
actually a buffer, and not just the name of a buffer.  In the &lt;code&gt;or&lt;/code&gt;
expression, if this is the case, the &lt;code&gt;or&lt;/code&gt; expression returns this
true value and does not evaluate the next expression—and this is fine
with us, since we do not want to do anything to the value of
&lt;code&gt;buffer&lt;/code&gt; if it really is a buffer.

   &lt;/div&gt;
On the other hand, if the value of &lt;code&gt;(bufferp buffer)&lt;/code&gt; is &lt;code&gt;nil&lt;/code&gt;,
which it will be if the value of &lt;code&gt;buffer&lt;/code&gt; is the name of a buffer,
the Lisp interpreter evaluates the next element of the &lt;code&gt;or&lt;/code&gt;
expression.  This is the expression &lt;code&gt;(setq buffer (get-buffer
buffer))&lt;/code&gt;.  This expression returns a non-&lt;code&gt;nil&lt;/code&gt; value, which
is the value to which it sets the variable &lt;code&gt;buffer&lt;/code&gt;—and this
value is a buffer itself, not the name of a buffer.

   &lt;br /&gt;
The result of all this is that the symbol &lt;code&gt;buffer&lt;/code&gt; is always
bound to a buffer itself rather than to the name of a buffer.  All
this is necessary because the &lt;code&gt;set-buffer&lt;/code&gt; function in a
following line only works with a buffer itself, not with the name to a
buffer.

   &lt;br /&gt;
Incidentally, using &lt;code&gt;or&lt;/code&gt;, the situation with the usher would be
written like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (or (holding-on-to-guest) (find-and-take-arm-of-guest))
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Insert-let&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#New-insert_002dbuffer&quot; rel=&quot;next&quot;&gt;New insert-buffer&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Insert-or&quot; rel=&quot;previous&quot;&gt;Insert or&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot; rel=&quot;up&quot;&gt;insert-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
5.2.5 The &lt;code&gt;let&lt;/code&gt; Expression in &lt;code&gt;insert-buffer&lt;/code&gt;&lt;/h4&gt;
After ensuring that the variable &lt;code&gt;buffer&lt;/code&gt; refers to a buffer itself
and not just to the name of a buffer, the &lt;code&gt;insert-buffer function&lt;/code&gt;
continues with a &lt;code&gt;let&lt;/code&gt; expression.  This specifies three local
variables, &lt;code&gt;start&lt;/code&gt;, &lt;code&gt;end&lt;/code&gt;, and &lt;code&gt;newmark&lt;/code&gt; and binds them
to the initial value &lt;code&gt;nil&lt;/code&gt;.  These variables are used inside the
remainder of the &lt;code&gt;let&lt;/code&gt; and temporarily hide any other occurrence of
variables of the same name in Emacs until the end of the &lt;code&gt;let&lt;/code&gt;.

   &lt;br /&gt;
The body of the &lt;code&gt;let&lt;/code&gt; contains two &lt;code&gt;save-excursion&lt;/code&gt;
expressions.  First, we will look at the inner &lt;code&gt;save-excursion&lt;/code&gt;
expression in detail.  The expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (save-excursion
       (set-buffer buffer)
       (setq start (point-min) end (point-max)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The expression &lt;code&gt;(set-buffer buffer)&lt;/code&gt; changes Emacs&#39;s attention
from the current buffer to the one from which the text will copied. 
In that buffer, the variables &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; are set to
the beginning and end of the buffer, using the commands
&lt;code&gt;point-min&lt;/code&gt; and &lt;code&gt;point-max&lt;/code&gt;.  Note that we have here an
illustration of how &lt;code&gt;setq&lt;/code&gt; is able to set two variables in the
same expression.  The first argument of &lt;code&gt;setq&lt;/code&gt; is set to the
value of its second, and its third argument is set to the value of its
fourth.

   &lt;/div&gt;
After the body of the inner &lt;code&gt;save-excursion&lt;/code&gt; is evaluated, the
&lt;code&gt;save-excursion&lt;/code&gt; restores the original buffer, but &lt;code&gt;start&lt;/code&gt; and
&lt;code&gt;end&lt;/code&gt; remain set to the values of the beginning and end of the
buffer from which the text will be copied.

   &lt;br /&gt;
The outer &lt;code&gt;save-excursion&lt;/code&gt; expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (save-excursion
       (&lt;var&gt;inner-&lt;/var&gt;&lt;code&gt;save-excursion&lt;/code&gt;&lt;var&gt;-expression&lt;/var&gt;
          (&lt;var&gt;go-to-new-buffer-and-set-&lt;/var&gt;&lt;code&gt;start&lt;/code&gt;&lt;var&gt;-and-&lt;/var&gt;&lt;code&gt;end&lt;/code&gt;)
       (insert-buffer-substring buffer start end)
       (setq newmark (point)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The &lt;code&gt;insert-buffer-substring&lt;/code&gt; function copies the text
&lt;em&gt;into&lt;/em&gt; the current buffer &lt;em&gt;from&lt;/em&gt; the region indicated by
&lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; in &lt;code&gt;buffer&lt;/code&gt;.  Since the whole of the
second buffer lies between &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt;, the whole of
the second buffer is copied into the buffer you are editing.  Next,
the value of point, which will be at the end of the inserted text, is
recorded in the variable &lt;code&gt;newmark&lt;/code&gt;.

   &lt;/div&gt;
After the body of the outer &lt;code&gt;save-excursion&lt;/code&gt; is evaluated, point
and mark are relocated to their original places.

   &lt;br /&gt;
However, it is convenient to locate a mark at the end of the newly
inserted text and locate point at its beginning.  The &lt;code&gt;newmark&lt;/code&gt;
variable records the end of the inserted text.  In the last line of
the &lt;code&gt;let&lt;/code&gt; expression, the &lt;code&gt;(push-mark newmark)&lt;/code&gt; expression
function sets a mark to this location.  (The previous location of the
mark is still accessible; it is recorded on the mark ring and you can
go back to it with &lt;kbd&gt;C-u C-&amp;lt;SPC&amp;gt;&lt;/kbd&gt;.)  Meanwhile, point is
located at the beginning of the inserted text, which is where it was
before you called the insert function, the position of which was saved
by the first &lt;code&gt;save-excursion&lt;/code&gt;.

   &lt;br /&gt;
The whole &lt;code&gt;let&lt;/code&gt; expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let (start end newmark)
       (save-excursion
         (save-excursion
           (set-buffer buffer)
           (setq start (point-min) end (point-max)))
         (insert-buffer-substring buffer start end)
         (setq newmark (point)))
       (push-mark newmark))
&lt;/pre&gt;
Like the &lt;code&gt;append-to-buffer&lt;/code&gt; function, the &lt;code&gt;insert-buffer&lt;/code&gt;
function uses &lt;code&gt;let&lt;/code&gt;, &lt;code&gt;save-excursion&lt;/code&gt;, and
&lt;code&gt;set-buffer&lt;/code&gt;.  In addition, the function illustrates one way to
use &lt;code&gt;or&lt;/code&gt;.  All these functions are building blocks that we will
find and use again and again.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;New-insert-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;New-insert_002dbuffer&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Insert-let&quot; rel=&quot;previous&quot;&gt;Insert let&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot; rel=&quot;up&quot;&gt;insert-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
5.2.6 New Body for &lt;code&gt;insert-buffer&lt;/code&gt;&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-insert_002dbuffer_002c-new-version-body-157&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-new-version-body-for-insert_002dbuffer-158&quot;&gt;&lt;/a&gt;
The body in the GNU Emacs 22 version is more confusing than the original.

   &lt;br /&gt;
It consists of two expressions,

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;       (push-mark
        (save-excursion
          (insert-buffer-substring (get-buffer buffer))
          (point)))
     
        nil
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
except, and this is what confuses novices, very important work is done
inside the &lt;code&gt;push-mark&lt;/code&gt; expression.

   &lt;/div&gt;
The &lt;code&gt;get-buffer&lt;/code&gt; function returns a buffer with the name
provided.  You will note that the function is &lt;em&gt;not&lt;/em&gt; called
&lt;code&gt;get-buffer-create&lt;/code&gt;; it does not create a buffer if one does not
already exist.  The buffer returned by &lt;code&gt;get-buffer&lt;/code&gt;, an existing
buffer, is passed to &lt;code&gt;insert-buffer-substring&lt;/code&gt;, which inserts the
whole of the buffer (since you did not specify anything else).

   &lt;br /&gt;
The location into which the buffer is inserted is recorded by
&lt;code&gt;push-mark&lt;/code&gt;.  Then the function returns &lt;code&gt;nil&lt;/code&gt;, the value of
its last command.  Put another way, the &lt;code&gt;insert-buffer&lt;/code&gt; function
exists only to produce a side effect, inserting another buffer, not to
return any value.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;beginning-of-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;beginning_002dof_002dbuffer&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Second-Buffer-Related-Review&quot; rel=&quot;next&quot;&gt;Second Buffer Related Review&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#insert_002dbuffer&quot; rel=&quot;previous&quot;&gt;insert-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#More-Complex&quot; rel=&quot;up&quot;&gt;More Complex&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
5.3 Complete Definition of &lt;code&gt;beginning-of-buffer&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-beginning_002dof_002dbuffer-159&quot;&gt;&lt;/a&gt;
The basic structure of the &lt;code&gt;beginning-of-buffer&lt;/code&gt; function has
already been discussed.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#simplified_002dbeginning_002dof_002dbuffer&quot;&gt;A Simplified &lt;code&gt;beginning-of-buffer&lt;/code&gt; Definition&lt;/a&gt;.) 
This section describes the complex part of the definition.

   &lt;br /&gt;
As previously described, when invoked without an argument,
&lt;code&gt;beginning-of-buffer&lt;/code&gt; moves the cursor to the beginning of the
buffer (in truth, the beginning of the accessible portion of the
buffer), leaving the mark at the previous position.  However, when the
command is invoked with a number between one and ten, the function
considers that number to be a fraction of the length of the buffer,
measured in tenths, and Emacs moves the cursor that fraction of the
way from the beginning of the buffer.  Thus, you can either call this
function with the key command &lt;kbd&gt;M-&amp;lt;&lt;/kbd&gt;, which will move the cursor to
the beginning of the buffer, or with a key command such as &lt;kbd&gt;C-u 7
M-&amp;lt;&lt;/kbd&gt; which will move the cursor to a point 70% of the way through the
buffer.  If a number bigger than ten is used for the argument, it
moves to the end of the buffer.

   &lt;br /&gt;
The &lt;code&gt;beginning-of-buffer&lt;/code&gt; function can be called with or without an
argument.  The use of the argument is optional.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Optional-Arguments&quot;&gt;Optional Arguments&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-opt-arg&quot;&gt;beginning-of-buffer opt arg&lt;/a&gt;:   Example with optional argument. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-complete&quot;&gt;beginning-of-buffer complete&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Optional-Arguments&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-opt-arg&quot; rel=&quot;next&quot;&gt;beginning-of-buffer opt arg&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer&quot; rel=&quot;up&quot;&gt;beginning-of-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
5.3.1 Optional Arguments&lt;/h4&gt;
Unless told otherwise, Lisp expects that a function with an argument in
its function definition will be called with a value for that argument. 
If that does not happen, you get an error and a message that says
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Wrong number of arguments&lt;/span&gt;&lt;/samp&gt;’.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Optional-arguments-160&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Keyword-161&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-optional-162&quot;&gt;&lt;/a&gt;However, optional arguments are a feature of Lisp: a particular
&lt;dfn&gt;keyword&lt;/dfn&gt; is used to tell the Lisp interpreter that an argument is
optional.  The keyword is &lt;code&gt;&amp;amp;optional&lt;/code&gt;.  (The ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;&amp;amp;&lt;/span&gt;&lt;/samp&gt;’ in front of
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;optional&lt;/span&gt;&lt;/samp&gt;’ is part of the keyword.)  In a function definition, if
an argument follows the keyword &lt;code&gt;&amp;amp;optional&lt;/code&gt;, no value need be
passed to that argument when the function is called.

   &lt;br /&gt;
The first line of the function definition of &lt;code&gt;beginning-of-buffer&lt;/code&gt;
therefore looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun beginning-of-buffer (&amp;amp;optional arg)
&lt;/pre&gt;
In outline, the whole function looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun beginning-of-buffer (&amp;amp;optional arg)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       (interactive &quot;P&quot;)
       (or (&lt;var&gt;is-the-argument-a-cons-cell&lt;/var&gt; arg)
           (and &lt;var&gt;are-both-transient-mark-mode-and-mark-active-true&lt;/var&gt;)
           (push-mark))
       (let (&lt;var&gt;determine-size-and-set-it&lt;/var&gt;)
       (goto-char
         (&lt;var&gt;if-there-is-an-argument&lt;/var&gt;
             &lt;var&gt;figure-out-where-to-go&lt;/var&gt;
           &lt;var&gt;else-go-to&lt;/var&gt;
           (point-min))))
        &lt;var&gt;do-nicety&lt;/var&gt;
&lt;/pre&gt;
The function is similar to the &lt;code&gt;simplified-beginning-of-buffer&lt;/code&gt;
function except that the &lt;code&gt;interactive&lt;/code&gt; expression has &lt;code&gt;&quot;P&quot;&lt;/code&gt;
as an argument and the &lt;code&gt;goto-char&lt;/code&gt; function is followed by an
if-then-else expression that figures out where to put the cursor if
there is an argument that is not a cons cell.

   &lt;br /&gt;
(Since I do not explain a cons cell for many more chapters, please
consider ignoring the function &lt;code&gt;consp&lt;/code&gt;.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Implementation&quot;&gt;How Lists are Implemented&lt;/a&gt;, and &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Cons-Cell-Type&quot;&gt;Cons Cell and List Types&lt;/a&gt;.)

   &lt;br /&gt;
The &lt;code&gt;&quot;P&quot;&lt;/code&gt; in the &lt;code&gt;interactive&lt;/code&gt; expression tells Emacs to
pass a prefix argument, if there is one, to the function in raw form. 
A prefix argument is made by typing the &amp;lt;META&amp;gt; key followed by a
number, or by typing &lt;kbd&gt;C-u&lt;/kbd&gt; and then a number.  (If you don&#39;t type
a number, &lt;kbd&gt;C-u&lt;/kbd&gt; defaults to a cons cell with a 4.  A lowercase
&lt;code&gt;&quot;p&quot;&lt;/code&gt; in the &lt;code&gt;interactive&lt;/code&gt; expression causes the function to
convert a prefix arg to a number.)

   &lt;br /&gt;
The true-or-false-test of the &lt;code&gt;if&lt;/code&gt; expression looks complex, but
it is not: it checks whether &lt;code&gt;arg&lt;/code&gt; has a value that is not
&lt;code&gt;nil&lt;/code&gt; and whether it is a cons cell.  (That is what &lt;code&gt;consp&lt;/code&gt;
does; it checks whether its argument is a cons cell.)  If &lt;code&gt;arg&lt;/code&gt;
has a value that is not &lt;code&gt;nil&lt;/code&gt; (and is not a cons cell), which
will be the case if &lt;code&gt;beginning-of-buffer&lt;/code&gt; is called with a
numeric argument, then this true-or-false-test will return true and
the then-part of the &lt;code&gt;if&lt;/code&gt; expression will be evaluated.  On the
other hand, if &lt;code&gt;beginning-of-buffer&lt;/code&gt; is not called with an
argument, the value of &lt;code&gt;arg&lt;/code&gt; will be &lt;code&gt;nil&lt;/code&gt; and the else-part
of the &lt;code&gt;if&lt;/code&gt; expression will be evaluated.  The else-part is
simply &lt;code&gt;point-min&lt;/code&gt;, and when this is the outcome, the whole
&lt;code&gt;goto-char&lt;/code&gt; expression is &lt;code&gt;(goto-char (point-min))&lt;/code&gt;, which
is how we saw the &lt;code&gt;beginning-of-buffer&lt;/code&gt; function in its
simplified form.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;beginning-of-buffer-opt-arg&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;beginning_002dof_002dbuffer-opt-arg&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-complete&quot; rel=&quot;next&quot;&gt;beginning-of-buffer complete&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Optional-Arguments&quot; rel=&quot;previous&quot;&gt;Optional Arguments&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer&quot; rel=&quot;up&quot;&gt;beginning-of-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
5.3.2 &lt;code&gt;beginning-of-buffer&lt;/code&gt; with an Argument&lt;/h4&gt;
When &lt;code&gt;beginning-of-buffer&lt;/code&gt; is called with an argument, an
expression is evaluated which calculates what value to pass to
&lt;code&gt;goto-char&lt;/code&gt;.  This expression is rather complicated at first sight. 
It includes an inner &lt;code&gt;if&lt;/code&gt; expression and much arithmetic.  It looks
like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (&amp;gt; (buffer-size) 10000)
         ;; &lt;span class=&quot;roman&quot;&gt;Avoid overflow for large buffer sizes!&lt;/span&gt;
                               (* (prefix-numeric-value arg)
                                  (/ size 10))
       (/
        (+ 10
           (*
            size (prefix-numeric-value arg))) 10)))
&lt;/pre&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Disentangle-beginning_002dof_002dbuffer&quot;&gt;Disentangle beginning-of-buffer&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Large-buffer-case&quot;&gt;Large buffer case&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Small-buffer-case&quot;&gt;Small buffer case&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Disentangle-beginning-of-buffer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Disentangle-beginning_002dof_002dbuffer&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Large-buffer-case&quot; rel=&quot;next&quot;&gt;Large buffer case&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-opt-arg&quot; rel=&quot;up&quot;&gt;beginning-of-buffer opt arg&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
Disentangle &lt;code&gt;beginning-of-buffer&lt;/code&gt;&lt;/h5&gt;
Like other complex-looking expressions, the conditional expression
within &lt;code&gt;beginning-of-buffer&lt;/code&gt; can be disentangled by looking at it
as parts of a template, in this case, the template for an if-then-else
expression.  In skeletal form, the expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (&lt;var&gt;buffer-is-large&lt;/var&gt;
         &lt;var&gt;divide-buffer-size-by-10-and-multiply-by-arg&lt;/var&gt;
       &lt;var&gt;else-use-alternate-calculation&lt;/var&gt;
&lt;/pre&gt;
The true-or-false-test of this inner &lt;code&gt;if&lt;/code&gt; expression checks the
size of the buffer.  The reason for this is that the old version 18
Emacs used numbers that are no bigger than eight million or so and in
the computation that followed, the programmer feared that Emacs might
try to use over-large numbers if the buffer were large.  The term
`overflow&#39;, mentioned in the comment, means numbers that are over
large.  More recent versions of Emacs use larger numbers, but this
code has not been touched, if only because people now look at buffers
that are far, far larger than ever before.

   &lt;br /&gt;
There are two cases:  if the buffer is large and if it is not.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Large-buffer-case&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Small-buffer-case&quot; rel=&quot;next&quot;&gt;Small buffer case&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Disentangle-beginning_002dof_002dbuffer&quot; rel=&quot;previous&quot;&gt;Disentangle beginning-of-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-opt-arg&quot; rel=&quot;up&quot;&gt;beginning-of-buffer opt arg&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
What happens in a large buffer&lt;/h5&gt;
In &lt;code&gt;beginning-of-buffer&lt;/code&gt;, the inner &lt;code&gt;if&lt;/code&gt; expression tests
whether the size of the buffer is greater than 10,000 characters.  To do
this, it uses the &lt;code&gt;&amp;gt;&lt;/code&gt; function and the computation of &lt;code&gt;size&lt;/code&gt;
that comes from the let expression.

   &lt;br /&gt;
In the old days, the function &lt;code&gt;buffer-size&lt;/code&gt; was used.  Not only
was that function called several times, it gave the size of the whole
buffer, not the accessible part.  The computation makes much more
sense when it handles just the accessible part.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot;&gt;Narrowing and Widening&lt;/a&gt;, for more information on focusing
attention to an `accessible&#39; part.)

   &lt;br /&gt;
The line looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (&amp;gt; size 10000)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When the buffer is large, the then-part of the &lt;code&gt;if&lt;/code&gt; expression is
evaluated.  It reads like this (after formatting for easy reading):

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (*
       (prefix-numeric-value arg)
       (/ size 10))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
This expression is a multiplication, with two arguments to the function
&lt;code&gt;*&lt;/code&gt;.

   &lt;/div&gt;
The first argument is &lt;code&gt;(prefix-numeric-value arg)&lt;/code&gt;.  When
&lt;code&gt;&quot;P&quot;&lt;/code&gt; is used as the argument for &lt;code&gt;interactive&lt;/code&gt;, the value
passed to the function as its argument is passed a “raw prefix
argument”, and not a number.  (It is a number in a list.)  To perform
the arithmetic, a conversion is necessary, and
&lt;code&gt;prefix-numeric-value&lt;/code&gt; does the job.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_002f-_0040r_007b_0028division_0029_007d-163&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Division-164&quot;&gt;&lt;/a&gt;The second argument is &lt;code&gt;(/ size 10)&lt;/code&gt;.  This expression divides
the numeric value by ten—the numeric value of the size of the
accessible portion of the buffer.  This produces a number that tells
how many characters make up one tenth of the buffer size.  (In Lisp,
&lt;code&gt;/&lt;/code&gt; is used for division, just as &lt;code&gt;*&lt;/code&gt; is used for
multiplication.)

   &lt;br /&gt;
In the multiplication expression as a whole, this amount is multiplied
by the value of the prefix argument—the multiplication looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (* &lt;var&gt;numeric-value-of-prefix-arg&lt;/var&gt;
        &lt;var&gt;number-of-characters-in-one-tenth-of-the-accessible-buffer&lt;/var&gt;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If, for example, the prefix argument is ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;7&lt;/span&gt;&lt;/samp&gt;’, the one-tenth value
will be multiplied by 7 to give a position 70% of the way through.

   &lt;/div&gt;
The result of all this is that if the accessible portion of the buffer
is large, the &lt;code&gt;goto-char&lt;/code&gt; expression reads like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (goto-char (* (prefix-numeric-value arg)
                   (/ size 10)))
&lt;/pre&gt;
This puts the cursor where we want it.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Small-buffer-case&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Large-buffer-case&quot; rel=&quot;previous&quot;&gt;Large buffer case&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-opt-arg&quot; rel=&quot;up&quot;&gt;beginning-of-buffer opt arg&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
What happens in a small buffer&lt;/h5&gt;
If the buffer contains fewer than 10,000 characters, a slightly
different computation is performed.  You might think this is not
necessary, since the first computation could do the job.  However, in
a small buffer, the first method may not put the cursor on exactly the
desired line; the second method does a better job.

   &lt;br /&gt;
The code looks like this:


&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (/ (+ 10 (* size (prefix-numeric-value arg))) 10))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
This is code in which you figure out what happens by discovering how the
functions are embedded in parentheses.  It is easier to read if you
reformat it with each expression indented more deeply than its
enclosing expression:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;       (/
        (+ 10
           (*
            size
            (prefix-numeric-value arg)))
        10))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Looking at parentheses, we see that the innermost operation is
&lt;code&gt;(prefix-numeric-value arg)&lt;/code&gt;, which converts the raw argument to
a number.  In the following expression, this number is multiplied by
the size of the accessible portion of the buffer:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (* size (prefix-numeric-value arg))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
This multiplication creates a number that may be larger than the size of
the buffer—seven times larger if the argument is 7, for example.  Ten
is then added to this number and finally the large number is divided by
ten to provide a value that is one character larger than the percentage
position in the buffer.

   &lt;/div&gt;
The number that results from all this is passed to &lt;code&gt;goto-char&lt;/code&gt; and
the cursor is moved to that point.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;beginning-of-buffer-complete&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;beginning_002dof_002dbuffer-complete&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer-opt-arg&quot; rel=&quot;previous&quot;&gt;beginning-of-buffer opt arg&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer&quot; rel=&quot;up&quot;&gt;beginning-of-buffer&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
5.3.3 The Complete &lt;code&gt;beginning-of-buffer&lt;/code&gt;&lt;/h4&gt;
Here is the complete text of the &lt;code&gt;beginning-of-buffer&lt;/code&gt; function:
   &lt;br /&gt;



&lt;pre class=&quot;smallexample&quot;&gt;     (defun beginning-of-buffer (&amp;amp;optional arg)
       &quot;Move point to the beginning of the buffer;
     leave mark at previous position.
     With \\[universal-argument] prefix,
     do not set mark at previous position.
     With numeric arg N,
     put point N/10 of the way from the beginning.
     
     If the buffer is narrowed,
     this command uses the beginning and size
     of the accessible part of the buffer.
     
     Don&#39;t use this command in Lisp programs!
     \(goto-char (point-min)) is faster
     and avoids clobbering the mark.&quot;
       (interactive &quot;P&quot;)
       (or (consp arg)
           (and transient-mark-mode mark-active)
           (push-mark))
       (let ((size (- (point-max) (point-min))))
         (goto-char (if (and arg (not (consp arg)))
                        (+ (point-min)
                           (if (&amp;gt; size 10000)
                               ;; Avoid overflow for large buffer sizes!
                               (* (prefix-numeric-value arg)
                                  (/ size 10))
                             (/ (+ 10 (* size (prefix-numeric-value arg)))
                                10)))
                      (point-min))))
       (if arg (forward-line 1)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Except for two small points, the previous discussion shows how this
function works.  The first point deals with a detail in the
documentation string, and the second point concerns the last line of
the function.

   &lt;/div&gt;
In the documentation string, there is reference to an expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     \\[universal-argument]
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
A ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;\\&lt;/span&gt;&lt;/samp&gt;’ is used before the first square bracket of this
expression.  This ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;\\&lt;/span&gt;&lt;/samp&gt;’ tells the Lisp interpreter to substitute
whatever key is currently bound to the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;[...]&lt;/span&gt;&lt;/samp&gt;’.  In the case
of &lt;code&gt;universal-argument&lt;/code&gt;, that is usually &lt;kbd&gt;C-u&lt;/kbd&gt;, but it might
be different.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Documentation-Tips&quot;&gt;Tips for Documentation Strings&lt;/a&gt;, for more
information.)

   &lt;/div&gt;
Finally, the last line of the &lt;code&gt;beginning-of-buffer&lt;/code&gt; command says
to move point to the beginning of the next line if the command is
invoked with an argument:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if arg (forward-line 1)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
This puts the cursor at the beginning of the first line after the
appropriate tenths position in the buffer.  This is a flourish that
means that the cursor is always located &lt;em&gt;at least&lt;/em&gt; the requested
tenths of the way through the buffer, which is a nicety that is,
perhaps, not necessary, but which, if it did not occur, would be sure
to draw complaints.

   &lt;/div&gt;
On the other hand, it also means that if you specify the command with
a &lt;kbd&gt;C-u&lt;/kbd&gt;, but without a number, that is to say, if the `raw prefix
argument&#39; is simply a cons cell, then the command puts you at the
beginning of the second line &lt;small class=&quot;dots&quot;&gt;...&lt;/small&gt;  I don&#39;t know whether this is
intended or whether no one has dealt with the code to avoid this
happening.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Second-Buffer-Related-Review&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#optional-Exercise&quot; rel=&quot;next&quot;&gt;optional Exercise&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#beginning_002dof_002dbuffer&quot; rel=&quot;previous&quot;&gt;beginning-of-buffer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#More-Complex&quot; rel=&quot;up&quot;&gt;More Complex&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
5.4 Review&lt;/h3&gt;
Here is a brief summary of some of the topics covered in this chapter.

     &lt;br /&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;or&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Evaluate each argument in sequence, and return the value of the first
argument that is not &lt;code&gt;nil&lt;/code&gt;; if none return a value that is not
&lt;code&gt;nil&lt;/code&gt;, return &lt;code&gt;nil&lt;/code&gt;.  In brief, return the first true value
of the arguments; return a true value if one &lt;em&gt;or&lt;/em&gt; any of the
others are true.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;and&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Evaluate each argument in sequence, and if any are &lt;code&gt;nil&lt;/code&gt;, return
&lt;code&gt;nil&lt;/code&gt;; if none are &lt;code&gt;nil&lt;/code&gt;, return the value of the last
argument.  In brief, return a true value only if all the arguments are
true; return a true value if one &lt;em&gt;and&lt;/em&gt; each of the others is
true.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;&amp;amp;optional&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;A keyword used to indicate that an argument to a function definition
is optional; this means that the function can be evaluated without the
argument, if desired.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;prefix-numeric-value&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Convert the `raw prefix argument&#39; produced by &lt;code&gt;(interactive
&quot;P&quot;)&lt;/code&gt; to a numeric value.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;forward-line&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Move point forward to the beginning of the next line, or if the argument
is greater than one, forward that many lines.  If it can&#39;t move as far
forward as it is supposed to, &lt;code&gt;forward-line&lt;/code&gt; goes forward as far as
it can and then returns a count of the number of additional lines it was
supposed to move but couldn&#39;t.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;erase-buffer&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Delete the entire contents of the current buffer.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;bufferp&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Return &lt;code&gt;t&lt;/code&gt; if its argument is a buffer; otherwise return &lt;code&gt;nil&lt;/code&gt;. 
&lt;/dd&gt;&lt;/dl&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;optional-Exercise&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Second-Buffer-Related-Review&quot; rel=&quot;previous&quot;&gt;Second Buffer Related Review&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#More-Complex&quot; rel=&quot;up&quot;&gt;More Complex&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
5.5 &lt;code&gt;optional&lt;/code&gt; Argument Exercise&lt;/h3&gt;
Write an interactive function with an optional argument that tests
whether its argument, a number, is greater than or equal to, or else,
less than the value of &lt;code&gt;fill-column&lt;/code&gt;, and tells you which, in a
message.  However, if you do not pass an argument to the function, use
56 as a default value.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Narrowing-&amp;amp;-Widening&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Narrowing-_0026-Widening&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;next&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#More-Complex&quot; rel=&quot;previous&quot;&gt;More Complex&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
6 Narrowing and Widening&lt;/h2&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Focusing-attention-_0028narrowing_0029-165&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Narrowing-166&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Widening-167&quot;&gt;&lt;/a&gt;
Narrowing is a feature of Emacs that makes it possible for you to focus
on a specific part of a buffer, and work without accidentally changing
other parts.  Narrowing is normally disabled since it can confuse
novices.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-advantages&quot;&gt;Narrowing advantages&lt;/a&gt;:         The advantages of narrowing
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002drestriction&quot;&gt;save-restriction&lt;/a&gt;:             The &lt;code&gt;save-restriction&lt;/code&gt; special form. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#what_002dline&quot;&gt;what-line&lt;/a&gt;:                    The number of the line that point is on. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#narrow-Exercise&quot;&gt;narrow Exercise&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Narrowing-advantages&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002drestriction&quot; rel=&quot;next&quot;&gt;save-restriction&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot; rel=&quot;up&quot;&gt;Narrowing &amp;amp; Widening&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
The Advantages of Narrowing&lt;/h3&gt;
With narrowing, the rest of a buffer is made invisible, as if it weren&#39;t
there.  This is an advantage if, for example, you want to replace a word
in one part of a buffer but not in another: you narrow to the part you want
and the replacement is carried out only in that section, not in the rest
of the buffer.  Searches will only work within a narrowed region, not
outside of one, so if you are fixing a part of a document, you can keep
yourself from accidentally finding parts you do not need to fix by
narrowing just to the region you want. 
(The key binding for &lt;code&gt;narrow-to-region&lt;/code&gt; is &lt;kbd&gt;C-x n n&lt;/kbd&gt;.)

   &lt;br /&gt;
However, narrowing does make the rest of the buffer invisible, which
can scare people who inadvertently invoke narrowing and think they
have deleted a part of their file.  Moreover, the &lt;code&gt;undo&lt;/code&gt; command
(which is usually bound to &lt;kbd&gt;C-x u&lt;/kbd&gt;) does not turn off narrowing
(nor should it), so people can become quite desperate if they do not
know that they can return the rest of a buffer to visibility with the
&lt;code&gt;widen&lt;/code&gt; command. 
(The key binding for &lt;code&gt;widen&lt;/code&gt; is &lt;kbd&gt;C-x n w&lt;/kbd&gt;.)

   &lt;br /&gt;
Narrowing is just as useful to the Lisp interpreter as to a human. 
Often, an Emacs Lisp function is designed to work on just part of a
buffer; or conversely, an Emacs Lisp function needs to work on all of a
buffer that has been narrowed.  The &lt;code&gt;what-line&lt;/code&gt; function, for
example, removes the narrowing from a buffer, if it has any narrowing
and when it has finished its job, restores the narrowing to what it was. 
On the other hand, the &lt;code&gt;count-lines&lt;/code&gt; function
uses narrowing to restrict itself to just that portion
of the buffer in which it is interested and then restores the previous
situation.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;save-restriction&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;save_002drestriction&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#what_002dline&quot; rel=&quot;next&quot;&gt;what-line&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-advantages&quot; rel=&quot;previous&quot;&gt;Narrowing advantages&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot; rel=&quot;up&quot;&gt;Narrowing &amp;amp; Widening&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
6.1 The &lt;code&gt;save-restriction&lt;/code&gt; Special Form&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-save_002drestriction-168&quot;&gt;&lt;/a&gt;
In Emacs Lisp, you can use the &lt;code&gt;save-restriction&lt;/code&gt; special form to
keep track of whatever narrowing is in effect, if any.  When the Lisp
interpreter meets with &lt;code&gt;save-restriction&lt;/code&gt;, it executes the code
in the body of the &lt;code&gt;save-restriction&lt;/code&gt; expression, and then undoes
any changes to narrowing that the code caused.  If, for example, the
buffer is narrowed and the code that follows &lt;code&gt;save-restriction&lt;/code&gt;
gets rid of the narrowing, &lt;code&gt;save-restriction&lt;/code&gt; returns the buffer
to its narrowed region afterwards.  In the &lt;code&gt;what-line&lt;/code&gt; command,
any narrowing the buffer may have is undone by the &lt;code&gt;widen&lt;/code&gt;
command that immediately follows the &lt;code&gt;save-restriction&lt;/code&gt; command. 
Any original narrowing is restored just before the completion of the
function.

   &lt;br /&gt;
The template for a &lt;code&gt;save-restriction&lt;/code&gt; expression is simple:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (save-restriction
       &lt;var&gt;body&lt;/var&gt;... )
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The body of the &lt;code&gt;save-restriction&lt;/code&gt; is one or more expressions that
will be evaluated in sequence by the Lisp interpreter.

   &lt;/div&gt;
Finally, a point to note: when you use both &lt;code&gt;save-excursion&lt;/code&gt; and
&lt;code&gt;save-restriction&lt;/code&gt;, one right after the other, you should use
&lt;code&gt;save-excursion&lt;/code&gt; outermost.  If you write them in reverse order,
you may fail to record narrowing in the buffer to which Emacs switches
after calling &lt;code&gt;save-excursion&lt;/code&gt;.  Thus, when written together,
&lt;code&gt;save-excursion&lt;/code&gt; and &lt;code&gt;save-restriction&lt;/code&gt; should be written
like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (save-excursion
       (save-restriction
         &lt;var&gt;body&lt;/var&gt;...))
&lt;/pre&gt;
In other circumstances, when not written together, the
&lt;code&gt;save-excursion&lt;/code&gt; and &lt;code&gt;save-restriction&lt;/code&gt; special forms must
be written in the order appropriate to the function.

   &lt;br /&gt;
For example,

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;       (save-restriction
         (widen)
         (save-excursion
         &lt;var&gt;body&lt;/var&gt;...))
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;what-line&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;what_002dline&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#narrow-Exercise&quot; rel=&quot;next&quot;&gt;narrow Exercise&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#save_002drestriction&quot; rel=&quot;previous&quot;&gt;save-restriction&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot; rel=&quot;up&quot;&gt;Narrowing &amp;amp; Widening&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
6.2 &lt;code&gt;what-line&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-what_002dline-169&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Widening_002c-example-of-170&quot;&gt;&lt;/a&gt;
The &lt;code&gt;what-line&lt;/code&gt; command tells you the number of the line in which
the cursor is located.  The function illustrates the use of the
&lt;code&gt;save-restriction&lt;/code&gt; and &lt;code&gt;save-excursion&lt;/code&gt; commands.  Here is the
original text of the function:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun what-line ()
       &quot;Print the current line number (in the buffer) of point.&quot;
       (interactive)
       (save-restriction
         (widen)
         (save-excursion
           (beginning-of-line)
           (message &quot;Line %d&quot;
                    (1+ (count-lines 1 (point)))))))
&lt;/pre&gt;
(In recent versions of GNU Emacs, the &lt;code&gt;what-line&lt;/code&gt; function has
been expanded to tell you your line number in a narrowed buffer as
well as your line number in a widened buffer.  The recent version is
more complex than the version shown here.  If you feel adventurous,
you might want to look at it after figuring out how this version
works.  You will probably need to use &lt;kbd&gt;C-h f&lt;/kbd&gt;
(&lt;code&gt;describe-function&lt;/code&gt;).  The newer version uses a conditional to
determine whether the buffer has been narrowed.

   &lt;br /&gt;
(Also, it uses &lt;code&gt;line-number-at-pos&lt;/code&gt;, which among other simple
expressions, such as &lt;code&gt;(goto-char (point-min))&lt;/code&gt;, moves point to
the beginning of the current line with &lt;code&gt;(forward-line 0)&lt;/code&gt; rather
than &lt;code&gt;beginning-of-line&lt;/code&gt;.)

   &lt;br /&gt;
The &lt;code&gt;what-line&lt;/code&gt; function as shown here has a documentation line
and is interactive, as you would expect.  The next two lines use the
functions &lt;code&gt;save-restriction&lt;/code&gt; and &lt;code&gt;widen&lt;/code&gt;.

   &lt;br /&gt;
The &lt;code&gt;save-restriction&lt;/code&gt; special form notes whatever narrowing is in
effect, if any, in the current buffer and restores that narrowing after
the code in the body of the &lt;code&gt;save-restriction&lt;/code&gt; has been evaluated.

   &lt;br /&gt;
The &lt;code&gt;save-restriction&lt;/code&gt; special form is followed by &lt;code&gt;widen&lt;/code&gt;. 
This function undoes any narrowing the current buffer may have had
when &lt;code&gt;what-line&lt;/code&gt; was called.  (The narrowing that was there is
the narrowing that &lt;code&gt;save-restriction&lt;/code&gt; remembers.)  This widening
makes it possible for the line counting commands to count from the
beginning of the buffer.  Otherwise, they would have been limited to
counting within the accessible region.  Any original narrowing is
restored just before the completion of the function by the
&lt;code&gt;save-restriction&lt;/code&gt; special form.

   &lt;br /&gt;
The call to &lt;code&gt;widen&lt;/code&gt; is followed by &lt;code&gt;save-excursion&lt;/code&gt;, which
saves the location of the cursor (i.e., of point) and of the mark, and
restores them after the code in the body of the &lt;code&gt;save-excursion&lt;/code&gt;
uses the &lt;code&gt;beginning-of-line&lt;/code&gt; function to move point.

   &lt;br /&gt;
(Note that the &lt;code&gt;(widen)&lt;/code&gt; expression comes between the
&lt;code&gt;save-restriction&lt;/code&gt; and &lt;code&gt;save-excursion&lt;/code&gt; special forms.  When
you write the two &lt;code&gt;save- ...&lt;/code&gt; expressions in sequence, write
&lt;code&gt;save-excursion&lt;/code&gt; outermost.)

   &lt;br /&gt;
The last two lines of the &lt;code&gt;what-line&lt;/code&gt; function are functions to
count the number of lines in the buffer and then print the number in the
echo area.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (message &quot;Line %d&quot;
              (1+ (count-lines 1 (point)))))))
&lt;/pre&gt;
The &lt;code&gt;message&lt;/code&gt; function prints a one-line message at the bottom of
the Emacs screen.  The first argument is inside of quotation marks and
is printed as a string of characters.  However, it may contain a
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’ expression to print a following argument.  ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’ prints
the argument as a decimal, so the message will say something such as
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Line 243&lt;/span&gt;&lt;/samp&gt;’.

   &lt;br /&gt;
The number that is printed in place of the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;%d&lt;/span&gt;&lt;/samp&gt;’ is computed by the
last line of the function:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (1+ (count-lines 1 (point)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
What this does is count the lines from the first position of the
buffer, indicated by the &lt;code&gt;1&lt;/code&gt;, up to &lt;code&gt;(point)&lt;/code&gt;, and then add
one to that number.  (The &lt;code&gt;1+&lt;/code&gt; function adds one to its
argument.)  We add one to it because line 2 has only one line before
it, and &lt;code&gt;count-lines&lt;/code&gt; counts only the lines &lt;em&gt;before&lt;/em&gt; the
current line.

   &lt;/div&gt;
After &lt;code&gt;count-lines&lt;/code&gt; has done its job, and the message has been
printed in the echo area, the &lt;code&gt;save-excursion&lt;/code&gt; restores point and
mark to their original positions; and &lt;code&gt;save-restriction&lt;/code&gt; restores
the original narrowing, if any.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;narrow-Exercise&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#what_002dline&quot; rel=&quot;previous&quot;&gt;what-line&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot; rel=&quot;up&quot;&gt;Narrowing &amp;amp; Widening&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
6.3 Exercise with Narrowing&lt;/h3&gt;
Write a function that will display the first 60 characters of the
current buffer, even if you have narrowed the buffer to its latter
half so that the first line is inaccessible.  Restore point, mark, and
narrowing.  For this exercise, you need to use a whole potpourri of
functions, including &lt;code&gt;save-restriction&lt;/code&gt;, &lt;code&gt;widen&lt;/code&gt;,
&lt;code&gt;goto-char&lt;/code&gt;, &lt;code&gt;point-min&lt;/code&gt;, &lt;code&gt;message&lt;/code&gt;, and
&lt;code&gt;buffer-substring&lt;/code&gt;.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Properties_002c-mention-of-_0040code_007bbuffer_002dsubstring_002dno_002dproperties_007d-171&quot;&gt;&lt;/a&gt;(&lt;code&gt;buffer-substring&lt;/code&gt; is a previously unmentioned function you will
have to investigate yourself; or perhaps you will have to use
&lt;code&gt;buffer-substring-no-properties&lt;/code&gt; or
&lt;code&gt;filter-buffer-substring&lt;/code&gt; &lt;small class=&quot;dots&quot;&gt;...&lt;/small&gt;, yet other functions.  Text
properties are a feature otherwise not discussed here.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Text-Properties&quot;&gt;Text Properties&lt;/a&gt;.)

   &lt;br /&gt;
Additionally, do you really need &lt;code&gt;goto-char&lt;/code&gt; or &lt;code&gt;point-min&lt;/code&gt;? 
Or can you write the function without them?

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;car-cdr-&amp;amp;-cons&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;car-cdr-_0026-cons&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;next&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Narrowing-_0026-Widening&quot; rel=&quot;previous&quot;&gt;Narrowing &amp;amp; Widening&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
7 &lt;code&gt;car&lt;/code&gt;, &lt;code&gt;cdr&lt;/code&gt;, &lt;code&gt;cons&lt;/code&gt;: Fundamental Functions&lt;/h2&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-car_002c-_0040r_007bintroduced_007d-172&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-cdr_002c-_0040r_007bintroduced_007d-173&quot;&gt;&lt;/a&gt;
In Lisp, &lt;code&gt;car&lt;/code&gt;, &lt;code&gt;cdr&lt;/code&gt;, and &lt;code&gt;cons&lt;/code&gt; are fundamental
functions.  The &lt;code&gt;cons&lt;/code&gt; function is used to construct lists, and
the &lt;code&gt;car&lt;/code&gt; and &lt;code&gt;cdr&lt;/code&gt; functions are used to take them apart.

   &lt;br /&gt;
In the walk through of the &lt;code&gt;copy-region-as-kill&lt;/code&gt; function, we
will see &lt;code&gt;cons&lt;/code&gt; as well as two variants on &lt;code&gt;cdr&lt;/code&gt;,
namely, &lt;code&gt;setcdr&lt;/code&gt; and &lt;code&gt;nthcdr&lt;/code&gt;.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill&quot;&gt;copy-region-as-kill&lt;/a&gt;.)

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Strange-Names&quot;&gt;Strange Names&lt;/a&gt;:                An historical aside: why the strange names? 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-_0026-cdr&quot;&gt;car &amp;amp; cdr&lt;/a&gt;:                    Functions for extracting part of a list. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons&quot;&gt;cons&lt;/a&gt;:                         Constructing a list. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nthcdr&quot;&gt;nthcdr&lt;/a&gt;:                       Calling &lt;code&gt;cdr&lt;/code&gt; repeatedly. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nth&quot;&gt;nth&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcar&quot;&gt;setcar&lt;/a&gt;:                       Changing the first element of a list. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;7&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcdr&quot;&gt;setcdr&lt;/a&gt;:                       Changing the rest of a list. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;8&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons-Exercise&quot;&gt;cons Exercise&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Strange-Names&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-_0026-cdr&quot; rel=&quot;next&quot;&gt;car &amp;amp; cdr&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;up&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
Strange Names&lt;/h3&gt;
The name of the &lt;code&gt;cons&lt;/code&gt; function is not unreasonable: it is an
abbreviation of the word `construct&#39;.  The origins of the names for
&lt;code&gt;car&lt;/code&gt; and &lt;code&gt;cdr&lt;/code&gt;, on the other hand, are esoteric: &lt;code&gt;car&lt;/code&gt;
is an acronym from the phrase `Contents of the Address part of the
Register&#39;; and &lt;code&gt;cdr&lt;/code&gt; (pronounced `could-er&#39;) is an acronym from
the phrase `Contents of the Decrement part of the Register&#39;.  These
phrases refer to specific pieces of hardware on the very early
computer on which the original Lisp was developed.  Besides being
obsolete, the phrases have been completely irrelevant for more than 25
years to anyone thinking about Lisp.  Nonetheless, although a few
brave scholars have begun to use more reasonable names for these
functions, the old terms are still in use.  In particular, since the
terms are used in the Emacs Lisp source code, we will use them in this
introduction.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;car-&amp;amp;-cdr&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;car-_0026-cdr&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons&quot; rel=&quot;next&quot;&gt;cons&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Strange-Names&quot; rel=&quot;previous&quot;&gt;Strange Names&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;up&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
7.1 &lt;code&gt;car&lt;/code&gt; and &lt;code&gt;cdr&lt;/code&gt;&lt;/h3&gt;
The &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of a list is, quite simply, the first item in the list. 
Thus the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of the list &lt;code&gt;(rose violet daisy buttercup)&lt;/code&gt; is
&lt;code&gt;rose&lt;/code&gt;.

   &lt;br /&gt;
If you are reading this in Info in GNU Emacs, you can see this by
evaluating the following:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (car &#39;(rose violet daisy buttercup))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
After evaluating the expression, &lt;code&gt;rose&lt;/code&gt; will appear in the echo
area.

   &lt;/div&gt;
Clearly, a more reasonable name for the &lt;code&gt;car&lt;/code&gt; function would be
&lt;code&gt;first&lt;/code&gt; and this is often suggested.

   &lt;br /&gt;
&lt;code&gt;car&lt;/code&gt; does not remove the first item from the list; it only reports
what it is.  After &lt;code&gt;car&lt;/code&gt; has been applied to a list, the list is
still the same as it was.  In the jargon, &lt;code&gt;car&lt;/code&gt; is
`non-destructive&#39;.  This feature turns out to be important.

   &lt;br /&gt;
The &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of a list is the rest of the list, that is, the
&lt;code&gt;cdr&lt;/code&gt; function returns the part of the list that follows the
first item.  Thus, while the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of the list &lt;code&gt;&#39;(rose violet
daisy buttercup)&lt;/code&gt; is &lt;code&gt;rose&lt;/code&gt;, the rest of the list, the value
returned by the &lt;code&gt;cdr&lt;/code&gt; function, is &lt;code&gt;(violet daisy
buttercup)&lt;/code&gt;.

   &lt;br /&gt;
You can see this by evaluating the following in the usual way:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (cdr &#39;(rose violet daisy buttercup))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When you evaluate this, &lt;code&gt;(violet daisy buttercup)&lt;/code&gt; will appear in
the echo area.

   &lt;/div&gt;
Like &lt;code&gt;car&lt;/code&gt;, &lt;code&gt;cdr&lt;/code&gt; does not remove any elements from the
list—it just returns a report of what the second and subsequent
elements are.

   &lt;br /&gt;
Incidentally, in the example, the list of flowers is quoted.  If it were
not, the Lisp interpreter would try to evaluate the list by calling
&lt;code&gt;rose&lt;/code&gt; as a function.  In this example, we do not want to do that.

   &lt;br /&gt;
Clearly, a more reasonable name for &lt;code&gt;cdr&lt;/code&gt; would be &lt;code&gt;rest&lt;/code&gt;.

   &lt;br /&gt;
(There is a lesson here: when you name new functions, consider very
carefully what you are doing, since you may be stuck with the names
for far longer than you expect.  The reason this document perpetuates
these names is that the Emacs Lisp source code uses them, and if I did
not use them, you would have a hard time reading the code; but do,
please, try to avoid using these terms yourself.  The people who come
after you will be grateful to you.)

   &lt;br /&gt;
When &lt;code&gt;car&lt;/code&gt; and &lt;code&gt;cdr&lt;/code&gt; are applied to a list made up of symbols,
such as the list &lt;code&gt;(pine fir oak maple)&lt;/code&gt;, the element of the list
returned by the function &lt;code&gt;car&lt;/code&gt; is the symbol &lt;code&gt;pine&lt;/code&gt; without
any parentheses around it.  &lt;code&gt;pine&lt;/code&gt; is the first element in the
list.  However, the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the list is a list itself, &lt;code&gt;(fir
oak maple)&lt;/code&gt;, as you can see by evaluating the following expressions in
the usual way:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (car &#39;(pine fir oak maple))
     
     (cdr &#39;(pine fir oak maple))
&lt;/pre&gt;
On the other hand, in a list of lists, the first element is itself a
list.  &lt;code&gt;car&lt;/code&gt; returns this first element as a list.  For example,
the following list contains three sub-lists, a list of carnivores, a
list of herbivores and a list of sea mammals:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (car &#39;((lion tiger cheetah)
            (gazelle antelope zebra)
            (whale dolphin seal)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In this example, the first element or &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of the list is the list of
carnivores, &lt;code&gt;(lion tiger cheetah)&lt;/code&gt;, and the rest of the list is
&lt;code&gt;((gazelle antelope zebra) (whale dolphin seal))&lt;/code&gt;.

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (cdr &#39;((lion tiger cheetah)
            (gazelle antelope zebra)
            (whale dolphin seal)))
&lt;/pre&gt;
It is worth saying again that &lt;code&gt;car&lt;/code&gt; and &lt;code&gt;cdr&lt;/code&gt; are
non-destructive—that is, they do not modify or change lists to which
they are applied.  This is very important for how they are used.

   &lt;br /&gt;
Also, in the first chapter, in the discussion about atoms, I said that
in Lisp, “certain kinds of atom, such as an array, can be separated
into parts; but the mechanism for doing this is different from the
mechanism for splitting a list.  As far as Lisp is concerned, the
atoms of a list are unsplittable.”  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-Atoms&quot;&gt;Lisp Atoms&lt;/a&gt;.)  The
&lt;code&gt;car&lt;/code&gt; and &lt;code&gt;cdr&lt;/code&gt; functions are used for splitting lists and
are considered fundamental to Lisp.  Since they cannot split or gain
access to the parts of an array, an array is considered an atom. 
Conversely, the other fundamental function, &lt;code&gt;cons&lt;/code&gt;, can put
together or construct a list, but not an array.  (Arrays are handled
by array-specific functions.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Arrays&quot;&gt;Arrays&lt;/a&gt;.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;cons&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nthcdr&quot; rel=&quot;next&quot;&gt;nthcdr&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-_0026-cdr&quot; rel=&quot;previous&quot;&gt;car &amp;amp; cdr&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;up&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
7.2 &lt;code&gt;cons&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-cons_002c-_0040r_007bintroduced_007d-174&quot;&gt;&lt;/a&gt;
The &lt;code&gt;cons&lt;/code&gt; function constructs lists; it is the inverse of
&lt;code&gt;car&lt;/code&gt; and &lt;code&gt;cdr&lt;/code&gt;.  For example, &lt;code&gt;cons&lt;/code&gt; can be used to make
a four element list from the three element list, &lt;code&gt;(fir oak maple)&lt;/code&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (cons &#39;pine &#39;(fir oak maple))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
After evaluating this list, you will see

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (pine fir oak maple)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
appear in the echo area.  &lt;code&gt;cons&lt;/code&gt; causes the creation of a new
list in which the element is followed by the elements of the original
list.

   &lt;/div&gt;
We often say that `&lt;code&gt;cons&lt;/code&gt; puts a new element at the beginning of
a list; it attaches or pushes elements onto the list&#39;, but this
phrasing can be misleading, since &lt;code&gt;cons&lt;/code&gt; does not change an
existing list, but creates a new one.

   &lt;br /&gt;
Like &lt;code&gt;car&lt;/code&gt; and &lt;code&gt;cdr&lt;/code&gt;, &lt;code&gt;cons&lt;/code&gt; is non-destructive.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Build-a-list&quot;&gt;Build a list&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#length&quot;&gt;length&lt;/a&gt;:                       How to find the length of a list. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Build-a-list&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#length&quot; rel=&quot;next&quot;&gt;length&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons&quot; rel=&quot;up&quot;&gt;cons&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
Build a list&lt;/h4&gt;
&lt;code&gt;cons&lt;/code&gt; must have a list to attach to.&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-9&quot; name=&quot;fnd-9&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;9&lt;/sup&gt;&lt;/a&gt;  You
cannot start from absolutely nothing.  If you are building a list, you
need to provide at least an empty list at the beginning.  Here is a
series of &lt;code&gt;cons&lt;/code&gt; expressions that build up a list of flowers.  If
you are reading this in Info in GNU Emacs, you can evaluate each of
the expressions in the usual way; the value is printed in this text
after ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;⇒&lt;/span&gt;&lt;/samp&gt;’, which you may read as `evaluates to&#39;.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (cons &#39;buttercup ())
          ⇒ (buttercup)
     
     (cons &#39;daisy &#39;(buttercup))
          ⇒ (daisy buttercup)
     
     (cons &#39;violet &#39;(daisy buttercup))
          ⇒ (violet daisy buttercup)
     
     (cons &#39;rose &#39;(violet daisy buttercup))
          ⇒ (rose violet daisy buttercup)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In the first example, the empty list is shown as &lt;code&gt;()&lt;/code&gt; and a list
made up of &lt;code&gt;buttercup&lt;/code&gt; followed by the empty list is constructed. 
As you can see, the empty list is not shown in the list that was
constructed.  All that you see is &lt;code&gt;(buttercup)&lt;/code&gt;.  The empty list is
not counted as an element of a list because there is nothing in an empty
list.  Generally speaking, an empty list is invisible.

   &lt;/div&gt;
The second example, &lt;code&gt;(cons &#39;daisy &#39;(buttercup))&lt;/code&gt; constructs a new,
two element list by putting &lt;code&gt;daisy&lt;/code&gt; in front of &lt;code&gt;buttercup&lt;/code&gt;;
and the third example constructs a three element list by putting
&lt;code&gt;violet&lt;/code&gt; in front of &lt;code&gt;daisy&lt;/code&gt; and &lt;code&gt;buttercup&lt;/code&gt;.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;length&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Build-a-list&quot; rel=&quot;previous&quot;&gt;Build a list&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons&quot; rel=&quot;up&quot;&gt;cons&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
7.2.1 Find the Length of a List: &lt;code&gt;length&lt;/code&gt;&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-length-175&quot;&gt;&lt;/a&gt;
You can find out how many elements there are in a list by using the Lisp
function &lt;code&gt;length&lt;/code&gt;, as in the following examples:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (length &#39;(buttercup))
          ⇒ 1
     
     (length &#39;(daisy buttercup))
          ⇒ 2
     
     (length (cons &#39;violet &#39;(daisy buttercup)))
          ⇒ 3
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In the third example, the &lt;code&gt;cons&lt;/code&gt; function is used to construct a
three element list which is then passed to the &lt;code&gt;length&lt;/code&gt; function as
its argument.

   &lt;/div&gt;
We can also use &lt;code&gt;length&lt;/code&gt; to count the number of elements in an
empty list:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (length ())
          ⇒ 0
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
As you would expect, the number of elements in an empty list is zero.

   &lt;/div&gt;
An interesting experiment is to find out what happens if you try to find
the length of no list at all; that is, if you try to call &lt;code&gt;length&lt;/code&gt;
without giving it an argument, not even an empty list:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (length )
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
What you see, if you evaluate this, is the error message

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     Lisp error: (wrong-number-of-arguments length 0)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
This means that the function receives the wrong number of
arguments, zero, when it expects some other number of arguments.  In
this case, one argument is expected, the argument being a list whose
length the function is measuring.  (Note that &lt;em&gt;one&lt;/em&gt; list is
&lt;em&gt;one&lt;/em&gt; argument, even if the list has many elements inside it.)

   &lt;/div&gt;
The part of the error message that says ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;length&lt;/span&gt;&lt;/samp&gt;’ is the name of
the function.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;nthcdr&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nth&quot; rel=&quot;next&quot;&gt;nth&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons&quot; rel=&quot;previous&quot;&gt;cons&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;up&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
7.3 &lt;code&gt;nthcdr&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-nthcdr-176&quot;&gt;&lt;/a&gt;
The &lt;code&gt;nthcdr&lt;/code&gt; function is associated with the &lt;code&gt;cdr&lt;/code&gt; function. 
What it does is take the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of a list repeatedly.

   &lt;br /&gt;
If you take the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the list &lt;code&gt;(pine fir
oak maple)&lt;/code&gt;, you will be returned the list &lt;code&gt;(fir oak maple)&lt;/code&gt;.  If you
repeat this on what was returned, you will be returned the list
&lt;code&gt;(oak maple)&lt;/code&gt;.  (Of course, repeated &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt;ing on the original
list will just give you the original &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; since the function does
not change the list.  You need to evaluate the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the
&lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; and so on.)  If you continue this, eventually you will be
returned an empty list, which in this case, instead of being shown as
&lt;code&gt;()&lt;/code&gt; is shown as &lt;code&gt;nil&lt;/code&gt;.

   &lt;br /&gt;
For review, here is a series of repeated &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt;s, the text following
the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;⇒&lt;/span&gt;&lt;/samp&gt;’ shows what is returned.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (cdr &#39;(pine fir oak maple))
          ⇒(fir oak maple)
     
     (cdr &#39;(fir oak maple))
          ⇒ (oak maple)
     
     (cdr &#39;(oak maple))
          ⇒(maple)
     
     (cdr &#39;(maple))
          ⇒ nil
     
     (cdr &#39;nil)
          ⇒ nil
     
     (cdr ())
          ⇒ nil
&lt;/pre&gt;
You can also do several &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt;s without printing the values in
between, like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (cdr (cdr &#39;(pine fir oak maple)))
          ⇒ (oak maple)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In this example, the Lisp interpreter evaluates the innermost list first. 
The innermost list is quoted, so it just passes the list as it is to the
innermost &lt;code&gt;cdr&lt;/code&gt;.  This &lt;code&gt;cdr&lt;/code&gt; passes a list made up of the
second and subsequent elements of the list to the outermost &lt;code&gt;cdr&lt;/code&gt;,
which produces a list composed of the third and subsequent elements of
the original list.  In this example, the &lt;code&gt;cdr&lt;/code&gt; function is repeated
and returns a list that consists of the original list without its
first two elements.

   &lt;/div&gt;
The &lt;code&gt;nthcdr&lt;/code&gt; function does the same as repeating the call to
&lt;code&gt;cdr&lt;/code&gt;.  In the following example, the argument 2 is passed to the
function &lt;code&gt;nthcdr&lt;/code&gt;, along with the list, and the value returned is
the list without its first two items, which is exactly the same
as repeating &lt;code&gt;cdr&lt;/code&gt; twice on the list:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (nthcdr 2 &#39;(pine fir oak maple))
          ⇒ (oak maple)
&lt;/pre&gt;
Using the original four element list, we can see what happens when
various numeric arguments are passed to &lt;code&gt;nthcdr&lt;/code&gt;, including 0, 1,
and 5:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     ;; &lt;span class=&quot;roman&quot;&gt;Leave the list as it was.&lt;/span&gt;
     (nthcdr 0 &#39;(pine fir oak maple))
          ⇒ (pine fir oak maple)
     
     ;; &lt;span class=&quot;roman&quot;&gt;Return a copy without the first element.&lt;/span&gt;
     (nthcdr 1 &#39;(pine fir oak maple))
          ⇒ (fir oak maple)
     
     ;; &lt;span class=&quot;roman&quot;&gt;Return a copy of the list without three elements.&lt;/span&gt;
     (nthcdr 3 &#39;(pine fir oak maple))
          ⇒ (maple)
     
     ;; &lt;span class=&quot;roman&quot;&gt;Return a copy lacking all four elements.&lt;/span&gt;
     (nthcdr 4 &#39;(pine fir oak maple))
          ⇒ nil
     
     ;; &lt;span class=&quot;roman&quot;&gt;Return a copy lacking all elements.&lt;/span&gt;
     (nthcdr 5 &#39;(pine fir oak maple))
          ⇒ nil
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;nth&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcar&quot; rel=&quot;next&quot;&gt;setcar&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nthcdr&quot; rel=&quot;previous&quot;&gt;nthcdr&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;up&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
7.4 &lt;code&gt;nth&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-nth-177&quot;&gt;&lt;/a&gt;
The &lt;code&gt;nthcdr&lt;/code&gt; function takes the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of a list repeatedly. 
The &lt;code&gt;nth&lt;/code&gt; function takes the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of the result returned by
&lt;code&gt;nthcdr&lt;/code&gt;.  It returns the Nth element of the list.

   &lt;br /&gt;
Thus, if it were not defined in C for speed, the definition of
&lt;code&gt;nth&lt;/code&gt; would be:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun nth (n list)
       &quot;Returns the Nth element of LIST.
     N counts from zero.  If LIST is not that long, nil is returned.&quot;
       (car (nthcdr n list)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(Originally, &lt;code&gt;nth&lt;/code&gt; was defined in Emacs Lisp in &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;subr.el&lt;/span&gt;&lt;/samp&gt;,
but its definition was redone in C in the 1980s.)

   &lt;/div&gt;
The &lt;code&gt;nth&lt;/code&gt; function returns a single element of a list. 
This can be very convenient.

   &lt;br /&gt;
Note that the elements are numbered from zero, not one.  That is to
say, the first element of a list, its &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; is the zeroth element. 
This is called `zero-based&#39; counting and often bothers people who
are accustomed to the first element in a list being number one, which
is `one-based&#39;.

   &lt;br /&gt;
For example:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (nth 0 &#39;(&quot;one&quot; &quot;two&quot; &quot;three&quot;))
         ⇒ &quot;one&quot;
     
     (nth 1 &#39;(&quot;one&quot; &quot;two&quot; &quot;three&quot;))
         ⇒ &quot;two&quot;
&lt;/pre&gt;
It is worth mentioning that &lt;code&gt;nth&lt;/code&gt;, like &lt;code&gt;nthcdr&lt;/code&gt; and
&lt;code&gt;cdr&lt;/code&gt;, does not change the original list—the function is
non-destructive.  This is in sharp contrast to the &lt;code&gt;setcar&lt;/code&gt; and
&lt;code&gt;setcdr&lt;/code&gt; functions.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;setcar&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcdr&quot; rel=&quot;next&quot;&gt;setcdr&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nth&quot; rel=&quot;previous&quot;&gt;nth&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;up&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
7.5 &lt;code&gt;setcar&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-setcar-178&quot;&gt;&lt;/a&gt;
As you might guess from their names, the &lt;code&gt;setcar&lt;/code&gt; and &lt;code&gt;setcdr&lt;/code&gt;
functions set the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; or the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of a list to a new value. 
They actually change the original list, unlike &lt;code&gt;car&lt;/code&gt; and &lt;code&gt;cdr&lt;/code&gt;
which leave the original list as it was.  One way to find out how this
works is to experiment.  We will start with the &lt;code&gt;setcar&lt;/code&gt; function.

   &lt;br /&gt;
First, we can make a list and then set the value of a variable to the
list, using the &lt;code&gt;setq&lt;/code&gt; function.  Here is a list of animals:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq animals &#39;(antelope giraffe lion tiger))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If you are reading this in Info inside of GNU Emacs, you can evaluate
this expression in the usual fashion, by positioning the cursor after
the expression and typing &lt;kbd&gt;C-x C-e&lt;/kbd&gt;.  (I&#39;m doing this right here
as I write this.  This is one of the advantages of having the
interpreter built into the computing environment.  Incidentally, when
there is nothing on the line after the final parentheses, such as a
comment, point can be on the next line.  Thus, if your cursor is in
the first column of the next line, you do not need to move it. 
Indeed, Emacs permits any amount of white space after the final
parenthesis.)

   &lt;/div&gt;
When we evaluate the variable &lt;code&gt;animals&lt;/code&gt;, we see that it is bound to
the list &lt;code&gt;(antelope giraffe lion tiger)&lt;/code&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     animals
          ⇒ (antelope giraffe lion tiger)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Put another way, the variable &lt;code&gt;animals&lt;/code&gt; points to the list
&lt;code&gt;(antelope giraffe lion tiger)&lt;/code&gt;.

   &lt;/div&gt;
Next, evaluate the function &lt;code&gt;setcar&lt;/code&gt; while passing it two
arguments, the variable &lt;code&gt;animals&lt;/code&gt; and the quoted symbol
&lt;code&gt;hippopotamus&lt;/code&gt;; this is done by writing the three element list
&lt;code&gt;(setcar animals &#39;hippopotamus)&lt;/code&gt; and then evaluating it in the
usual fashion:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setcar animals &#39;hippopotamus)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
After evaluating this expression, evaluate the variable &lt;code&gt;animals&lt;/code&gt;
again.  You will see that the list of animals has changed:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     animals
          ⇒ (hippopotamus giraffe lion tiger)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The first element on the list, &lt;code&gt;antelope&lt;/code&gt; is replaced by
&lt;code&gt;hippopotamus&lt;/code&gt;.

   &lt;/div&gt;
So we can see that &lt;code&gt;setcar&lt;/code&gt; did not add a new element to the list
as &lt;code&gt;cons&lt;/code&gt; would have; it replaced &lt;code&gt;antelope&lt;/code&gt; with
&lt;code&gt;hippopotamus&lt;/code&gt;; it &lt;em&gt;changed&lt;/em&gt; the list.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;setcdr&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons-Exercise&quot; rel=&quot;next&quot;&gt;cons Exercise&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcar&quot; rel=&quot;previous&quot;&gt;setcar&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;up&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
7.6 &lt;code&gt;setcdr&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-setcdr-179&quot;&gt;&lt;/a&gt;
The &lt;code&gt;setcdr&lt;/code&gt; function is similar to the &lt;code&gt;setcar&lt;/code&gt; function,
except that the function replaces the second and subsequent elements of
a list rather than the first element.

   &lt;br /&gt;
(To see how to change the last element of a list, look ahead to
&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dnew-function&quot;&gt;The &lt;code&gt;kill-new&lt;/code&gt; function&lt;/a&gt;, which uses
the &lt;code&gt;nthcdr&lt;/code&gt; and &lt;code&gt;setcdr&lt;/code&gt; functions.)

   &lt;br /&gt;
To see how this works, set the value of the variable to a list of
domesticated animals by evaluating the following expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq domesticated-animals &#39;(horse cow sheep goat))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If you now evaluate the list, you will be returned the list
&lt;code&gt;(horse cow sheep goat)&lt;/code&gt;:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     domesticated-animals
          ⇒ (horse cow sheep goat)
&lt;/pre&gt;
Next, evaluate &lt;code&gt;setcdr&lt;/code&gt; with two arguments, the name of the
variable which has a list as its value, and the list to which the
&lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the first list will be set;

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setcdr domesticated-animals &#39;(cat dog))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If you evaluate this expression, the list &lt;code&gt;(cat dog)&lt;/code&gt; will appear
in the echo area.  This is the value returned by the function.  The
result we are interested in is the “side effect”, which we can see by
evaluating the variable &lt;code&gt;domesticated-animals&lt;/code&gt;:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     domesticated-animals
          ⇒ (horse cat dog)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Indeed, the list is changed from &lt;code&gt;(horse cow sheep goat)&lt;/code&gt; to
&lt;code&gt;(horse cat dog)&lt;/code&gt;.  The &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the list is changed from
&lt;code&gt;(cow sheep goat)&lt;/code&gt; to &lt;code&gt;(cat dog)&lt;/code&gt;.

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;cons-Exercise&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcdr&quot; rel=&quot;previous&quot;&gt;setcdr&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;up&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
7.7 Exercise&lt;/h3&gt;
Construct a list of four birds by evaluating several expressions with
&lt;code&gt;cons&lt;/code&gt;.  Find out what happens when you &lt;code&gt;cons&lt;/code&gt; a list onto
itself.  Replace the first element of the list of four birds with a
fish.  Replace the rest of that list with a list of other fish.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Cutting-&amp;amp;-Storing-Text&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Cutting-_0026-Storing-Text&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Implementation&quot; rel=&quot;next&quot;&gt;List Implementation&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#car-cdr-_0026-cons&quot; rel=&quot;previous&quot;&gt;car cdr &amp;amp; cons&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
8 Cutting and Storing Text&lt;/h2&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Cutting-and-storing-text-180&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Storing-and-cutting-text-181&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Killing-text-182&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Clipping-text-183&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Erasing-text-184&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Deleting-text-185&quot;&gt;&lt;/a&gt;
Whenever you cut or clip text out of a buffer with a `kill&#39; command in
GNU Emacs, it is stored in a list and you can bring it back with a
`yank&#39; command.

   &lt;br /&gt;
(The use of the word `kill&#39; in Emacs for processes which specifically
&lt;em&gt;do not&lt;/em&gt; destroy the values of the entities is an unfortunate
historical accident.  A much more appropriate word would be `clip&#39; since
that is what the kill commands do; they clip text out of a buffer and
put it into storage from which it can be brought back.  I have often
been tempted to replace globally all occurrences of `kill&#39; in the Emacs
sources with `clip&#39; and all occurrences of `killed&#39; with `clipped&#39;.)

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Storing-Text&quot;&gt;Storing Text&lt;/a&gt;:                 Text is stored in a list. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot;&gt;zap-to-char&lt;/a&gt;:                  Cutting out text up to a character. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dregion&quot;&gt;kill-region&lt;/a&gt;:                  Cutting text out of a region. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill&quot;&gt;copy-region-as-kill&lt;/a&gt;:          A definition for copying text. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Digression-into-C&quot;&gt;Digression into C&lt;/a&gt;:            Minor note on C programming language macros. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defvar&quot;&gt;defvar&lt;/a&gt;:                       How to give a variable an initial value. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;7&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons-_0026-search_002dfwd-Review&quot;&gt;cons &amp;amp; search-fwd Review&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;8&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#search-Exercises&quot;&gt;search Exercises&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Storing-Text&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot; rel=&quot;next&quot;&gt;zap-to-char&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;up&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
Storing Text in a List&lt;/h3&gt;
When text is cut out of a buffer, it is stored on a list.  Successive
pieces of text are stored on the list successively, so the list might
look like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (&quot;a piece of text&quot; &quot;previous piece&quot;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The function &lt;code&gt;cons&lt;/code&gt; can be used to create a new list from a piece
of text (an `atom&#39;, to use the jargon) and an existing list, like
this:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (cons &quot;another piece&quot;
           &#39;(&quot;a piece of text&quot; &quot;previous piece&quot;))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If you evaluate this expression, a list of three elements will appear in
the echo area:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (&quot;another piece&quot; &quot;a piece of text&quot; &quot;previous piece&quot;)
&lt;/pre&gt;
With the &lt;code&gt;car&lt;/code&gt; and &lt;code&gt;nthcdr&lt;/code&gt; functions, you can retrieve
whichever piece of text you want.  For example, in the following code,
&lt;code&gt;nthcdr 1 ...&lt;/code&gt; returns the list with the first item removed;
and the &lt;code&gt;car&lt;/code&gt; returns the first element of that remainder—the
second element of the original list:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (car (nthcdr 1 &#39;(&quot;another piece&quot;
                      &quot;a piece of text&quot;
                      &quot;previous piece&quot;)))
          ⇒ &quot;a piece of text&quot;
&lt;/pre&gt;
The actual functions in Emacs are more complex than this, of course. 
The code for cutting and retrieving text has to be written so that
Emacs can figure out which element in the list you want—the first,
second, third, or whatever.  In addition, when you get to the end of
the list, Emacs should give you the first element of the list, rather
than nothing at all.

   &lt;br /&gt;
The list that holds the pieces of text is called the &lt;dfn&gt;kill ring&lt;/dfn&gt;. 
This chapter leads up to a description of the kill ring and how it is
used by first tracing how the &lt;code&gt;zap-to-char&lt;/code&gt; function works.  This
function uses (or `calls&#39;) a function that invokes a function that
manipulates the kill ring.  Thus, before reaching the mountains, we
climb the foothills.

   &lt;br /&gt;
A subsequent chapter describes how text that is cut from the buffer is
retrieved.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Yanking&quot;&gt;Yanking Text Back&lt;/a&gt;.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;zap-to-char&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;zap_002dto_002dchar&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dregion&quot; rel=&quot;next&quot;&gt;kill-region&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Storing-Text&quot; rel=&quot;previous&quot;&gt;Storing Text&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;up&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
8.1 &lt;code&gt;zap-to-char&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-zap_002dto_002dchar-186&quot;&gt;&lt;/a&gt;

The &lt;code&gt;zap-to-char&lt;/code&gt; function changed little between GNU Emacs
version 19 and GNU Emacs version 22.  However, &lt;code&gt;zap-to-char&lt;/code&gt;
calls another function, &lt;code&gt;kill-region&lt;/code&gt;, which enjoyed a major
rewrite.

   &lt;br /&gt;
The &lt;code&gt;kill-region&lt;/code&gt; function in Emacs 19 is complex, but does not
use code that is important at this time.  We will skip it.

   &lt;br /&gt;
The &lt;code&gt;kill-region&lt;/code&gt; function in Emacs 22 is easier to read than the
same function in Emacs 19 and introduces a very important concept,
that of error handling.  We will walk through the function.

   &lt;br /&gt;
But first, let us look at the interactive &lt;code&gt;zap-to-char&lt;/code&gt; function.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-zap_002dto_002dchar&quot;&gt;Complete zap-to-char&lt;/a&gt;:         The complete implementation. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar-interactive&quot;&gt;zap-to-char interactive&lt;/a&gt;:      A three part interactive expression. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar-body&quot;&gt;zap-to-char body&lt;/a&gt;:             A short overview. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#search_002dforward&quot;&gt;search-forward&lt;/a&gt;:               How to search for a string. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#progn&quot;&gt;progn&lt;/a&gt;:                        The &lt;code&gt;progn&lt;/code&gt; special form. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Summing-up-zap_002dto_002dchar&quot;&gt;Summing up zap-to-char&lt;/a&gt;:       Using &lt;code&gt;point&lt;/code&gt; and &lt;code&gt;search-forward&lt;/code&gt;. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Complete-zap-to-char&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Complete-zap_002dto_002dchar&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar-interactive&quot; rel=&quot;next&quot;&gt;zap-to-char interactive&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot; rel=&quot;up&quot;&gt;zap-to-char&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
The Complete &lt;code&gt;zap-to-char&lt;/code&gt; Implementation&lt;/h4&gt;
The &lt;code&gt;zap-to-char&lt;/code&gt; function removes the text in the region between
the location of the cursor (i.e., of point) up to and including the
next occurrence of a specified character.  The text that
&lt;code&gt;zap-to-char&lt;/code&gt; removes is put in the kill ring; and it can be
retrieved from the kill ring by typing &lt;kbd&gt;C-y&lt;/kbd&gt; (&lt;code&gt;yank&lt;/code&gt;).  If
the command is given an argument, it removes text through that number
of occurrences.  Thus, if the cursor were at the beginning of this
sentence and the character were ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;s&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Thus&lt;/span&gt;&lt;/samp&gt;’ would be
removed.  If the argument were two, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Thus, if the curs&lt;/span&gt;&lt;/samp&gt;’ would be
removed, up to and including the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;s&lt;/span&gt;&lt;/samp&gt;’ in ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;cursor&lt;/span&gt;&lt;/samp&gt;’.

   &lt;br /&gt;
If the specified character is not found, &lt;code&gt;zap-to-char&lt;/code&gt; will say
“Search failed”, tell you the character you typed, and not remove
any text.

   &lt;br /&gt;
In order to determine how much text to remove, &lt;code&gt;zap-to-char&lt;/code&gt; uses
a search function.  Searches are used extensively in code that
manipulates text, and we will focus attention on them as well as on the
deletion command.

   &lt;br /&gt;
Here is the complete text of the version 22 implementation of the function:


&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun zap-to-char (arg char)
       &quot;Kill up to and including ARG&#39;th occurrence of CHAR.
     Case is ignored if `case-fold-search&#39; is non-nil in the current buffer.
     Goes backward if ARG is negative; error if CHAR not found.&quot;
       (interactive &quot;p\ncZap to char: &quot;)
       (if (char-table-p translation-table-for-input)
           (setq char (or (aref translation-table-for-input char) char)))
       (kill-region (point) (progn
                              (search-forward (char-to-string char)
                                              nil nil arg)
                              (point))))
&lt;/pre&gt;
The documentation is thorough.  You do need to know the jargon meaning
of the word `kill&#39;.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;zap-to-char-interactive&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;zap_002dto_002dchar-interactive&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar-body&quot; rel=&quot;next&quot;&gt;zap-to-char body&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-zap_002dto_002dchar&quot; rel=&quot;previous&quot;&gt;Complete zap-to-char&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot; rel=&quot;up&quot;&gt;zap-to-char&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
8.1.1 The &lt;code&gt;interactive&lt;/code&gt; Expression&lt;/h4&gt;
The interactive expression in the &lt;code&gt;zap-to-char&lt;/code&gt; command looks like
this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (interactive &quot;p\ncZap to char: &quot;)
&lt;/pre&gt;
The part within quotation marks, &lt;code&gt;&quot;p\ncZap to char: &quot;&lt;/code&gt;, specifies
two different things.  First, and most simply, is the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’. 
This part is separated from the next part by a newline, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;\n&lt;/span&gt;&lt;/samp&gt;’. 
The ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;p&lt;/span&gt;&lt;/samp&gt;’ means that the first argument to the function will be
passed the value of a `processed prefix&#39;.  The prefix argument is
passed by typing &lt;kbd&gt;C-u&lt;/kbd&gt; and a number, or &lt;kbd&gt;M-&lt;/kbd&gt; and a number.  If
the function is called interactively without a prefix, 1 is passed to
this argument.

   &lt;br /&gt;
The second part of &lt;code&gt;&quot;p\ncZap to char: &quot;&lt;/code&gt; is
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;cZap to char:  &lt;/span&gt;&lt;/samp&gt;’.  In this part, the lower case ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;c&lt;/span&gt;&lt;/samp&gt;’
indicates that &lt;code&gt;interactive&lt;/code&gt; expects a prompt and that the
argument will be a character.  The prompt follows the ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;c&lt;/span&gt;&lt;/samp&gt;’ and is
the string ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;Zap to char: &lt;/span&gt;&lt;/samp&gt;’ (with a space after the colon to
make it look good).

   &lt;br /&gt;
What all this does is prepare the arguments to &lt;code&gt;zap-to-char&lt;/code&gt; so they
are of the right type, and give the user a prompt.

   &lt;br /&gt;
In a read-only buffer, the &lt;code&gt;zap-to-char&lt;/code&gt; function copies the text
to the kill ring, but does not remove it.  The echo area displays a
message saying that the buffer is read-only.  Also, the terminal may
beep or blink at you.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;zap-to-char-body&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;zap_002dto_002dchar-body&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#search_002dforward&quot; rel=&quot;next&quot;&gt;search-forward&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar-interactive&quot; rel=&quot;previous&quot;&gt;zap-to-char interactive&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot; rel=&quot;up&quot;&gt;zap-to-char&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
8.1.2 The Body of &lt;code&gt;zap-to-char&lt;/code&gt;&lt;/h4&gt;
The body of the &lt;code&gt;zap-to-char&lt;/code&gt; function contains the code that
kills (that is, removes) the text in the region from the current
position of the cursor up to and including the specified character.

   &lt;br /&gt;
The first part of the code looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (char-table-p translation-table-for-input)
         (setq char (or (aref translation-table-for-input char) char)))
     (kill-region (point) (progn
                            (search-forward (char-to-string char) nil nil arg)
                            (point)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
&lt;code&gt;char-table-p&lt;/code&gt; is an hitherto unseen function.  It determines
whether its argument is a character table.  When it is, it sets the
character passed to &lt;code&gt;zap-to-char&lt;/code&gt; to one of them, if that
character exists, or to the character itself.  (This becomes important
for certain characters in non-European languages.  The &lt;code&gt;aref&lt;/code&gt;
function extracts an element from an array.  It is an array-specific
function that is not described in this document.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Arrays&quot;&gt;Arrays&lt;/a&gt;.)

&lt;/div&gt;
&lt;div class=&quot;noindent&quot;&gt;
&lt;code&gt;(point)&lt;/code&gt; is the current position of the cursor.

   &lt;/div&gt;
The next part of the code is an expression using &lt;code&gt;progn&lt;/code&gt;.  The body
of the &lt;code&gt;progn&lt;/code&gt; consists of calls to &lt;code&gt;search-forward&lt;/code&gt; and
&lt;code&gt;point&lt;/code&gt;.

   &lt;br /&gt;
It is easier to understand how &lt;code&gt;progn&lt;/code&gt; works after learning about
&lt;code&gt;search-forward&lt;/code&gt;, so we will look at &lt;code&gt;search-forward&lt;/code&gt; and
then at &lt;code&gt;progn&lt;/code&gt;.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;search-forward&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;search_002dforward&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#progn&quot; rel=&quot;next&quot;&gt;progn&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar-body&quot; rel=&quot;previous&quot;&gt;zap-to-char body&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot; rel=&quot;up&quot;&gt;zap-to-char&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
8.1.3 The &lt;code&gt;search-forward&lt;/code&gt; Function&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-search_002dforward-187&quot;&gt;&lt;/a&gt;
The &lt;code&gt;search-forward&lt;/code&gt; function is used to locate the
zapped-for-character in &lt;code&gt;zap-to-char&lt;/code&gt;.  If the search is
successful, &lt;code&gt;search-forward&lt;/code&gt; leaves point immediately after the
last character in the target string.  (In &lt;code&gt;zap-to-char&lt;/code&gt;, the
target string is just one character long.  &lt;code&gt;zap-to-char&lt;/code&gt; uses the
function &lt;code&gt;char-to-string&lt;/code&gt; to ensure that the computer treats that
character as a string.)  If the search is backwards,
&lt;code&gt;search-forward&lt;/code&gt; leaves point just before the first character in
the target.  Also, &lt;code&gt;search-forward&lt;/code&gt; returns &lt;code&gt;t&lt;/code&gt; for true. 
(Moving point is therefore a `side effect&#39;.)

   &lt;br /&gt;
In &lt;code&gt;zap-to-char&lt;/code&gt;, the &lt;code&gt;search-forward&lt;/code&gt; function looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (search-forward (char-to-string char) nil nil arg)
&lt;/pre&gt;
The &lt;code&gt;search-forward&lt;/code&gt; function takes four arguments:

     &lt;br /&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li&gt;The first argument is the target, what is searched for.  This must be a
string, such as ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;&quot;z&quot;&lt;/span&gt;&lt;/samp&gt;’.

     As it happens, the argument passed to &lt;code&gt;zap-to-char&lt;/code&gt; is a single
character.  Because of the way computers are built, the Lisp
interpreter may treat a single character as being different from a
string of characters.  Inside the computer, a single character has a
different electronic format than a string of one character.  (A single
character can often be recorded in the computer using exactly one
byte; but a string may be longer, and the computer needs to be ready
for this.)  Since the &lt;code&gt;search-forward&lt;/code&gt; function searches for a
string, the character that the &lt;code&gt;zap-to-char&lt;/code&gt; function receives as
its argument must be converted inside the computer from one format to
the other; otherwise the &lt;code&gt;search-forward&lt;/code&gt; function will fail. 
The &lt;code&gt;char-to-string&lt;/code&gt; function is used to make this conversion.

     &lt;/li&gt;
&lt;li&gt;The second argument bounds the search; it is specified as a position in
the buffer.  In this case, the search can go to the end of the buffer,
so no bound is set and the second argument is &lt;code&gt;nil&lt;/code&gt;.

     &lt;/li&gt;
&lt;li&gt;The third argument tells the function what it should do if the search
fails—it can signal an error (and print a message) or it can return
&lt;code&gt;nil&lt;/code&gt;.  A &lt;code&gt;nil&lt;/code&gt; as the third argument causes the function to
signal an error when the search fails.

     &lt;/li&gt;
&lt;li&gt;The fourth argument to &lt;code&gt;search-forward&lt;/code&gt; is the repeat count—how
many occurrences of the string to look for.  This argument is optional
and if the function is called without a repeat count, this argument is
passed the value 1.  If this argument is negative, the search goes
backwards.
        &lt;/li&gt;
&lt;/ol&gt;
In template form, a &lt;code&gt;search-forward&lt;/code&gt; expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (search-forward &quot;&lt;var&gt;target-string&lt;/var&gt;&quot;
                     &lt;var&gt;limit-of-search&lt;/var&gt;
                     &lt;var&gt;what-to-do-if-search-fails&lt;/var&gt;
                     &lt;var&gt;repeat-count&lt;/var&gt;)
&lt;/pre&gt;
We will look at &lt;code&gt;progn&lt;/code&gt; next.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;progn&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Summing-up-zap_002dto_002dchar&quot; rel=&quot;next&quot;&gt;Summing up zap-to-char&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#search_002dforward&quot; rel=&quot;previous&quot;&gt;search-forward&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot; rel=&quot;up&quot;&gt;zap-to-char&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
8.1.4 The &lt;code&gt;progn&lt;/code&gt; Special Form&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-progn-188&quot;&gt;&lt;/a&gt;
&lt;code&gt;progn&lt;/code&gt; is a special form that causes each of its arguments to be
evaluated in sequence and then returns the value of the last one.  The
preceding expressions are evaluated only for the side effects they
perform.  The values produced by them are discarded.

   &lt;br /&gt;
The template for a &lt;code&gt;progn&lt;/code&gt; expression is very simple:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (progn
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
In &lt;code&gt;zap-to-char&lt;/code&gt;, the &lt;code&gt;progn&lt;/code&gt; expression has to do two things:
put point in exactly the right position; and return the location of
point so that &lt;code&gt;kill-region&lt;/code&gt; will know how far to kill to.

   &lt;br /&gt;
The first argument to the &lt;code&gt;progn&lt;/code&gt; is &lt;code&gt;search-forward&lt;/code&gt;.  When
&lt;code&gt;search-forward&lt;/code&gt; finds the string, the function leaves point
immediately after the last character in the target string.  (In this
case the target string is just one character long.)  If the search is
backwards, &lt;code&gt;search-forward&lt;/code&gt; leaves point just before the first
character in the target.  The movement of point is a side effect.

   &lt;br /&gt;
The second and last argument to &lt;code&gt;progn&lt;/code&gt; is the expression
&lt;code&gt;(point)&lt;/code&gt;.  This expression returns the value of point, which in
this case will be the location to which it has been moved by
&lt;code&gt;search-forward&lt;/code&gt;.  (In the source, a line that tells the function
to go to the previous character, if it is going forward, was commented
out in 1999; I don&#39;t remember whether that feature or mis-feature was
ever a part of the distributed source.)  The value of &lt;code&gt;point&lt;/code&gt; is
returned by the &lt;code&gt;progn&lt;/code&gt; expression and is passed to
&lt;code&gt;kill-region&lt;/code&gt; as &lt;code&gt;kill-region&lt;/code&gt;&#39;s second argument.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Summing-up-zap-to-char&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Summing-up-zap_002dto_002dchar&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#progn&quot; rel=&quot;previous&quot;&gt;progn&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot; rel=&quot;up&quot;&gt;zap-to-char&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
8.1.5 Summing up &lt;code&gt;zap-to-char&lt;/code&gt;&lt;/h4&gt;
Now that we have seen how &lt;code&gt;search-forward&lt;/code&gt; and &lt;code&gt;progn&lt;/code&gt; work,
we can see how the &lt;code&gt;zap-to-char&lt;/code&gt; function works as a whole.

   &lt;br /&gt;
The first argument to &lt;code&gt;kill-region&lt;/code&gt; is the position of the cursor
when the &lt;code&gt;zap-to-char&lt;/code&gt; command is given—the value of point at
that time.  Within the &lt;code&gt;progn&lt;/code&gt;, the search function then moves
point to just after the zapped-to-character and &lt;code&gt;point&lt;/code&gt; returns the
value of this location.  The &lt;code&gt;kill-region&lt;/code&gt; function puts together
these two values of point, the first one as the beginning of the region
and the second one as the end of the region, and removes the region.

   &lt;br /&gt;
The &lt;code&gt;progn&lt;/code&gt; special form is necessary because the
&lt;code&gt;kill-region&lt;/code&gt; command takes two arguments; and it would fail if
&lt;code&gt;search-forward&lt;/code&gt; and &lt;code&gt;point&lt;/code&gt; expressions were written in
sequence as two additional arguments.  The &lt;code&gt;progn&lt;/code&gt; expression is
a single argument to &lt;code&gt;kill-region&lt;/code&gt; and returns the one value that
&lt;code&gt;kill-region&lt;/code&gt; needs for its second argument.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;kill-region&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;kill_002dregion&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill&quot; rel=&quot;next&quot;&gt;copy-region-as-kill&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#zap_002dto_002dchar&quot; rel=&quot;previous&quot;&gt;zap-to-char&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;up&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
8.2 &lt;code&gt;kill-region&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-kill_002dregion-189&quot;&gt;&lt;/a&gt;
The &lt;code&gt;zap-to-char&lt;/code&gt; function uses the &lt;code&gt;kill-region&lt;/code&gt; function. 
This function clips text from a region and copies that text to
the kill ring, from which it may be retrieved.

   &lt;br /&gt;
The Emacs 22 version of that function uses &lt;code&gt;condition-case&lt;/code&gt; and
&lt;code&gt;copy-region-as-kill&lt;/code&gt;, both of which we will explain. 
&lt;code&gt;condition-case&lt;/code&gt; is an important special form.

   &lt;br /&gt;
In essence, the &lt;code&gt;kill-region&lt;/code&gt; function calls
&lt;code&gt;condition-case&lt;/code&gt;, which takes three arguments.  In this function,
the first argument does nothing.  The second argument contains the
code that does the work when all goes well.  The third argument
contains the code that is called in the event of an error.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-kill_002dregion&quot;&gt;Complete kill-region&lt;/a&gt;:         The function definition. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#condition_002dcase&quot;&gt;condition-case&lt;/a&gt;:               Dealing with a problem. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-macro&quot;&gt;Lisp macro&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Complete-kill-region&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Complete-kill_002dregion&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#condition_002dcase&quot; rel=&quot;next&quot;&gt;condition-case&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dregion&quot; rel=&quot;up&quot;&gt;kill-region&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
The Complete &lt;code&gt;kill-region&lt;/code&gt; Definition&lt;/h4&gt;
We will go through the &lt;code&gt;condition-case&lt;/code&gt; code in a moment.  First,
let us look at the definition of &lt;code&gt;kill-region&lt;/code&gt;, with comments
added:


&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun kill-region (beg end)
       &quot;Kill (\&quot;cut\&quot;) text between point and mark.
     This deletes the text from the buffer and saves it in the kill ring.
     The command \\[yank] can retrieve it from there. ... &quot;
     
       ;; • Since order matters, pass point first.
       (interactive (list (point) (mark)))
       ;; • And tell us if we cannot cut the text.
       ;; `unless&#39; is an `if&#39; without a then-part.
       (unless (and beg end)
         (error &quot;The mark is not set now, so there is no region&quot;))
     
       ;; • `condition-case&#39; takes three arguments.
       ;;    If the first argument is nil, as it is here,
       ;;    information about the error signal is not
       ;;    stored for use by another function.
       (condition-case nil
     
           ;; • The second argument to `condition-case&#39; tells the
           ;;    Lisp interpreter what to do when all goes well.
     
           ;;    It starts with a `let&#39; function that extracts the string
           ;;    and tests whether it exists.  If so (that is what the
           ;;    `when&#39; checks), it calls an `if&#39; function that determines
           ;;    whether the previous command was another call to
           ;;    `kill-region&#39;; if it was, then the new text is appended to
           ;;    the previous text; if not, then a different function,
           ;;    `kill-new&#39;, is called.
     
           ;;    The `kill-append&#39; function concatenates the new string and
           ;;    the old.  The `kill-new&#39; function inserts text into a new
           ;;    item in the kill ring.
     
           ;;    `when&#39; is an `if&#39; without an else-part.  The second `when&#39;
           ;;    again checks whether the current string exists; in
           ;;    addition, it checks whether the previous command was
           ;;    another call to `kill-region&#39;.  If one or the other
           ;;    condition is true, then it sets the current command to
           ;;    be `kill-region&#39;.
           (let ((string (filter-buffer-substring beg end t)))
             (when string                    ;STRING is nil if BEG = END
               ;; Add that string to the kill ring, one way or another.
               (if (eq last-command &#39;kill-region)
                   ;;    − `yank-handler&#39; is an optional argument to
                   ;;    `kill-region&#39; that tells the `kill-append&#39; and
                   ;;    `kill-new&#39; functions how deal with properties
                   ;;    added to the text, such as `bold&#39; or `italics&#39;.
                   (kill-append string (&amp;lt; end beg) yank-handler)
                 (kill-new string nil yank-handler)))
             (when (or string (eq last-command &#39;kill-region))
               (setq this-command &#39;kill-region))
             nil)
     
         ;;  • The third argument to `condition-case&#39; tells the interpreter
         ;;    what to do with an error.
         ;;    The third argument has a conditions part and a body part.
         ;;    If the conditions are met (in this case,
         ;;             if text or buffer are read-only)
         ;;    then the body is executed.
         ;;    The first part of the third argument is the following:
         ((buffer-read-only text-read-only) ;; the if-part
          ;; ...  the then-part
          (copy-region-as-kill beg end)
          ;;    Next, also as part of the then-part, set this-command, so
          ;;    it will be set in an error
          (setq this-command &#39;kill-region)
          ;;    Finally, in the then-part, send a message if you may copy
          ;;    the text to the kill ring without signaling an error, but
          ;;    don&#39;t if you may not.
          (if kill-read-only-ok
              (progn (message &quot;Read only text copied to kill ring&quot;) nil)
            (barf-if-buffer-read-only)
            ;; If the buffer isn&#39;t read-only, the text is.
            (signal &#39;text-read-only (list (current-buffer)))))
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;condition-case&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;condition_002dcase&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lisp-macro&quot; rel=&quot;next&quot;&gt;Lisp macro&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-kill_002dregion&quot; rel=&quot;previous&quot;&gt;Complete kill-region&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dregion&quot; rel=&quot;up&quot;&gt;kill-region&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
8.2.1 &lt;code&gt;condition-case&lt;/code&gt;&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-condition_002dcase-190&quot;&gt;&lt;/a&gt;
As we have seen earlier (see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Making-Errors&quot;&gt;Generate an Error Message&lt;/a&gt;), when the Emacs Lisp interpreter has trouble evaluating an
expression, it provides you with help; in the jargon, this is called
“signaling an error”.  Usually, the computer stops the program and
shows you a message.

   &lt;br /&gt;
However, some programs undertake complicated actions.  They should not
simply stop on an error.  In the &lt;code&gt;kill-region&lt;/code&gt; function, the most
likely error is that you will try to kill text that is read-only and
cannot be removed.  So the &lt;code&gt;kill-region&lt;/code&gt; function contains code
to handle this circumstance.  This code, which makes up the body of
the &lt;code&gt;kill-region&lt;/code&gt; function, is inside of a &lt;code&gt;condition-case&lt;/code&gt;
special form.

   &lt;br /&gt;
The template for &lt;code&gt;condition-case&lt;/code&gt; looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (condition-case
       &lt;var&gt;var&lt;/var&gt;
       &lt;var&gt;bodyform&lt;/var&gt;
       &lt;var&gt;error-handler&lt;/var&gt;...)
&lt;/pre&gt;
The second argument, &lt;var&gt;bodyform&lt;/var&gt;, is straightforward.  The
&lt;code&gt;condition-case&lt;/code&gt; special form causes the Lisp interpreter to
evaluate the code in &lt;var&gt;bodyform&lt;/var&gt;.  If no error occurs, the special
form returns the code&#39;s value and produces the side-effects, if any.

   &lt;br /&gt;
In short, the &lt;var&gt;bodyform&lt;/var&gt; part of a &lt;code&gt;condition-case&lt;/code&gt;
expression determines what should happen when everything works
correctly.

   &lt;br /&gt;
However, if an error occurs, among its other actions, the function
generating the error signal will define one or more error condition
names.

   &lt;br /&gt;
An error handler is the third argument to &lt;code&gt;condition case&lt;/code&gt;. 
An error handler has two parts, a &lt;var&gt;condition-name&lt;/var&gt; and a
&lt;var&gt;body&lt;/var&gt;.  If the &lt;var&gt;condition-name&lt;/var&gt; part of an error handler
matches a condition name generated by an error, then the &lt;var&gt;body&lt;/var&gt;
part of the error handler is run.

   &lt;br /&gt;
As you will expect, the &lt;var&gt;condition-name&lt;/var&gt; part of an error handler
may be either a single condition name or a list of condition names.

   &lt;br /&gt;
Also, a complete &lt;code&gt;condition-case&lt;/code&gt; expression may contain more
than one error handler.  When an error occurs, the first applicable
handler is run.

   &lt;br /&gt;
Lastly, the first argument to the &lt;code&gt;condition-case&lt;/code&gt; expression,
the &lt;var&gt;var&lt;/var&gt; argument, is sometimes bound to a variable that
contains information about the error.  However, if that argument is
nil, as is the case in &lt;code&gt;kill-region&lt;/code&gt;, that information is
discarded.

   &lt;br /&gt;
In brief, in the &lt;code&gt;kill-region&lt;/code&gt; function, the code
&lt;code&gt;condition-case&lt;/code&gt; works like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &lt;var&gt;If no errors&lt;/var&gt;, &lt;var&gt;run only this code&lt;/var&gt;
         &lt;var&gt;but&lt;/var&gt;, &lt;var&gt;if errors&lt;/var&gt;, &lt;var&gt;run this other code&lt;/var&gt;.
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Lisp-macro&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#condition_002dcase&quot; rel=&quot;previous&quot;&gt;condition-case&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dregion&quot; rel=&quot;up&quot;&gt;kill-region&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
8.2.2 Lisp macro&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Macro_002c-lisp-191&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Lisp-macro-192&quot;&gt;&lt;/a&gt;
The part of the &lt;code&gt;condition-case&lt;/code&gt; expression that is evaluated in
the expectation that all goes well has a &lt;code&gt;when&lt;/code&gt;.  The code uses
&lt;code&gt;when&lt;/code&gt; to determine whether the &lt;code&gt;string&lt;/code&gt; variable points to
text that exists.

   &lt;br /&gt;
A &lt;code&gt;when&lt;/code&gt; expression is simply a programmers&#39; convenience.  It is
an &lt;code&gt;if&lt;/code&gt; without the possibility of an else clause.  In your mind,
you can replace &lt;code&gt;when&lt;/code&gt; with &lt;code&gt;if&lt;/code&gt; and understand what goes
on.  That is what the Lisp interpreter does.

   &lt;br /&gt;
Technically speaking, &lt;code&gt;when&lt;/code&gt; is a Lisp macro.  A Lisp &lt;dfn&gt;macro&lt;/dfn&gt;
enables you to define new control constructs and other language
features.  It tells the interpreter how to compute another Lisp
expression which will in turn compute the value.  In this case, the
`other expression&#39; is an &lt;code&gt;if&lt;/code&gt; expression.

   &lt;br /&gt;
The &lt;code&gt;kill-region&lt;/code&gt; function definition also has an &lt;code&gt;unless&lt;/code&gt;
macro; it is the converse of &lt;code&gt;when&lt;/code&gt;.  The &lt;code&gt;unless&lt;/code&gt; macro is
an &lt;code&gt;if&lt;/code&gt; without a then clause

   &lt;br /&gt;
For more about Lisp macros, see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Macros&quot;&gt;Macros&lt;/a&gt;.  The C programming language also
provides macros.  These are different, but also useful.

   &lt;br /&gt;
Regarding the &lt;code&gt;when&lt;/code&gt; macro, in the &lt;code&gt;condition-case&lt;/code&gt;
expression, when the string has content, then another conditional
expression is executed.  This is an &lt;code&gt;if&lt;/code&gt; with both a then-part
and an else-part.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (eq last-command &#39;kill-region)
         (kill-append string (&amp;lt; end beg) yank-handler)
       (kill-new string nil yank-handler))
&lt;/pre&gt;
The then-part is evaluated if the previous command was another call to
&lt;code&gt;kill-region&lt;/code&gt;; if not, the else-part is evaluated.

   &lt;br /&gt;
&lt;code&gt;yank-handler&lt;/code&gt; is an optional argument to &lt;code&gt;kill-region&lt;/code&gt; that
tells the &lt;code&gt;kill-append&lt;/code&gt; and &lt;code&gt;kill-new&lt;/code&gt; functions how deal
with properties added to the text, such as `bold&#39; or `italics&#39;.

   &lt;br /&gt;
&lt;code&gt;last-command&lt;/code&gt; is a variable that comes with Emacs that we have
not seen before.  Normally, whenever a function is executed, Emacs
sets the value of &lt;code&gt;last-command&lt;/code&gt; to the previous command.

   &lt;br /&gt;
In this segment of the definition, the &lt;code&gt;if&lt;/code&gt; expression checks
whether the previous command was &lt;code&gt;kill-region&lt;/code&gt;.  If it was,

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (kill-append string (&amp;lt; end beg) yank-handler)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
concatenates a copy of the newly clipped text to the just previously
clipped text in the kill ring.

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;copy-region-as-kill&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;copy_002dregion_002das_002dkill&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Digression-into-C&quot; rel=&quot;next&quot;&gt;Digression into C&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dregion&quot; rel=&quot;previous&quot;&gt;kill-region&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;up&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
8.3 &lt;code&gt;copy-region-as-kill&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-copy_002dregion_002das_002dkill-193&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-nthcdr-194&quot;&gt;&lt;/a&gt;
The &lt;code&gt;copy-region-as-kill&lt;/code&gt; function copies a region of text from a
buffer and (via either &lt;code&gt;kill-append&lt;/code&gt; or &lt;code&gt;kill-new&lt;/code&gt;) saves it
in the &lt;code&gt;kill-ring&lt;/code&gt;.

   &lt;br /&gt;
If you call &lt;code&gt;copy-region-as-kill&lt;/code&gt; immediately after a
&lt;code&gt;kill-region&lt;/code&gt; command, Emacs appends the newly copied text to the
previously copied text.  This means that if you yank back the text, you
get it all, from both this and the previous operation.  On the other
hand, if some other command precedes the &lt;code&gt;copy-region-as-kill&lt;/code&gt;,
the function copies the text into a separate entry in the kill ring.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-copy_002dregion_002das_002dkill&quot;&gt;Complete copy-region-as-kill&lt;/a&gt;:   The complete function definition. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill-body&quot;&gt;copy-region-as-kill body&lt;/a&gt;:       The body of &lt;code&gt;copy-region-as-kill&lt;/code&gt;. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Complete-copy-region-as-kill&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Complete-copy_002dregion_002das_002dkill&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill-body&quot; rel=&quot;next&quot;&gt;copy-region-as-kill body&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill&quot; rel=&quot;up&quot;&gt;copy-region-as-kill&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
The complete &lt;code&gt;copy-region-as-kill&lt;/code&gt; function definition&lt;/h4&gt;
Here is the complete text of the version 22 &lt;code&gt;copy-region-as-kill&lt;/code&gt;
function:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun copy-region-as-kill (beg end)
       &quot;Save the region as if killed, but don&#39;t kill it.
     In Transient Mark mode, deactivate the mark.
     If `interprogram-cut-function&#39; is non-nil, also save the text for a window
     system cut and paste.&quot;
       (interactive &quot;r&quot;)
       (if (eq last-command &#39;kill-region)
           (kill-append (filter-buffer-substring beg end) (&amp;lt; end beg))
         (kill-new (filter-buffer-substring beg end)))
       (if transient-mark-mode
           (setq deactivate-mark t))
       nil)
&lt;/pre&gt;
As usual, this function can be divided into its component parts:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun copy-region-as-kill (&lt;var&gt;argument-list&lt;/var&gt;)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       (interactive &quot;r&quot;)
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
The arguments are &lt;code&gt;beg&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; and the function is
interactive with &lt;code&gt;&quot;r&quot;&lt;/code&gt;, so the two arguments must refer to the
beginning and end of the region.  If you have been reading though this
document from the beginning, understanding these parts of a function is
almost becoming routine.

   &lt;br /&gt;
The documentation is somewhat confusing unless you remember that the
word `kill&#39; has a meaning different from usual.  The `Transient Mark&#39;
and &lt;code&gt;interprogram-cut-function&lt;/code&gt; comments explain certain
side-effects.

   &lt;br /&gt;
After you once set a mark, a buffer always contains a region.  If you
wish, you can use Transient Mark mode to highlight the region
temporarily.  (No one wants to highlight the region all the time, so
Transient Mark mode highlights it only at appropriate times.  Many
people turn off Transient Mark mode, so the region is never
highlighted.)

   &lt;br /&gt;
Also, a windowing system allows you to copy, cut, and paste among
different programs.  In the X windowing system, for example, the
&lt;code&gt;interprogram-cut-function&lt;/code&gt; function is &lt;code&gt;x-select-text&lt;/code&gt;,
which works with the windowing system&#39;s equivalent of the Emacs kill
ring.

   &lt;br /&gt;
The body of the &lt;code&gt;copy-region-as-kill&lt;/code&gt; function starts with an
&lt;code&gt;if&lt;/code&gt; clause.  What this clause does is distinguish between two
different situations: whether or not this command is executed
immediately after a previous &lt;code&gt;kill-region&lt;/code&gt; command.  In the first
case, the new region is appended to the previously copied text. 
Otherwise, it is inserted into the beginning of the kill ring as a
separate piece of text from the previous piece.

   &lt;br /&gt;
The last two lines of the function prevent the region from lighting up
if Transient Mark mode is turned on.

   &lt;br /&gt;
The body of &lt;code&gt;copy-region-as-kill&lt;/code&gt; merits discussion in detail.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;copy-region-as-kill-body&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;copy_002dregion_002das_002dkill-body&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Complete-copy_002dregion_002das_002dkill&quot; rel=&quot;previous&quot;&gt;Complete copy-region-as-kill&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill&quot; rel=&quot;up&quot;&gt;copy-region-as-kill&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
8.3.1 The Body of &lt;code&gt;copy-region-as-kill&lt;/code&gt;&lt;/h4&gt;
The &lt;code&gt;copy-region-as-kill&lt;/code&gt; function works in much the same way as
the &lt;code&gt;kill-region&lt;/code&gt; function.  Both are written so that two or more
kills in a row combine their text into a single entry.  If you yank
back the text from the kill ring, you get it all in one piece. 
Moreover, kills that kill forward from the current position of the
cursor are added to the end of the previously copied text and commands
that copy text backwards add it to the beginning of the previously
copied text.  This way, the words in the text stay in the proper
order.

   &lt;br /&gt;
Like &lt;code&gt;kill-region&lt;/code&gt;, the &lt;code&gt;copy-region-as-kill&lt;/code&gt; function makes
use of the &lt;code&gt;last-command&lt;/code&gt; variable that keeps track of the
previous Emacs command.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#last_002dcommand-_0026-this_002dcommand&quot;&gt;last-command &amp;amp; this-command&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dappend-function&quot;&gt;kill-append function&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dnew-function&quot;&gt;kill-new function&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;last-command-&amp;amp;-this-command&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;last_002dcommand-_0026-this_002dcommand&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dappend-function&quot; rel=&quot;next&quot;&gt;kill-append function&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill-body&quot; rel=&quot;up&quot;&gt;copy-region-as-kill body&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
&lt;code&gt;last-command&lt;/code&gt; and &lt;code&gt;this-command&lt;/code&gt;&lt;/h5&gt;
Normally, whenever a function is executed, Emacs sets the value of
&lt;code&gt;this-command&lt;/code&gt; to the function being executed (which in this case
would be &lt;code&gt;copy-region-as-kill&lt;/code&gt;).  At the same time, Emacs sets
the value of &lt;code&gt;last-command&lt;/code&gt; to the previous value of
&lt;code&gt;this-command&lt;/code&gt;.

   &lt;br /&gt;
In the first part of the body of the &lt;code&gt;copy-region-as-kill&lt;/code&gt;
function, an &lt;code&gt;if&lt;/code&gt; expression determines whether the value of
&lt;code&gt;last-command&lt;/code&gt; is &lt;code&gt;kill-region&lt;/code&gt;.  If so, the then-part of
the &lt;code&gt;if&lt;/code&gt; expression is evaluated; it uses the &lt;code&gt;kill-append&lt;/code&gt;
function to concatenate the text copied at this call to the function
with the text already in the first element (the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt;) of the kill
ring.  On the other hand, if the value of &lt;code&gt;last-command&lt;/code&gt; is not
&lt;code&gt;kill-region&lt;/code&gt;, then the &lt;code&gt;copy-region-as-kill&lt;/code&gt; function
attaches a new element to the kill ring using the &lt;code&gt;kill-new&lt;/code&gt;
function.

   &lt;br /&gt;
The &lt;code&gt;if&lt;/code&gt; expression reads as follows; it uses &lt;code&gt;eq&lt;/code&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;       (if (eq last-command &#39;kill-region)
           ;; &lt;span class=&quot;roman&quot;&gt;then-part&lt;/span&gt;
           (kill-append  (filter-buffer-substring beg end) (&amp;lt; end beg))
         ;; &lt;span class=&quot;roman&quot;&gt;else-part&lt;/span&gt;
         (kill-new  (filter-buffer-substring beg end)))
&lt;/pre&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-filter_002dbuffer_002dsubstring-195&quot;&gt;&lt;/a&gt;(The &lt;code&gt;filter-buffer-substring&lt;/code&gt; function returns a filtered
substring of the buffer, if any.  Optionally—the arguments are not
here, so neither is done—the function may delete the initial text or
return the text without its properties; this function is a replacement
for the older &lt;code&gt;buffer-substring&lt;/code&gt; function, which came before text
properties were implemented.)

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-eq-_0040r_007b_0028example-of-use_0029_007d-196&quot;&gt;&lt;/a&gt;The &lt;code&gt;eq&lt;/code&gt; function tests whether its first argument is the same Lisp
object as its second argument.  The &lt;code&gt;eq&lt;/code&gt; function is similar to the
&lt;code&gt;equal&lt;/code&gt; function in that it is used to test for equality, but
differs in that it determines whether two representations are actually
the same object inside the computer, but with different names. 
&lt;code&gt;equal&lt;/code&gt; determines whether the structure and contents of two
expressions are the same.

   &lt;br /&gt;
If the previous command was &lt;code&gt;kill-region&lt;/code&gt;, then the Emacs Lisp
interpreter calls the &lt;code&gt;kill-append&lt;/code&gt; function

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;kill-append-function&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;kill_002dappend-function&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dnew-function&quot; rel=&quot;next&quot;&gt;kill-new function&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#last_002dcommand-_0026-this_002dcommand&quot; rel=&quot;previous&quot;&gt;last-command &amp;amp; this-command&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill-body&quot; rel=&quot;up&quot;&gt;copy-region-as-kill body&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
The &lt;code&gt;kill-append&lt;/code&gt; function&lt;/h5&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-kill_002dappend-197&quot;&gt;&lt;/a&gt;
The &lt;code&gt;kill-append&lt;/code&gt; function looks like this:


&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun kill-append (string before-p &amp;amp;optional yank-handler)
       &quot;Append STRING to the end of the latest kill in the kill ring.
     If BEFORE-P is non-nil, prepend STRING to the kill.
     ... &quot;
       (let* ((cur (car kill-ring)))
         (kill-new (if before-p (concat string cur) (concat cur string))
                   (or (= (length cur) 0)
                       (equal yank-handler
                              (get-text-property 0 &#39;yank-handler cur)))
                   yank-handler)))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The &lt;code&gt;kill-append&lt;/code&gt; function is fairly straightforward.  It uses
the &lt;code&gt;kill-new&lt;/code&gt; function, which we will discuss in more detail in
a moment.

   &lt;/div&gt;
(Also, the function provides an optional argument called
&lt;code&gt;yank-handler&lt;/code&gt;; when invoked, this argument tells the function
how to deal with properties added to the text, such as `bold&#39; or
`italics&#39;.)


   &lt;br /&gt;
It has a &lt;code&gt;let*&lt;/code&gt; function to set the value of the first element of
the kill ring to &lt;code&gt;cur&lt;/code&gt;.  (I do not know why the function does not
use &lt;code&gt;let&lt;/code&gt; instead; only one value is set in the expression. 
Perhaps this is a bug that produces no problems?)

   &lt;br /&gt;
Consider the conditional that is one of the two arguments to
&lt;code&gt;kill-new&lt;/code&gt;.  It uses &lt;code&gt;concat&lt;/code&gt; to concatenate the new text to
the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of the kill ring.  Whether it prepends or appends the
text depends on the results of an &lt;code&gt;if&lt;/code&gt; expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if before-p                            ; &lt;span class=&quot;roman&quot;&gt;if-part&lt;/span&gt;
         (concat string cur)                 ; &lt;span class=&quot;roman&quot;&gt;then-part&lt;/span&gt;
       (concat cur string))                  ; &lt;span class=&quot;roman&quot;&gt;else-part&lt;/span&gt;
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If the region being killed is before the region that was killed in the
last command, then it should be prepended before the material that was
saved in the previous kill; and conversely, if the killed text follows
what was just killed, it should be appended after the previous text. 
The &lt;code&gt;if&lt;/code&gt; expression depends on the predicate &lt;code&gt;before-p&lt;/code&gt; to
decide whether the newly saved text should be put before or after the
previously saved text.

   &lt;/div&gt;
The symbol &lt;code&gt;before-p&lt;/code&gt; is the name of one of the arguments to
&lt;code&gt;kill-append&lt;/code&gt;.  When the &lt;code&gt;kill-append&lt;/code&gt; function is
evaluated, it is bound to the value returned by evaluating the actual
argument.  In this case, this is the expression &lt;code&gt;(&amp;lt; end beg)&lt;/code&gt;. 
This expression does not directly determine whether the killed text in
this command is located before or after the kill text of the last
command; what it does is determine whether the value of the variable
&lt;code&gt;end&lt;/code&gt; is less than the value of the variable &lt;code&gt;beg&lt;/code&gt;.  If it
is, it means that the user is most likely heading towards the
beginning of the buffer.  Also, the result of evaluating the predicate
expression, &lt;code&gt;(&amp;lt; end beg)&lt;/code&gt;, will be true and the text will be
prepended before the previous text.  On the other hand, if the value of
the variable &lt;code&gt;end&lt;/code&gt; is greater than the value of the variable
&lt;code&gt;beg&lt;/code&gt;, the text will be appended after the previous text.

   &lt;br /&gt;
When the newly saved text will be prepended, then the string with the new
text will be concatenated before the old text:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (concat string cur)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
But if the text will be appended, it will be concatenated
after the old text:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (concat cur string))
&lt;/pre&gt;
To understand how this works, we first need to review the
&lt;code&gt;concat&lt;/code&gt; function.  The &lt;code&gt;concat&lt;/code&gt; function links together or
unites two strings of text.  The result is a string.  For example:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (concat &quot;abc&quot; &quot;def&quot;)
          ⇒ &quot;abcdef&quot;
     
     (concat &quot;new &quot;
             (car &#39;(&quot;first element&quot; &quot;second element&quot;)))
          ⇒ &quot;new first element&quot;
     
     (concat (car
             &#39;(&quot;first element&quot; &quot;second element&quot;)) &quot; modified&quot;)
          ⇒ &quot;first element modified&quot;
&lt;/pre&gt;
We can now make sense of &lt;code&gt;kill-append&lt;/code&gt;: it modifies the contents
of the kill ring.  The kill ring is a list, each element of which is
saved text.  The &lt;code&gt;kill-append&lt;/code&gt; function uses the &lt;code&gt;kill-new&lt;/code&gt;
function which in turn uses the &lt;code&gt;setcar&lt;/code&gt; function.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;kill-new-function&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;kill_002dnew-function&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dappend-function&quot; rel=&quot;previous&quot;&gt;kill-append function&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill-body&quot; rel=&quot;up&quot;&gt;copy-region-as-kill body&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
The &lt;code&gt;kill-new&lt;/code&gt; function&lt;/h5&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-kill_002dnew-198&quot;&gt;&lt;/a&gt;

The &lt;code&gt;kill-new&lt;/code&gt; function looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun kill-new (string &amp;amp;optional replace yank-handler)
       &quot;Make STRING the latest kill in the kill ring.
     Set `kill-ring-yank-pointer&#39; to point to it.
     
     If `interprogram-cut-function&#39; is non-nil, apply it to STRING.
     Optional second argument REPLACE non-nil means that STRING will replace
     the front of the kill ring, rather than being added to the list.
     ...&quot;
       (if (&amp;gt; (length string) 0)
           (if yank-handler
               (put-text-property 0 (length string)
                                  &#39;yank-handler yank-handler string))
         (if yank-handler
             (signal &#39;args-out-of-range
                     (list string &quot;yank-handler specified for empty string&quot;))))
       (if (fboundp &#39;menu-bar-update-yank-menu)
           (menu-bar-update-yank-menu string (and replace (car kill-ring))))
       (if (and replace kill-ring)
           (setcar kill-ring string)
         (push string kill-ring)
         (if (&amp;gt; (length kill-ring) kill-ring-max)
             (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil)))
       (setq kill-ring-yank-pointer kill-ring)
       (if interprogram-cut-function
           (funcall interprogram-cut-function string (not replace))))
&lt;/pre&gt;
(Notice that the function is not interactive.)

   &lt;br /&gt;
As usual, we can look at this function in parts.

   &lt;br /&gt;
The function definition has an optional &lt;code&gt;yank-handler&lt;/code&gt; argument,
which when invoked tells the function how to deal with properties
added to the text, such as `bold&#39; or `italics&#39;.  We will skip that.

   &lt;br /&gt;
The first line of the documentation makes sense:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     Make STRING the latest kill in the kill ring.
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Let&#39;s skip over the rest of the documentation for the moment.

&lt;/div&gt;
&lt;div class=&quot;noindent&quot;&gt;
Also, let&#39;s skip over the initial &lt;code&gt;if&lt;/code&gt; expression and those lines
of code involving &lt;code&gt;menu-bar-update-yank-menu&lt;/code&gt;.  We will explain
them below.

   &lt;/div&gt;
The critical lines are these:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;       (if (and replace kill-ring)
           ;; &lt;span class=&quot;roman&quot;&gt;then&lt;/span&gt;
           (setcar kill-ring string)
         ;; &lt;span class=&quot;roman&quot;&gt;else&lt;/span&gt;
       (push string kill-ring)
         (setq kill-ring (cons string kill-ring))
         (if (&amp;gt; (length kill-ring) kill-ring-max)
             ;; &lt;span class=&quot;roman&quot;&gt;avoid overly long kill ring&lt;/span&gt;
             (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil)))
       (setq kill-ring-yank-pointer kill-ring)
       (if interprogram-cut-function
           (funcall interprogram-cut-function string (not replace))))
&lt;/pre&gt;
The conditional test is &lt;code&gt;(and&amp;nbsp;replace&amp;nbsp;kill-ring)&lt;/code&gt;. 
This will be true when two conditions are met:  the kill ring has
something in it, and the &lt;code&gt;replace&lt;/code&gt; variable is true.

   &lt;br /&gt;
When the &lt;code&gt;kill-append&lt;/code&gt; function sets &lt;code&gt;replace&lt;/code&gt; to be true
and when the kill ring has at least one item in it, the &lt;code&gt;setcar&lt;/code&gt;
expression is executed:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setcar kill-ring string)
&lt;/pre&gt;
The &lt;code&gt;setcar&lt;/code&gt; function actually changes the first element of the
&lt;code&gt;kill-ring&lt;/code&gt; list to the value of &lt;code&gt;string&lt;/code&gt;.  It replaces the
first element.

   &lt;br /&gt;
On the other hand, if the kill ring is empty, or replace is false, the
else-part of the condition is executed:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (push string kill-ring)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
&lt;code&gt;push&lt;/code&gt; puts its first argument onto the second.  It is similar to
the older

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq kill-ring (cons string kill-ring))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
or the newer

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (add-to-list kill-ring string)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When it is false, the expression first constructs a new version of the
kill ring by prepending &lt;code&gt;string&lt;/code&gt; to the existing kill ring as a
new element (that is what the &lt;code&gt;push&lt;/code&gt; does).  Then it executes a
second &lt;code&gt;if&lt;/code&gt; clause.  This second &lt;code&gt;if&lt;/code&gt; clause keeps the kill
ring from growing too long.

   &lt;/div&gt;
Let&#39;s look at these two expressions in order.

   &lt;br /&gt;
The &lt;code&gt;push&lt;/code&gt; line of the else-part sets the new value of the kill
ring to what results from adding the string being killed to the old
kill ring.

   &lt;br /&gt;
We can see how this works with an example.

   &lt;br /&gt;
First,

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq example-list &#39;(&quot;here is a clause&quot; &quot;another clause&quot;))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
After evaluating this expression with &lt;kbd&gt;C-x C-e&lt;/kbd&gt;, you can evaluate
&lt;code&gt;example-list&lt;/code&gt; and see what it returns:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     example-list
          ⇒ (&quot;here is a clause&quot; &quot;another clause&quot;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Now, we can add a new element on to this list by evaluating the
following expression:
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-push_002c-_0040r_007bexample_007d-199&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (push &quot;a third clause&quot; example-list)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When we evaluate &lt;code&gt;example-list&lt;/code&gt;, we find its value is:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     example-list
          ⇒ (&quot;a third clause&quot; &quot;here is a clause&quot; &quot;another clause&quot;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Thus, the third clause is added to the list by &lt;code&gt;push&lt;/code&gt;.

   &lt;/div&gt;
Now for the second part of the &lt;code&gt;if&lt;/code&gt; clause.  This expression
keeps the kill ring from growing too long.  It looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (if (&amp;gt; (length kill-ring) kill-ring-max)
         (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))
&lt;/pre&gt;
The code checks whether the length of the kill ring is greater than
the maximum permitted length.  This is the value of
&lt;code&gt;kill-ring-max&lt;/code&gt; (which is 60, by default).  If the length of the
kill ring is too long, then this code sets the last element of the
kill ring to &lt;code&gt;nil&lt;/code&gt;.  It does this by using two functions,
&lt;code&gt;nthcdr&lt;/code&gt; and &lt;code&gt;setcdr&lt;/code&gt;.

   &lt;br /&gt;
We looked at &lt;code&gt;setcdr&lt;/code&gt; earlier (see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcdr&quot;&gt;&lt;code&gt;setcdr&lt;/code&gt;&lt;/a&gt;). 
It sets the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of a list, just as &lt;code&gt;setcar&lt;/code&gt; sets the
&lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of a list.  In this case, however, &lt;code&gt;setcdr&lt;/code&gt; will not be
setting the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the whole kill ring; the &lt;code&gt;nthcdr&lt;/code&gt;
function is used to cause it to set the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the next to last
element of the kill ring—this means that since the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the
next to last element is the last element of the kill ring, it will set
the last element of the kill ring.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-nthcdr_002c-_0040r_007bexample_007d-200&quot;&gt;&lt;/a&gt;The &lt;code&gt;nthcdr&lt;/code&gt; function works by repeatedly taking the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of a
list—it takes the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt;
&lt;small class=&quot;dots&quot;&gt;...&lt;/small&gt;  It does this &lt;var&gt;N&lt;/var&gt; times and returns the results. 
(See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#nthcdr&quot;&gt;&lt;code&gt;nthcdr&lt;/code&gt;&lt;/a&gt;.)

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-setcdr_002c-_0040r_007bexample_007d-201&quot;&gt;&lt;/a&gt;Thus, if we had a four element list that was supposed to be three
elements long, we could set the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the next to last element
to &lt;code&gt;nil&lt;/code&gt;, and thereby shorten the list.  (If you set the last
element to some other value than &lt;code&gt;nil&lt;/code&gt;, which you could do, then
you would not have shortened the list.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#setcdr&quot;&gt;&lt;code&gt;setcdr&lt;/code&gt;&lt;/a&gt;.)

   &lt;br /&gt;
You can see shortening by evaluating the following three expressions
in turn.  First set the value of &lt;code&gt;trees&lt;/code&gt; to &lt;code&gt;(maple oak pine
birch)&lt;/code&gt;, then set the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of its second &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; to &lt;code&gt;nil&lt;/code&gt;
and then find the value of &lt;code&gt;trees&lt;/code&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq trees &#39;(maple oak pine birch))
          ⇒ (maple oak pine birch)
     
     (setcdr (nthcdr 2 trees) nil)
          ⇒ nil
     
     trees
          ⇒ (maple oak pine)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(The value returned by the &lt;code&gt;setcdr&lt;/code&gt; expression is &lt;code&gt;nil&lt;/code&gt; since
that is what the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; is set to.)

   &lt;/div&gt;
To repeat, in &lt;code&gt;kill-new&lt;/code&gt;, the &lt;code&gt;nthcdr&lt;/code&gt; function takes the
&lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; a number of times that is one less than the maximum permitted
size of the kill ring and &lt;code&gt;setcdr&lt;/code&gt; sets the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of that
element (which will be the rest of the elements in the kill ring) to
&lt;code&gt;nil&lt;/code&gt;.  This prevents the kill ring from growing too long.

   &lt;br /&gt;
The next to last expression in the &lt;code&gt;kill-new&lt;/code&gt; function is

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq kill-ring-yank-pointer kill-ring)
&lt;/pre&gt;
The &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; is a global variable that is set to be
the &lt;code&gt;kill-ring&lt;/code&gt;.

   &lt;br /&gt;
Even though the &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; is called a
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;pointer&lt;/span&gt;&lt;/samp&gt;’, it is a variable just like the kill ring.  However, the
name has been chosen to help humans understand how the variable is used.

   &lt;br /&gt;
Now, to return to an early expression in the body of the function:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;       (if (fboundp &#39;menu-bar-update-yank-menu)
            (menu-bar-update-yank-menu string (and replace (car kill-ring))))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
It starts with an &lt;code&gt;if&lt;/code&gt; expression

   &lt;/div&gt;
In this case, the expression tests first to see whether
&lt;code&gt;menu-bar-update-yank-menu&lt;/code&gt; exists as a function, and if so,
calls it.  The &lt;code&gt;fboundp&lt;/code&gt; function returns true if the symbol it
is testing has a function definition that `is not void&#39;.  If the
symbol&#39;s function definition were void, we would receive an error
message, as we did when we created errors intentionally (see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Making-Errors&quot;&gt;Generate an Error Message&lt;/a&gt;).

&lt;br /&gt;
&lt;div class=&quot;noindent&quot;&gt;
The then-part contains an expression whose first element is the
function &lt;code&gt;and&lt;/code&gt;.

   &lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-and-202&quot;&gt;&lt;/a&gt;The &lt;code&gt;and&lt;/code&gt; special form evaluates each of its arguments until one
of the arguments returns a value of &lt;code&gt;nil&lt;/code&gt;, in which case the
&lt;code&gt;and&lt;/code&gt; expression returns &lt;code&gt;nil&lt;/code&gt;; however, if none of the
arguments returns a value of &lt;code&gt;nil&lt;/code&gt;, the value resulting from
evaluating the last argument is returned.  (Since such a value is not
&lt;code&gt;nil&lt;/code&gt;, it is considered true in Emacs Lisp.)  In other words, an
&lt;code&gt;and&lt;/code&gt; expression returns a true value only if all its arguments
are true.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Second-Buffer-Related-Review&quot;&gt;Second Buffer Related Review&lt;/a&gt;.)

   &lt;br /&gt;
The expression determines whether the second argument to
&lt;code&gt;menu-bar-update-yank-menu&lt;/code&gt; is true or not.

   &lt;br /&gt;
&lt;code&gt;menu-bar-update-yank-menu&lt;/code&gt; is one of the functions that make it
possible to use the `Select and Paste&#39; menu in the Edit item of a menu
bar; using a mouse, you can look at the various pieces of text you
have saved and select one piece to paste.

   &lt;br /&gt;
The last expression in the &lt;code&gt;kill-new&lt;/code&gt; function adds the newly
copied string to whatever facility exists for copying and pasting
among different programs running in a windowing system.  In the X
Windowing system, for example, the &lt;code&gt;x-select-text&lt;/code&gt; function takes
the string and stores it in memory operated by X.  You can paste the
string in another program, such as an Xterm.

   &lt;br /&gt;
The expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;       (if interprogram-cut-function
           (funcall interprogram-cut-function string (not replace))))
&lt;/pre&gt;
If an &lt;code&gt;interprogram-cut-function&lt;/code&gt; exists, then Emacs executes
&lt;code&gt;funcall&lt;/code&gt;, which in turn calls its first argument as a function
and passes the remaining arguments to it.  (Incidentally, as far as I
can see, this &lt;code&gt;if&lt;/code&gt; expression could be replaced by an &lt;code&gt;and&lt;/code&gt;
expression similar to the one in the first part of the function.)

   &lt;br /&gt;
We are not going to discuss windowing systems and other programs
further, but merely note that this is a mechanism that enables GNU
Emacs to work easily and well with other programs.

   &lt;br /&gt;
This code for placing text in the kill ring, either concatenated with
an existing element or as a new element, leads us to the code for
bringing back text that has been cut out of the buffer—the yank
commands.  However, before discussing the yank commands, it is better
to learn how lists are implemented in a computer.  This will make
clear such mysteries as the use of the term `pointer&#39;.  But before
that, we will digress into C.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Digression-into-C&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defvar&quot; rel=&quot;next&quot;&gt;defvar&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill&quot; rel=&quot;previous&quot;&gt;copy-region-as-kill&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;up&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
8.4 Digression into C&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-delete_002dand_002dextract_002dregion-203&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-C_002c-a-digression-into-204&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Digression-into-C-205&quot;&gt;&lt;/a&gt;
The &lt;code&gt;copy-region-as-kill&lt;/code&gt; function (see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#copy_002dregion_002das_002dkill&quot;&gt;&lt;code&gt;copy-region-as-kill&lt;/code&gt;&lt;/a&gt;) uses the &lt;code&gt;filter-buffer-substring&lt;/code&gt;
function, which in turn uses the &lt;code&gt;delete-and-extract-region&lt;/code&gt;
function.  It removes the contents of a region and you cannot get them
back.

   &lt;br /&gt;
Unlike the other code discussed here, the
&lt;code&gt;delete-and-extract-region&lt;/code&gt; function is not written in Emacs
Lisp; it is written in C and is one of the primitives of the GNU Emacs
system.  Since it is very simple, I will digress briefly from Lisp and
describe it here.



   &lt;br /&gt;
Like many of the other Emacs primitives,
&lt;code&gt;delete-and-extract-region&lt;/code&gt; is written as an instance of a C
macro, a macro being a template for code.  The complete macro looks
like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     DEFUN (&quot;delete-and-extract-region&quot;, Fdelete_and_extract_region,
            Sdelete_and_extract_region, 2, 2, 0,
            doc: /* Delete the text between START and END and return it.  */)
            (Lisp_Object start, Lisp_Object end)
     {
       validate_region (&amp;amp;start, &amp;amp;end);
       if (XINT (start) == XINT (end))
         return empty_unibyte_string;
       return del_range_1 (XINT (start), XINT (end), 1, 1);
     }
&lt;/pre&gt;
Without going into the details of the macro writing process, let me
point out that this macro starts with the word &lt;code&gt;DEFUN&lt;/code&gt;.  The word
&lt;code&gt;DEFUN&lt;/code&gt; was chosen since the code serves the same purpose as
&lt;code&gt;defun&lt;/code&gt; does in Lisp.  (The &lt;code&gt;DEFUN&lt;/code&gt; C macro is defined in
&lt;samp&gt;&lt;span class=&quot;file&quot;&gt;emacs/src/lisp.h&lt;/span&gt;&lt;/samp&gt;.)

   &lt;br /&gt;
The word &lt;code&gt;DEFUN&lt;/code&gt; is followed by seven parts inside of
parentheses:

     &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The first part is the name given to the function in Lisp,
&lt;code&gt;delete-and-extract-region&lt;/code&gt;.

     &lt;/li&gt;
&lt;li&gt;The second part is the name of the function in C,
&lt;code&gt;Fdelete_and_extract_region&lt;/code&gt;.  By convention, it starts with
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;F&lt;/span&gt;&lt;/samp&gt;’.  Since C does not use hyphens in names, underscores are used
instead.

     &lt;/li&gt;
&lt;li&gt;The third part is the name for the C constant structure that records
information on this function for internal use.  It is the name of the
function in C but begins with an ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;S&lt;/span&gt;&lt;/samp&gt;’ instead of an ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;F&lt;/span&gt;&lt;/samp&gt;’.

     &lt;/li&gt;
&lt;li&gt;The fourth and fifth parts specify the minimum and maximum number of
arguments the function can have.  This function demands exactly 2
arguments.

     &lt;/li&gt;
&lt;li&gt;The sixth part is nearly like the argument that follows the
&lt;code&gt;interactive&lt;/code&gt; declaration in a function written in Lisp: a letter
followed, perhaps, by a prompt.  The only difference from the Lisp is
when the macro is called with no arguments.  Then you write a &lt;code&gt;0&lt;/code&gt;
(which is a `null string&#39;), as in this macro.

     If you were to specify arguments, you would place them between
quotation marks.  The C macro for &lt;code&gt;goto-char&lt;/code&gt; includes
&lt;code&gt;&quot;NGoto char: &quot;&lt;/code&gt; in this position to indicate that the function
expects a raw prefix, in this case, a numerical location in a buffer,
and provides a prompt.

     &lt;/li&gt;
&lt;li&gt;The seventh part is a documentation string, just like the one for a
function written in Emacs Lisp.  This is written as a C comment.  (When
you build Emacs, the program &lt;samp&gt;&lt;span class=&quot;command&quot;&gt;lib-src/make-docfile&lt;/span&gt;&lt;/samp&gt; extracts
these comments and uses them to make the “real” documentation.) 
&lt;/li&gt;
&lt;/ul&gt;
In a C macro, the formal parameters come next, with a statement of
what kind of object they are, followed by what might be called the `body&#39;
of the macro.  For &lt;code&gt;delete-and-extract-region&lt;/code&gt; the `body&#39;
consists of the following four lines:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     validate_region (&amp;amp;start, &amp;amp;end);
     if (XINT (start) == XINT (end))
       return empty_unibyte_string;
     return del_range_1 (XINT (start), XINT (end), 1, 1);
&lt;/pre&gt;
The &lt;code&gt;validate_region&lt;/code&gt; function checks whether the values
passed as the beginning and end of the region are the proper type and
are within range.  If the beginning and end positions are the same,
then return an empty string.

   &lt;br /&gt;
The &lt;code&gt;del_range_1&lt;/code&gt; function actually deletes the text.  It is a
complex function we will not look into.  It updates the buffer and
does other things.  However, it is worth looking at the two arguments
passed to &lt;code&gt;del_range&lt;/code&gt;.  These are &lt;code&gt;XINT&amp;nbsp;(start)&lt;/code&gt; and
&lt;code&gt;XINT&amp;nbsp;(end)&lt;/code&gt;.

   &lt;br /&gt;
As far as the C language is concerned, &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; are
two integers that mark the beginning and end of the region to be
deleted&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-10&quot; name=&quot;fnd-10&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;10&lt;/sup&gt;&lt;/a&gt;.

   &lt;br /&gt;
In early versions of Emacs, these two numbers were thirty-two bits
long, but the code is slowly being generalized to handle other
lengths.  Three of the available bits are used to specify the type of
information; the remaining bits are used as `content&#39;.

   &lt;br /&gt;
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;XINT&lt;/span&gt;&lt;/samp&gt;’ is a C macro that extracts the relevant number from the
longer collection of bits; the three other bits are discarded.

   &lt;br /&gt;
The command in &lt;code&gt;delete-and-extract-region&lt;/code&gt; looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     del_range_1 (XINT (start), XINT (end), 1, 1);
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
It deletes the region between the beginning position, &lt;code&gt;start&lt;/code&gt;,
and the ending position, &lt;code&gt;end&lt;/code&gt;.

   &lt;/div&gt;
From the point of view of the person writing Lisp, Emacs is all very
simple; but hidden underneath is a great deal of complexity to make it
all work.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;defvar&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons-_0026-search_002dfwd-Review&quot; rel=&quot;next&quot;&gt;cons &amp;amp; search-fwd Review&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Digression-into-C&quot; rel=&quot;previous&quot;&gt;Digression into C&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;up&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
8.5 Initializing a Variable with &lt;code&gt;defvar&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-defvar-206&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Initializing-a-variable-207&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Variable-initialization-208&quot;&gt;&lt;/a&gt;

   &lt;br /&gt;
The &lt;code&gt;copy-region-as-kill&lt;/code&gt; function is written in Emacs Lisp.  Two
functions within it, &lt;code&gt;kill-append&lt;/code&gt; and &lt;code&gt;kill-new&lt;/code&gt;, copy a
region in a buffer and save it in a variable called the
&lt;code&gt;kill-ring&lt;/code&gt;.  This section describes how the &lt;code&gt;kill-ring&lt;/code&gt;
variable is created and initialized using the &lt;code&gt;defvar&lt;/code&gt; special
form.

   &lt;br /&gt;
(Again we note that the term &lt;code&gt;kill-ring&lt;/code&gt; is a misnomer.  The text
that is clipped out of the buffer can be brought back; it is not a ring
of corpses, but a ring of resurrectable text.)

   &lt;br /&gt;
In Emacs Lisp, a variable such as the &lt;code&gt;kill-ring&lt;/code&gt; is created and
given an initial value by using the &lt;code&gt;defvar&lt;/code&gt; special form.  The
name comes from “define variable”.

   &lt;br /&gt;
The &lt;code&gt;defvar&lt;/code&gt; special form is similar to &lt;code&gt;setq&lt;/code&gt; in that it sets
the value of a variable.  It is unlike &lt;code&gt;setq&lt;/code&gt; in two ways: first,
it only sets the value of the variable if the variable does not already
have a value.  If the variable already has a value, &lt;code&gt;defvar&lt;/code&gt; does
not override the existing value.  Second, &lt;code&gt;defvar&lt;/code&gt; has a
documentation string.

   &lt;br /&gt;
(Another special form, &lt;code&gt;defcustom&lt;/code&gt;, is designed for variables
that people customize.  It has more features than &lt;code&gt;defvar&lt;/code&gt;. 
(See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defcustom&quot;&gt;Setting Variables with &lt;code&gt;defcustom&lt;/code&gt;&lt;/a&gt;.)

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#See-variable-current-value&quot;&gt;See variable current value&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defvar-and-asterisk&quot;&gt;defvar and asterisk&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;See-variable-current-value&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defvar-and-asterisk&quot; rel=&quot;next&quot;&gt;defvar and asterisk&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defvar&quot; rel=&quot;up&quot;&gt;defvar&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
Seeing the Current Value of a Variable&lt;/h4&gt;
You can see the current value of a variable, any variable, by using
the &lt;code&gt;describe-variable&lt;/code&gt; function, which is usually invoked by
typing &lt;kbd&gt;C-h v&lt;/kbd&gt;.  If you type &lt;kbd&gt;C-h v&lt;/kbd&gt; and then &lt;code&gt;kill-ring&lt;/code&gt;
(followed by &amp;lt;RET&amp;gt;) when prompted, you will see what is in your
current kill ring—this may be quite a lot!  Conversely, if you have
been doing nothing this Emacs session except read this document, you
may have nothing in it.  Also, you will see the documentation for
&lt;code&gt;kill-ring&lt;/code&gt;:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     Documentation:
     List of killed text sequences.
     Since the kill ring is supposed to interact nicely with cut-and-paste
     facilities offered by window systems, use of this variable should
     interact nicely with `interprogram-cut-function&#39; and
     `interprogram-paste-function&#39;.  The functions `kill-new&#39;,
     `kill-append&#39;, and `current-kill&#39; are supposed to implement this
     interaction; you may want to use them instead of manipulating the kill
     ring directly.
&lt;/pre&gt;
The kill ring is defined by a &lt;code&gt;defvar&lt;/code&gt; in the following way:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defvar kill-ring nil
       &quot;List of killed text sequences.
     ...&quot;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
In this variable definition, the variable is given an initial value of
&lt;code&gt;nil&lt;/code&gt;, which makes sense, since if you have saved nothing, you want
nothing back if you give a &lt;code&gt;yank&lt;/code&gt; command.  The documentation
string is written just like the documentation string of a &lt;code&gt;defun&lt;/code&gt;. 
As with the documentation string of the &lt;code&gt;defun&lt;/code&gt;, the first line of
the documentation should be a complete sentence, since some commands,
like &lt;code&gt;apropos&lt;/code&gt;, print only the first line of documentation. 
Succeeding lines should not be indented; otherwise they look odd when
you use &lt;kbd&gt;C-h v&lt;/kbd&gt; (&lt;code&gt;describe-variable&lt;/code&gt;).

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;defvar-and-asterisk&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#See-variable-current-value&quot; rel=&quot;previous&quot;&gt;See variable current value&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defvar&quot; rel=&quot;up&quot;&gt;defvar&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
8.5.1 &lt;code&gt;defvar&lt;/code&gt; and an asterisk&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-defvar-_0040r_007bfor-a-user-customizable-variable_007d-209&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-defvar-_0040r_007bwith-an-asterisk_007d-210&quot;&gt;&lt;/a&gt;
In the past, Emacs used the &lt;code&gt;defvar&lt;/code&gt; special form both for
internal variables that you would not expect a user to change and for
variables that you do expect a user to change.  Although you can still
use &lt;code&gt;defvar&lt;/code&gt; for user customizable variables, please use
&lt;code&gt;defcustom&lt;/code&gt; instead, since that special form provides a path into
the Customization commands.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defcustom&quot;&gt;Specifying Variables using &lt;code&gt;defcustom&lt;/code&gt;&lt;/a&gt;.)

   &lt;br /&gt;
When you specified a variable using the &lt;code&gt;defvar&lt;/code&gt; special form,
you could distinguish a variable that a user might want to change from
others by typing an asterisk, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;*&lt;/span&gt;&lt;/samp&gt;’, in the first column of its
documentation string.  For example:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defvar shell-command-default-error-buffer nil
       &quot;*Buffer name for `shell-command&#39; ... error output.
     ... &quot;)
&lt;/pre&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-set_002dvariable-211&quot;&gt;&lt;/a&gt;You could (and still can) use the &lt;code&gt;set-variable&lt;/code&gt; command to
change the value of &lt;code&gt;shell-command-default-error-buffer&lt;/code&gt;
temporarily.  However, options set using &lt;code&gt;set-variable&lt;/code&gt; are set
only for the duration of your editing session.  The new values are not
saved between sessions.  Each time Emacs starts, it reads the original
value, unless you change the value within your &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.emacs&lt;/span&gt;&lt;/samp&gt; file,
either by setting it manually or by using &lt;code&gt;customize&lt;/code&gt;. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Emacs-Initialization&quot;&gt;Your &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.emacs&lt;/span&gt;&lt;/samp&gt; File&lt;/a&gt;.

   &lt;br /&gt;
For me, the major use of the &lt;code&gt;set-variable&lt;/code&gt; command is to suggest
variables that I might want to set in my &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;.emacs&lt;/span&gt;&lt;/samp&gt; file.  There
are now more than 700 such variables, far too many to remember
readily.  Fortunately, you can press &amp;lt;TAB&amp;gt; after calling the
&lt;code&gt;M-x set-variable&lt;/code&gt; command to see the list of variables. 
(See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Examining&quot;&gt;Examining and Setting Variables&lt;/a&gt;.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;cons-&amp;amp;-search-fwd-Review&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;cons-_0026-search_002dfwd-Review&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#search-Exercises&quot; rel=&quot;next&quot;&gt;search Exercises&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#defvar&quot; rel=&quot;previous&quot;&gt;defvar&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;up&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
8.6 Review&lt;/h3&gt;
Here is a brief summary of some recently introduced functions.

     &lt;br /&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;car&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;cdr&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;code&gt;car&lt;/code&gt; returns the first element of a list; &lt;code&gt;cdr&lt;/code&gt; returns the
second and subsequent elements of a list.

     For example:

     &lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;          (car &#39;(1 2 3 4 5 6 7))
               ⇒ 1
          (cdr &#39;(1 2 3 4 5 6 7))
               ⇒ (2 3 4 5 6 7)
&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;cons&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;code&gt;cons&lt;/code&gt; constructs a list by prepending its first argument to its
second argument.

     For example:

     &lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;          (cons 1 &#39;(2 3 4))
               ⇒ (1 2 3 4)
&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;funcall&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;code&gt;funcall&lt;/code&gt; evaluates its first argument as a function.  It passes
its remaining arguments to its first argument.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;nthcdr&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Return the result of taking &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; `n&#39; times on a list. 
The `rest of the rest&#39;, as it were.

     For example:

     &lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;          (nthcdr 3 &#39;(1 2 3 4 5 6 7))
               ⇒ (4 5 6 7)
&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;setcar&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;setcdr&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;code&gt;setcar&lt;/code&gt; changes the first element of a list; &lt;code&gt;setcdr&lt;/code&gt;
changes the second and subsequent elements of a list.

     For example:

     &lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;          (setq triple &#39;(1 2 3))
          
          (setcar triple &#39;37)
          
          triple
               ⇒ (37 2 3)
          
          (setcdr triple &#39;(&quot;foo&quot; &quot;bar&quot;))
          
          triple
               ⇒ (37 &quot;foo&quot; &quot;bar&quot;)
&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;progn&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Evaluate each argument in sequence and then return the value of the
last.

     For example:

     &lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;          (progn 1 2 3 4)
               ⇒ 4
&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;save-restriction&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Record whatever narrowing is in effect in the current buffer, if any,
and restore that narrowing after evaluating the arguments.

     &lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;search-forward&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Search for a string, and if the string is found, move point.  With a
regular expression, use the similar &lt;code&gt;re-search-forward&lt;/code&gt;. 
(See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Regexp-Search&quot;&gt;Regular Expression Searches&lt;/a&gt;, for an
explanation of regular expression patterns and searches.)

     &lt;div class=&quot;noindent&quot;&gt;
&lt;code&gt;search-forward&lt;/code&gt; and &lt;code&gt;re-search-forward&lt;/code&gt; take four
arguments:

          &lt;/div&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li&gt;The string or regular expression to search for.

          &lt;/li&gt;
&lt;li&gt;Optionally, the limit of the search.

          &lt;/li&gt;
&lt;li&gt;Optionally, what to do if the search fails, return &lt;code&gt;nil&lt;/code&gt; or an
error message.

          &lt;/li&gt;
&lt;li&gt;Optionally, how many times to repeat the search; if negative, the
search goes backwards.
          &lt;/li&gt;
&lt;/ol&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;kill-region&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;delete-and-extract-region&lt;/code&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;code&gt;copy-region-as-kill&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;
&lt;code&gt;kill-region&lt;/code&gt; cuts the text between point and mark from the
buffer and stores that text in the kill ring, so you can get it back
by yanking.

     &lt;code&gt;copy-region-as-kill&lt;/code&gt; copies the text between point and mark into
the kill ring, from which you can get it by yanking.  The function
does not cut or remove the text from the buffer. 
&lt;/dd&gt;&lt;/dl&gt;
&lt;code&gt;delete-and-extract-region&lt;/code&gt; removes the text between point and
mark from the buffer and throws it away.  You cannot get it back. 
(This is not an interactive command.)

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;search-Exercises&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#cons-_0026-search_002dfwd-Review&quot; rel=&quot;previous&quot;&gt;cons &amp;amp; search-fwd Review&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;up&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
8.7 Searching Exercises&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Write an interactive function that searches for a string.  If the
search finds the string, leave point after it and display a message
that says “Found!”.  (Do not use &lt;code&gt;search-forward&lt;/code&gt; for the name
of this function; if you do, you will overwrite the existing version of
&lt;code&gt;search-forward&lt;/code&gt; that comes with Emacs.  Use a name such as
&lt;code&gt;test-search&lt;/code&gt; instead.)

     &lt;/li&gt;
&lt;li&gt;Write a function that prints the third element of the kill ring in the
echo area, if any; if the kill ring does not contain a third element,
print an appropriate message. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;List-Implementation&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Yanking&quot; rel=&quot;next&quot;&gt;Yanking&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Cutting-_0026-Storing-Text&quot; rel=&quot;previous&quot;&gt;Cutting &amp;amp; Storing Text&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
9 How Lists are Implemented&lt;/h2&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Lists-in-a-computer-212&quot;&gt;&lt;/a&gt;
In Lisp, atoms are recorded in a straightforward fashion; if the
implementation is not straightforward in practice, it is, nonetheless,
straightforward in theory.  The atom ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;rose&lt;/span&gt;&lt;/samp&gt;’, for example, is
recorded as the four contiguous letters ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;r&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;o&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;s&lt;/span&gt;&lt;/samp&gt;’,
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;e&lt;/span&gt;&lt;/samp&gt;’.  A list, on the other hand, is kept differently.  The mechanism
is equally simple, but it takes a moment to get used to the idea.  A
list is kept using a series of pairs of pointers.  In the series, the
first pointer in each pair points to an atom or to another list, and the
second pointer in each pair points to the next pair, or to the symbol
&lt;code&gt;nil&lt;/code&gt;, which marks the end of the list.

   &lt;br /&gt;
A pointer itself is quite simply the electronic address of what is
pointed to.  Hence, a list is kept as a series of electronic addresses.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lists-diagrammed&quot;&gt;Lists diagrammed&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Symbols-as-Chest&quot;&gt;Symbols as Chest&lt;/a&gt;:             Exploring a powerful metaphor. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Exercise&quot;&gt;List Exercise&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Lists-diagrammed&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Symbols-as-Chest&quot; rel=&quot;next&quot;&gt;Symbols as Chest&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Implementation&quot; rel=&quot;up&quot;&gt;List Implementation&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;unnumberedsec&quot;&gt;
Lists diagrammed&lt;/h3&gt;
For example, the list &lt;code&gt;(rose violet buttercup)&lt;/code&gt; has three elements,
‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;rose&lt;/span&gt;&lt;/samp&gt;’, ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;violet&lt;/span&gt;&lt;/samp&gt;’, and ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;buttercup&lt;/span&gt;&lt;/samp&gt;’.  In the computer, the
electronic address of ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;rose&lt;/span&gt;&lt;/samp&gt;’ is recorded in a segment of computer
memory along with the address that gives the electronic address of where
the atom ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;violet&lt;/span&gt;&lt;/samp&gt;’ is located; and that address (the one that tells
where ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;violet&lt;/span&gt;&lt;/samp&gt;’ is located) is kept along with an address that tells
where the address for the atom ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;buttercup&lt;/span&gt;&lt;/samp&gt;’ is located.

   &lt;br /&gt;
This sounds more complicated than it is and is easier seen in a diagram:



&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;         ___ ___      ___ ___      ___ ___
        |___|___|--&amp;gt; |___|___|--&amp;gt; |___|___|--&amp;gt; nil
          |            |            |
          |            |            |
           --&amp;gt; rose     --&amp;gt; violet   --&amp;gt; buttercup
&lt;/pre&gt;
In the diagram, each box represents a word of computer memory that
holds a Lisp object, usually in the form of a memory address.  The boxes,
i.e., the addresses, are in pairs.  Each arrow points to what the address
is the address of, either an atom or another pair of addresses.  The
first box is the electronic address of ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;rose&lt;/span&gt;&lt;/samp&gt;’ and the arrow points
to ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;rose&lt;/span&gt;&lt;/samp&gt;’; the second box is the address of the next pair of boxes,
the first part of which is the address of ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;violet&lt;/span&gt;&lt;/samp&gt;’ and the second
part of which is the address of the next pair.  The very last box
points to the symbol &lt;code&gt;nil&lt;/code&gt;, which marks the end of the list.

   When a variable is set to a list with a function such as &lt;code&gt;setq&lt;/code&gt;,
it stores the address of the first box in the variable.  Thus,
evaluation of the expression

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq bouquet &#39;(rose violet buttercup))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
creates a situation like this:


&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     bouquet
          |
          |     ___ ___      ___ ___      ___ ___
           --&amp;gt; |___|___|--&amp;gt; |___|___|--&amp;gt; |___|___|--&amp;gt; nil
                 |            |            |
                 |            |            |
                  --&amp;gt; rose     --&amp;gt; violet   --&amp;gt; buttercup
&lt;/pre&gt;
In this example, the symbol &lt;code&gt;bouquet&lt;/code&gt; holds the address of the first
pair of boxes.

   This same list can be illustrated in a different sort of box notation
like this:


&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     bouquet
      |
      |    --------------       ---------------       ----------------
      |   | car   | cdr  |     | car    | cdr  |     | car     | cdr  |
       --&amp;gt;| rose  |   o-------&amp;gt;| violet |   o-------&amp;gt;| butter- |  nil |
          |       |      |     |        |      |     | cup     |      |
           --------------       ---------------       ----------------
&lt;/pre&gt;
(Symbols consist of more than pairs of addresses, but the structure of
a symbol is made up of addresses.  Indeed, the symbol &lt;code&gt;bouquet&lt;/code&gt;
consists of a group of address-boxes, one of which is the address of
the printed word ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;bouquet&lt;/span&gt;&lt;/samp&gt;’, a second of which is the address of a
function definition attached to the symbol, if any, a third of which
is the address of the first pair of address-boxes for the list
&lt;code&gt;(rose violet buttercup)&lt;/code&gt;, and so on.  Here we are showing that
the symbol&#39;s third address-box points to the first pair of
address-boxes for the list.)

   If a symbol is set to the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of a list, the list itself is not
changed; the symbol simply has an address further down the list.  (In
the jargon, &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; and &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; are `non-destructive&#39;.)  Thus,
evaluation of the following expression

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq flowers (cdr bouquet))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
produces this:


   &lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     bouquet        flowers
       |              |
       |     ___ ___  |     ___ ___      ___ ___
        --&amp;gt; |   |   |  --&amp;gt; |   |   |    |   |   |
            |___|___|----&amp;gt; |___|___|--&amp;gt; |___|___|--&amp;gt; nil
              |              |            |
              |              |            |
               --&amp;gt; rose       --&amp;gt; violet   --&amp;gt; buttercup
&lt;/pre&gt;
The value of &lt;code&gt;flowers&lt;/code&gt; is &lt;code&gt;(violet buttercup)&lt;/code&gt;, which is
to say, the symbol &lt;code&gt;flowers&lt;/code&gt; holds the address of the pair of
address-boxes, the first of which holds the address of &lt;code&gt;violet&lt;/code&gt;,
and the second of which holds the address of &lt;code&gt;buttercup&lt;/code&gt;.

   A pair of address-boxes is called a &lt;dfn&gt;cons cell&lt;/dfn&gt; or &lt;dfn&gt;dotted
pair&lt;/dfn&gt;.  See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Cons-Cell-Type&quot;&gt;Cons Cell and List Types&lt;/a&gt;, and &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Dotted-Pair-Notation&quot;&gt;Dotted Pair Notation&lt;/a&gt;, for more
information about cons cells and dotted pairs.

   &lt;br /&gt;
The function &lt;code&gt;cons&lt;/code&gt; adds a new pair of addresses to the front of
a series of addresses like that shown above.  For example, evaluating
the expression

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq bouquet (cons &#39;lily bouquet))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
produces:


   &lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     bouquet                       flowers
       |                             |
       |     ___ ___        ___ ___  |     ___ ___       ___ ___
        --&amp;gt; |   |   |      |   |   |  --&amp;gt; |   |   |     |   |   |
            |___|___|----&amp;gt; |___|___|----&amp;gt; |___|___|----&amp;gt;|___|___|--&amp;gt; nil
              |              |              |             |
              |              |              |             |
               --&amp;gt; lily      --&amp;gt; rose       --&amp;gt; violet    --&amp;gt; buttercup
&lt;/pre&gt;
However, this does not change the value of the symbol
&lt;code&gt;flowers&lt;/code&gt;, as you can see by evaluating the following,

&lt;pre class=&quot;smallexample&quot;&gt;     (eq (cdr (cdr bouquet)) flowers)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
which returns &lt;code&gt;t&lt;/code&gt; for true.

   &lt;/div&gt;
Until it is reset, &lt;code&gt;flowers&lt;/code&gt; still has the value
&lt;code&gt;(violet buttercup)&lt;/code&gt;; that is, it has the address of the cons
cell whose first address is of &lt;code&gt;violet&lt;/code&gt;.  Also, this does not
alter any of the pre-existing cons cells; they are all still there.

   &lt;br /&gt;
Thus, in Lisp, to get the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of a list, you just get the address
of the next cons cell in the series; to get the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of a list,
you get the address of the first element of the list; to &lt;code&gt;cons&lt;/code&gt; a
new element on a list, you add a new cons cell to the front of the list. 
That is all there is to it!  The underlying structure of Lisp is
brilliantly simple!

   &lt;br /&gt;
And what does the last address in a series of cons cells refer to?  It
is the address of the empty list, of &lt;code&gt;nil&lt;/code&gt;.

   &lt;br /&gt;
In summary, when a Lisp variable is set to a value, it is provided with
the address of the list to which the variable refers.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Symbols-as-Chest&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Exercise&quot; rel=&quot;next&quot;&gt;List Exercise&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Lists-diagrammed&quot; rel=&quot;previous&quot;&gt;Lists diagrammed&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Implementation&quot; rel=&quot;up&quot;&gt;List Implementation&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
9.1 Symbols as a Chest of Drawers&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Symbols-as-a-Chest-of-Drawers-213&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Chest-of-Drawers_002c-metaphor-for-a-symbol-214&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Drawers_002c-Chest-of_002c-metaphor-for-a-symbol-215&quot;&gt;&lt;/a&gt;
In an earlier section, I suggested that you might imagine a symbol as
being a chest of drawers.  The function definition is put in one
drawer, the value in another, and so on.  What is put in the drawer
holding the value can be changed without affecting the contents of the
drawer holding the function definition, and vice-verse.

   &lt;br /&gt;
Actually, what is put in each drawer is the address of the value or
function definition.  It is as if you found an old chest in the attic,
and in one of its drawers you found a map giving you directions to
where the buried treasure lies.

   &lt;br /&gt;
(In addition to its name, symbol definition, and variable value, a
symbol has a `drawer&#39; for a &lt;dfn&gt;property list&lt;/dfn&gt; which can be used to
record other information.  Property lists are not discussed here; see
&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Property-Lists&quot;&gt;Property Lists&lt;/a&gt;.)

   &lt;br /&gt;
Here is a fanciful representation:


   &lt;br /&gt;

&lt;pre class=&quot;smallexample&quot;&gt;                 Chest of Drawers            Contents of Drawers
     
                 __   o0O0o   __
               /                 \
              ---------------------
             |    directions to    |            [map to]
             |     symbol name     |             bouquet
             |                     |
             +---------------------+
             |    directions to    |
             |  symbol definition  |             [none]
             |                     |
             +---------------------+
             |    directions to    |            [map to]
             |    variable value   |             (rose violet buttercup)
             |                     |
             +---------------------+
             |    directions to    |
             |    property list    |             [not described here]
             |                     |
             +---------------------+
             |/                   \|
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;List-Exercise&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Symbols-as-Chest&quot; rel=&quot;previous&quot;&gt;Symbols as Chest&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Implementation&quot; rel=&quot;up&quot;&gt;List Implementation&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
9.2 Exercise&lt;/h3&gt;
Set &lt;code&gt;flowers&lt;/code&gt; to &lt;code&gt;violet&lt;/code&gt; and &lt;code&gt;buttercup&lt;/code&gt;.  Cons two
more flowers on to this list and set this new list to
&lt;code&gt;more-flowers&lt;/code&gt;.  Set the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of &lt;code&gt;flowers&lt;/code&gt; to a fish. 
What does the &lt;code&gt;more-flowers&lt;/code&gt; list now contain?

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Yanking&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loops-_0026-Recursion&quot; rel=&quot;next&quot;&gt;Loops &amp;amp; Recursion&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Implementation&quot; rel=&quot;previous&quot;&gt;List Implementation&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
10 Yanking Text Back&lt;/h2&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-yank-216&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Text-retrieval-217&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Retrieving-text-218&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Pasting-text-219&quot;&gt;&lt;/a&gt;
Whenever you cut text out of a buffer with a `kill&#39; command in GNU Emacs,
you can bring it back with a `yank&#39; command.  The text that is cut out of
the buffer is put in the kill ring and the yank commands insert the
appropriate contents of the kill ring back into a buffer (not necessarily
the original buffer).

   &lt;br /&gt;
A simple &lt;kbd&gt;C-y&lt;/kbd&gt; (&lt;code&gt;yank&lt;/code&gt;) command inserts the first item from
the kill ring into the current buffer.  If the &lt;kbd&gt;C-y&lt;/kbd&gt; command is
followed immediately by &lt;kbd&gt;M-y&lt;/kbd&gt;, the first element is replaced by
the second element.  Successive &lt;kbd&gt;M-y&lt;/kbd&gt; commands replace the second
element with the third, fourth, or fifth element, and so on.  When the
last element in the kill ring is reached, it is replaced by the first
element and the cycle is repeated.  (Thus the kill ring is called a
`ring&#39; rather than just a `list&#39;.  However, the actual data structure
that holds the text is a list. 
See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Kill-Ring&quot;&gt;Handling the Kill Ring&lt;/a&gt;, for the details of how the
list is handled as a ring.)

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Kill-Ring-Overview&quot;&gt;Kill Ring Overview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dring_002dyank_002dpointer&quot;&gt;kill-ring-yank-pointer&lt;/a&gt;:       The kill ring is a list. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#yank-nthcdr-Exercises&quot;&gt;yank nthcdr Exercises&lt;/a&gt;:        The &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; variable. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Kill-Ring-Overview&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dring_002dyank_002dpointer&quot; rel=&quot;next&quot;&gt;kill-ring-yank-pointer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Yanking&quot; rel=&quot;up&quot;&gt;Yanking&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
10.1 Kill Ring Overview&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Kill-ring-overview-220&quot;&gt;&lt;/a&gt;
The kill ring is a list of textual strings.  This is what it looks like:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (&quot;some text&quot; &quot;a different piece of text&quot; &quot;yet more text&quot;)
&lt;/pre&gt;
If this were the contents of my kill ring and I pressed &lt;kbd&gt;C-y&lt;/kbd&gt;, the
string of characters saying ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;some text&lt;/span&gt;&lt;/samp&gt;’ would be inserted in this
buffer where my cursor is located.

   &lt;br /&gt;
The &lt;code&gt;yank&lt;/code&gt; command is also used for duplicating text by copying it. 
The copied text is not cut from the buffer, but a copy of it is put on the
kill ring and is inserted by yanking it back.

   &lt;br /&gt;
Three functions are used for bringing text back from the kill ring:
&lt;code&gt;yank&lt;/code&gt;, which is usually bound to &lt;kbd&gt;C-y&lt;/kbd&gt;; &lt;code&gt;yank-pop&lt;/code&gt;,
which is usually bound to &lt;kbd&gt;M-y&lt;/kbd&gt;; and &lt;code&gt;rotate-yank-pointer&lt;/code&gt;,
which is used by the two other functions.

   &lt;br /&gt;
These functions refer to the kill ring through a variable called the
&lt;code&gt;kill-ring-yank-pointer&lt;/code&gt;.  Indeed, the insertion code for both the
&lt;code&gt;yank&lt;/code&gt; and &lt;code&gt;yank-pop&lt;/code&gt; functions is:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (insert (car kill-ring-yank-pointer))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
(Well, no more.  In GNU Emacs 22, the function has been replaced by
&lt;code&gt;insert-for-yank&lt;/code&gt; which calls &lt;code&gt;insert-for-yank-1&lt;/code&gt;
repetitively for each &lt;code&gt;yank-handler&lt;/code&gt; segment.  In turn,
&lt;code&gt;insert-for-yank-1&lt;/code&gt; strips text properties from the inserted text
according to &lt;code&gt;yank-excluded-properties&lt;/code&gt;.  Otherwise, it is just
like &lt;code&gt;insert&lt;/code&gt;.  We will stick with plain &lt;code&gt;insert&lt;/code&gt; since it
is easier to understand.)

   &lt;/div&gt;
To begin to understand how &lt;code&gt;yank&lt;/code&gt; and &lt;code&gt;yank-pop&lt;/code&gt; work, it is
first necessary to look at the &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; variable.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;kill-ring-yank-pointer&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;kill_002dring_002dyank_002dpointer&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#yank-nthcdr-Exercises&quot; rel=&quot;next&quot;&gt;yank nthcdr Exercises&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Kill-Ring-Overview&quot; rel=&quot;previous&quot;&gt;Kill Ring Overview&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Yanking&quot; rel=&quot;up&quot;&gt;Yanking&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
10.2 The &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; Variable&lt;/h3&gt;
&lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; is a variable, just as &lt;code&gt;kill-ring&lt;/code&gt; is
a variable.  It points to something by being bound to the value of what
it points to, like any other Lisp variable.

   &lt;br /&gt;
Thus, if the value of the kill ring is:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (&quot;some text&quot; &quot;a different piece of text&quot; &quot;yet more text&quot;)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
and the &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; points to the second clause, the
value of &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; is:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (&quot;a different piece of text&quot; &quot;yet more text&quot;)
&lt;/pre&gt;
As explained in the previous chapter (see &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#List-Implementation&quot;&gt;List Implementation&lt;/a&gt;), the
computer does not keep two different copies of the text being pointed to
by both the &lt;code&gt;kill-ring&lt;/code&gt; and the &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt;.  The
words “a different piece of text” and “yet more text” are not
duplicated.  Instead, the two Lisp variables point to the same pieces of
text.  Here is a diagram:


&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     kill-ring     kill-ring-yank-pointer
         |               |
         |      ___ ___  |     ___ ___      ___ ___
          ---&amp;gt; |   |   |  --&amp;gt; |   |   |    |   |   |
               |___|___|----&amp;gt; |___|___|--&amp;gt; |___|___|--&amp;gt; nil
                 |              |            |
                 |              |            |
                 |              |             --&amp;gt; &quot;yet more text&quot;
                 |              |
                 |               --&amp;gt; &quot;a different piece of text&quot;
                 |
                  --&amp;gt; &quot;some text&quot;
&lt;/pre&gt;
Both the variable &lt;code&gt;kill-ring&lt;/code&gt; and the variable
&lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; are pointers.  But the kill ring itself is
usually described as if it were actually what it is composed of.  The
&lt;code&gt;kill-ring&lt;/code&gt; is spoken of as if it were the list rather than that it
points to the list.  Conversely, the &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt; is
spoken of as pointing to a list.

   These two ways of talking about the same thing sound confusing at first but
make sense on reflection.  The kill ring is generally thought of as the
complete structure of data that holds the information of what has recently
been cut out of the Emacs buffers.  The &lt;code&gt;kill-ring-yank-pointer&lt;/code&gt;
on the other hand, serves to indicate—that is, to `point to&#39;—that part
of the kill ring of which the first element (the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt;) will be
inserted.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;yank-nthcdr-Exercises&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#kill_002dring_002dyank_002dpointer&quot; rel=&quot;previous&quot;&gt;kill-ring-yank-pointer&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Yanking&quot; rel=&quot;up&quot;&gt;Yanking&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
10.3 Exercises with &lt;code&gt;yank&lt;/code&gt; and &lt;code&gt;nthcdr&lt;/code&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Using &lt;kbd&gt;C-h v&lt;/kbd&gt; (&lt;code&gt;describe-variable&lt;/code&gt;), look at the value of
your kill ring.  Add several items to your kill ring; look at its
value again.  Using &lt;kbd&gt;M-y&lt;/kbd&gt; (&lt;code&gt;yank-pop)&lt;/code&gt;, move all the way
around the kill ring.  How many items were in your kill ring?  Find
the value of &lt;code&gt;kill-ring-max&lt;/code&gt;.  Was your kill ring full, or could
you have kept more blocks of text within it?

     &lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;nthcdr&lt;/code&gt; and &lt;code&gt;car&lt;/code&gt;, construct a series of expressions
to return the first, second, third, and fourth elements of a list. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Loops-&amp;amp;-Recursion&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Loops-_0026-Recursion&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Regexp-Search&quot; rel=&quot;next&quot;&gt;Regexp Search&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Yanking&quot; rel=&quot;previous&quot;&gt;Yanking&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Top&quot; rel=&quot;up&quot;&gt;Top&lt;/a&gt;

&lt;/div&gt;
&lt;h2 class=&quot;chapter&quot;&gt;
11 Loops and Recursion&lt;/h2&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Loops-and-recursion-221&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Recursion-and-loops-222&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Repetition-_0028loops_0029-223&quot;&gt;&lt;/a&gt;
Emacs Lisp has two primary ways to cause an expression, or a series of
expressions, to be evaluated repeatedly: one uses a &lt;code&gt;while&lt;/code&gt;
loop, and the other uses &lt;dfn&gt;recursion&lt;/dfn&gt;.

   &lt;br /&gt;
Repetition can be very valuable.  For example, to move forward four
sentences, you need only write a program that will move forward one
sentence and then repeat the process four times.  Since a computer does
not get bored or tired, such repetitive action does not have the
deleterious effects that excessive or the wrong kinds of repetition can
have on humans.

   &lt;br /&gt;
People mostly write Emacs Lisp functions using &lt;code&gt;while&lt;/code&gt; loops and
their kin; but you can use recursion, which provides a very powerful
way to think about and then to solve problems&lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#fn-11&quot; name=&quot;fnd-11&quot; rel=&quot;footnote&quot;&gt;&lt;sup&gt;11&lt;/sup&gt;&lt;/a&gt;.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#while&quot;&gt;while&lt;/a&gt;:                        Causing a stretch of code to repeat. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#dolist-dotimes&quot;&gt;dolist dotimes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursion&quot;&gt;Recursion&lt;/a&gt;:                    Causing a function to call itself. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Looping-exercise&quot;&gt;Looping exercise&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;while&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#dolist-dotimes&quot; rel=&quot;next&quot;&gt;dolist dotimes&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loops-_0026-Recursion&quot; rel=&quot;up&quot;&gt;Loops &amp;amp; Recursion&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
11.1 &lt;code&gt;while&lt;/code&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Loops-224&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-while-225&quot;&gt;&lt;/a&gt;
The &lt;code&gt;while&lt;/code&gt; special form tests whether the value returned by
evaluating its first argument is true or false.  This is similar to what
the Lisp interpreter does with an &lt;code&gt;if&lt;/code&gt;; what the interpreter does
next, however, is different.

   &lt;br /&gt;
In a &lt;code&gt;while&lt;/code&gt; expression, if the value returned by evaluating the
first argument is false, the Lisp interpreter skips the rest of the
expression (the &lt;dfn&gt;body&lt;/dfn&gt; of the expression) and does not evaluate it. 
However, if the value is true, the Lisp interpreter evaluates the body
of the expression and then again tests whether the first argument to
&lt;code&gt;while&lt;/code&gt; is true or false.  If the value returned by evaluating the
first argument is again true, the Lisp interpreter again evaluates the
body of the expression.

   &lt;br /&gt;
The template for a &lt;code&gt;while&lt;/code&gt; expression looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (while &lt;var&gt;true-or-false-test&lt;/var&gt;
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Looping-with-while&quot;&gt;Looping with while&lt;/a&gt;:           Repeat so long as test returns true. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loop-Example&quot;&gt;Loop Example&lt;/a&gt;:                 A &lt;code&gt;while&lt;/code&gt; loop that uses a list. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#print_002delements_002dof_002dlist&quot;&gt;print-elements-of-list&lt;/a&gt;:       Uses &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;car&lt;/code&gt;, &lt;code&gt;cdr&lt;/code&gt;. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;4&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop&quot;&gt;Incrementing Loop&lt;/a&gt;:            A loop with an incrementing counter. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;5&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop-Details&quot;&gt;Incrementing Loop Details&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;6&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Decrementing-Loop&quot;&gt;Decrementing Loop&lt;/a&gt;:            A loop with a decrementing counter. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Looping-with-while&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loop-Example&quot; rel=&quot;next&quot;&gt;Loop Example&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#while&quot; rel=&quot;up&quot;&gt;while&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
Looping with &lt;code&gt;while&lt;/code&gt;&lt;/h4&gt;
So long as the true-or-false-test of the &lt;code&gt;while&lt;/code&gt; expression
returns a true value when it is evaluated, the body is repeatedly
evaluated.  This process is called a loop since the Lisp interpreter
repeats the same thing again and again, like an airplane doing a loop. 
When the result of evaluating the true-or-false-test is false, the
Lisp interpreter does not evaluate the rest of the &lt;code&gt;while&lt;/code&gt;
expression and `exits the loop&#39;.

   &lt;br /&gt;
Clearly, if the value returned by evaluating the first argument to
&lt;code&gt;while&lt;/code&gt; is always true, the body following will be evaluated
again and again &lt;small class=&quot;dots&quot;&gt;...&lt;/small&gt; and again &lt;small class=&quot;dots&quot;&gt;...&lt;/small&gt; forever.  Conversely, if the
value returned is never true, the expressions in the body will never
be evaluated.  The craft of writing a &lt;code&gt;while&lt;/code&gt; loop consists of
choosing a mechanism such that the true-or-false-test returns true
just the number of times that you want the subsequent expressions to
be evaluated, and then have the test return false.

   &lt;br /&gt;
The value returned by evaluating a &lt;code&gt;while&lt;/code&gt; is the value of the
true-or-false-test.  An interesting consequence of this is that a
&lt;code&gt;while&lt;/code&gt; loop that evaluates without error will return &lt;code&gt;nil&lt;/code&gt;
or false regardless of whether it has looped 1 or 100 times or none at
all.  A &lt;code&gt;while&lt;/code&gt; expression that evaluates successfully never
returns a true value!  What this means is that &lt;code&gt;while&lt;/code&gt; is always
evaluated for its side effects, which is to say, the consequences of
evaluating the expressions within the body of the &lt;code&gt;while&lt;/code&gt; loop. 
This makes sense.  It is not the mere act of looping that is desired,
but the consequences of what happens when the expressions in the loop
are repeatedly evaluated.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Loop-Example&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#print_002delements_002dof_002dlist&quot; rel=&quot;next&quot;&gt;print-elements-of-list&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Looping-with-while&quot; rel=&quot;previous&quot;&gt;Looping with while&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#while&quot; rel=&quot;up&quot;&gt;while&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
11.1.1 A &lt;code&gt;while&lt;/code&gt; Loop and a List&lt;/h4&gt;
A common way to control a &lt;code&gt;while&lt;/code&gt; loop is to test whether a list
has any elements.  If it does, the loop is repeated; but if it does not,
the repetition is ended.  Since this is an important technique, we will
create a short example to illustrate it.

   &lt;br /&gt;
A simple way to test whether a list has elements is to evaluate the
list: if it has no elements, it is an empty list and will return the
empty list, &lt;code&gt;()&lt;/code&gt;, which is a synonym for &lt;code&gt;nil&lt;/code&gt; or false.  On
the other hand, a list with elements will return those elements when it
is evaluated.  Since Emacs Lisp considers as true any value that is not
&lt;code&gt;nil&lt;/code&gt;, a list that returns elements will test true in a
&lt;code&gt;while&lt;/code&gt; loop.

   &lt;br /&gt;
For example, you can set the variable &lt;code&gt;empty-list&lt;/code&gt; to &lt;code&gt;nil&lt;/code&gt; by
evaluating the following &lt;code&gt;setq&lt;/code&gt; expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq empty-list ())
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
After evaluating the &lt;code&gt;setq&lt;/code&gt; expression, you can evaluate the
variable &lt;code&gt;empty-list&lt;/code&gt; in the usual way, by placing the cursor after
the symbol and typing &lt;kbd&gt;C-x C-e&lt;/kbd&gt;; &lt;code&gt;nil&lt;/code&gt; will appear in your
echo area:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     empty-list
&lt;/pre&gt;
On the other hand, if you set a variable to be a list with elements, the
list will appear when you evaluate the variable, as you can see by
evaluating the following two expressions:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq animals &#39;(gazelle giraffe lion tiger))
     
     animals
&lt;/pre&gt;
Thus, to create a &lt;code&gt;while&lt;/code&gt; loop that tests whether there are any
items in the list &lt;code&gt;animals&lt;/code&gt;, the first part of the loop will be
written like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (while animals
            ...
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When the &lt;code&gt;while&lt;/code&gt; tests its first argument, the variable
&lt;code&gt;animals&lt;/code&gt; is evaluated.  It returns a list.  So long as the list
has elements, the &lt;code&gt;while&lt;/code&gt; considers the results of the test to be
true; but when the list is empty, it considers the results of the test
to be false.

   &lt;/div&gt;
To prevent the &lt;code&gt;while&lt;/code&gt; loop from running forever, some mechanism
needs to be provided to empty the list eventually.  An oft-used
technique is to have one of the subsequent forms in the &lt;code&gt;while&lt;/code&gt;
expression set the value of the list to be the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the list. 
Each time the &lt;code&gt;cdr&lt;/code&gt; function is evaluated, the list will be made
shorter, until eventually only the empty list will be left.  At this
point, the test of the &lt;code&gt;while&lt;/code&gt; loop will return false, and the
arguments to the &lt;code&gt;while&lt;/code&gt; will no longer be evaluated.

   &lt;br /&gt;
For example, the list of animals bound to the variable &lt;code&gt;animals&lt;/code&gt;
can be set to be the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the original list with the
following expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq animals (cdr animals))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
If you have evaluated the previous expressions and then evaluate this
expression, you will see &lt;code&gt;(giraffe lion tiger)&lt;/code&gt; appear in the echo
area.  If you evaluate the expression again, &lt;code&gt;(lion tiger)&lt;/code&gt; will
appear in the echo area.  If you evaluate it again and yet again,
&lt;code&gt;(tiger)&lt;/code&gt; appears and then the empty list, shown by &lt;code&gt;nil&lt;/code&gt;.

   &lt;/div&gt;
A template for a &lt;code&gt;while&lt;/code&gt; loop that uses the &lt;code&gt;cdr&lt;/code&gt; function
repeatedly to cause the true-or-false-test eventually to test false
looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (while &lt;var&gt;test-whether-list-is-empty&lt;/var&gt;
       &lt;var&gt;body&lt;/var&gt;...
       &lt;var&gt;set-list-to-cdr-of-list&lt;/var&gt;)
&lt;/pre&gt;
This test and use of &lt;code&gt;cdr&lt;/code&gt; can be put together in a function that
goes through a list and prints each element of the list on a line of its
own.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;print-elements-of-list&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;print_002delements_002dof_002dlist&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop&quot; rel=&quot;next&quot;&gt;Incrementing Loop&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loop-Example&quot; rel=&quot;previous&quot;&gt;Loop Example&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#while&quot; rel=&quot;up&quot;&gt;while&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
11.1.2 An Example: &lt;code&gt;print-elements-of-list&lt;/code&gt;&lt;/h4&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-print_002delements_002dof_002dlist-226&quot;&gt;&lt;/a&gt;
The &lt;code&gt;print-elements-of-list&lt;/code&gt; function illustrates a &lt;code&gt;while&lt;/code&gt;
loop with a list.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_0040file_007b_002ascratch_002a_007d-buffer-227&quot;&gt;&lt;/a&gt;The function requires several lines for its output.  If you are
reading this in a recent instance of GNU Emacs,

you can evaluate the following expression inside of Info, as usual.

   &lt;br /&gt;
If you are using an earlier version of Emacs, you need to copy the
necessary expressions to your &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer and evaluate
them there.  This is because the echo area had only one line in the
earlier versions.

   &lt;br /&gt;
You can copy the expressions by marking the beginning of the region
with &lt;kbd&gt;C-&amp;lt;SPC&amp;gt;&lt;/kbd&gt; (&lt;code&gt;set-mark-command&lt;/code&gt;), moving the cursor to
the end of the region and then copying the region using &lt;kbd&gt;M-w&lt;/kbd&gt;
(&lt;code&gt;kill-ring-save&lt;/code&gt;, which calls &lt;code&gt;copy-region-as-kill&lt;/code&gt; and
then provides visual feedback).  In the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt;
buffer, you can yank the expressions back by typing &lt;kbd&gt;C-y&lt;/kbd&gt;
(&lt;code&gt;yank&lt;/code&gt;).

   &lt;br /&gt;
After you have copied the expressions to the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer,
evaluate each expression in turn.  Be sure to evaluate the last
expression, &lt;code&gt;(print-elements-of-list animals)&lt;/code&gt;, by typing
&lt;kbd&gt;C-u C-x C-e&lt;/kbd&gt;, that is, by giving an argument to
&lt;code&gt;eval-last-sexp&lt;/code&gt;.  This will cause the result of the evaluation
to be printed in the &lt;samp&gt;&lt;span class=&quot;file&quot;&gt;*scratch*&lt;/span&gt;&lt;/samp&gt; buffer instead of being printed
in the echo area.  (Otherwise you will see something like this in your
echo area: &lt;code&gt;^Jgazelle^J^Jgiraffe^J^Jlion^J^Jtiger^Jnil&lt;/code&gt;, in which
each ‘&lt;samp&gt;&lt;span class=&quot;samp&quot;&gt;^J&lt;/span&gt;&lt;/samp&gt;’ stands for a `newline&#39;.)

   &lt;br /&gt;
In a recent instance of GNU Emacs, you can evaluate these expressions
directly in the Info buffer, and the echo area will grow to show the
results.

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq animals &#39;(gazelle giraffe lion tiger))
     
     (defun print-elements-of-list (list)
       &quot;Print each element of LIST on a line of its own.&quot;
       (while list
         (print (car list))
         (setq list (cdr list))))
     
     (print-elements-of-list animals)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
When you evaluate the three expressions in sequence, you will see
this:

&lt;/div&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     gazelle
     
     giraffe
     
     lion
     
     tiger
     nil
&lt;/pre&gt;
Each element of the list is printed on a line of its own (that is what
the function &lt;code&gt;print&lt;/code&gt; does) and then the value returned by the
function is printed.  Since the last expression in the function is the
&lt;code&gt;while&lt;/code&gt; loop, and since &lt;code&gt;while&lt;/code&gt; loops always return
&lt;code&gt;nil&lt;/code&gt;, a &lt;code&gt;nil&lt;/code&gt; is printed after the last element of the list.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Incrementing-Loop&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop-Details&quot; rel=&quot;next&quot;&gt;Incrementing Loop Details&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#print_002delements_002dof_002dlist&quot; rel=&quot;previous&quot;&gt;print-elements-of-list&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#while&quot; rel=&quot;up&quot;&gt;while&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
11.1.3 A Loop with an Incrementing Counter&lt;/h4&gt;
A loop is not useful unless it stops when it ought.  Besides
controlling a loop with a list, a common way of stopping a loop is to
write the first argument as a test that returns false when the correct
number of repetitions are complete.  This means that the loop must
have a counter—an expression that counts how many times the loop
repeats itself.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Incrementing-Loop-Details&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Decrementing-Loop&quot; rel=&quot;next&quot;&gt;Decrementing Loop&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop&quot; rel=&quot;previous&quot;&gt;Incrementing Loop&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#while&quot; rel=&quot;up&quot;&gt;while&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;unnumberedsubsec&quot;&gt;
Details of an Incrementing Loop&lt;/h4&gt;
The test for a loop with an incrementing counter can be an expression
such as &lt;code&gt;(&amp;lt; count desired-number)&lt;/code&gt; which returns &lt;code&gt;t&lt;/code&gt; for
true if the value of &lt;code&gt;count&lt;/code&gt; is less than the
&lt;code&gt;desired-number&lt;/code&gt; of repetitions and &lt;code&gt;nil&lt;/code&gt; for false if the
value of &lt;code&gt;count&lt;/code&gt; is equal to or is greater than the
&lt;code&gt;desired-number&lt;/code&gt;.  The expression that increments the count can
be a simple &lt;code&gt;setq&lt;/code&gt; such as &lt;code&gt;(setq count (1+ count))&lt;/code&gt;, where
&lt;code&gt;1+&lt;/code&gt; is a built-in function in Emacs Lisp that adds 1 to its
argument.  (The expression &lt;code&gt;(1+&amp;nbsp;count)&lt;/code&gt; has the same result
as &lt;code&gt;(+&amp;nbsp;count&amp;nbsp;1)&lt;/code&gt;, but is easier for a human to read.)

   &lt;br /&gt;
The template for a &lt;code&gt;while&lt;/code&gt; loop controlled by an incrementing
counter looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     &lt;var&gt;set-count-to-initial-value&lt;/var&gt;
     (while (&amp;lt; count desired-number)         ; &lt;span class=&quot;roman&quot;&gt;true-or-false-test&lt;/span&gt;
       &lt;var&gt;body&lt;/var&gt;...
       (setq count (1+ count)))              ; &lt;span class=&quot;roman&quot;&gt;incrementer&lt;/span&gt;
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
Note that you need to set the initial value of &lt;code&gt;count&lt;/code&gt;; usually it
is set to 1.

&lt;/div&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Example&quot;&gt;Incrementing Example&lt;/a&gt;:         Counting pebbles in a triangle. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Inc-Example-parts&quot;&gt;Inc Example parts&lt;/a&gt;:            The parts of the function definition. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Inc-Example-altogether&quot;&gt;Inc Example altogether&lt;/a&gt;:       Putting the function definition together. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Incrementing-Example&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Inc-Example-parts&quot; rel=&quot;next&quot;&gt;Inc Example parts&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop-Details&quot; rel=&quot;up&quot;&gt;Incrementing Loop Details&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
Example with incrementing counter&lt;/h5&gt;
Suppose you are playing on the beach and decide to make a triangle of
pebbles, putting one pebble in the first row, two in the second row,
three in the third row and so on, like this:

   &lt;br /&gt;


&lt;pre class=&quot;smallexample&quot;&gt;                    *
                   * *
                  * * *
                 * * * *
&lt;/pre&gt;
(About 2500 years ago, Pythagoras and others developed the beginnings of
number theory by considering questions such as this.)

   Suppose you want to know how many pebbles you will need to make a
triangle with 7 rows?

   &lt;br /&gt;
Clearly, what you need to do is add up the numbers from 1 to 7.  There
are two ways to do this; start with the smallest number, one, and add up
the list in sequence, 1, 2, 3, 4 and so on; or start with the largest
number and add the list going down: 7, 6, 5, 4 and so on.  Because both
mechanisms illustrate common ways of writing &lt;code&gt;while&lt;/code&gt; loops, we will
create two examples, one counting up and the other counting down.  In
this first example, we will start with 1 and add 2, 3, 4 and so on.

   &lt;br /&gt;
If you are just adding up a short list of numbers, the easiest way to do
it is to add up all the numbers at once.  However, if you do not know
ahead of time how many numbers your list will have, or if you want to be
prepared for a very long list, then you need to design your addition so
that what you do is repeat a simple process many times instead of doing
a more complex process once.

   &lt;br /&gt;
For example, instead of adding up all the pebbles all at once, what you
can do is add the number of pebbles in the first row, 1, to the number
in the second row, 2, and then add the total of those two rows to the
third row, 3.  Then you can add the number in the fourth row, 4, to the
total of the first three rows; and so on.

   &lt;br /&gt;
The critical characteristic of the process is that each repetitive
action is simple.  In this case, at each step we add only two numbers,
the number of pebbles in the row and the total already found.  This
process of adding two numbers is repeated again and again until the last
row has been added to the total of all the preceding rows.  In a more
complex loop the repetitive action might not be so simple, but it will
be simpler than doing everything all at once.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Inc-Example-parts&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Inc-Example-altogether&quot; rel=&quot;next&quot;&gt;Inc Example altogether&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Example&quot; rel=&quot;previous&quot;&gt;Incrementing Example&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop-Details&quot; rel=&quot;up&quot;&gt;Incrementing Loop Details&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
The parts of the function definition&lt;/h5&gt;
The preceding analysis gives us the bones of our function definition:
first, we will need a variable that we can call &lt;code&gt;total&lt;/code&gt; that will
be the total number of pebbles.  This will be the value returned by
the function.

   &lt;br /&gt;
Second, we know that the function will require an argument: this
argument will be the total number of rows in the triangle.  It can be
called &lt;code&gt;number-of-rows&lt;/code&gt;.

   &lt;br /&gt;
Finally, we need a variable to use as a counter.  We could call this
variable &lt;code&gt;counter&lt;/code&gt;, but a better name is &lt;code&gt;row-number&lt;/code&gt;.  That
is because what the counter does in this function is count rows, and a
program should be written to be as understandable as possible.

   &lt;br /&gt;
When the Lisp interpreter first starts evaluating the expressions in the
function, the value of &lt;code&gt;total&lt;/code&gt; should be set to zero, since we have
not added anything to it.  Then the function should add the number of
pebbles in the first row to the total, and then add the number of
pebbles in the second to the total, and then add the number of
pebbles in the third row to the total, and so on, until there are no
more rows left to add.

   &lt;br /&gt;
Both &lt;code&gt;total&lt;/code&gt; and &lt;code&gt;row-number&lt;/code&gt; are used only inside the
function, so they can be declared as local variables with &lt;code&gt;let&lt;/code&gt;
and given initial values.  Clearly, the initial value for &lt;code&gt;total&lt;/code&gt;
should be 0.  The initial value of &lt;code&gt;row-number&lt;/code&gt; should be 1,
since we start with the first row.  This means that the &lt;code&gt;let&lt;/code&gt;
statement will look like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;       (let ((total 0)
             (row-number 1))
         &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
After the internal variables are declared and bound to their initial
values, we can begin the &lt;code&gt;while&lt;/code&gt; loop.  The expression that serves
as the test should return a value of &lt;code&gt;t&lt;/code&gt; for true so long as the
&lt;code&gt;row-number&lt;/code&gt; is less than or equal to the &lt;code&gt;number-of-rows&lt;/code&gt;. 
(If the expression tests true only so long as the row number is less
than the number of rows in the triangle, the last row will never be
added to the total; hence the row number has to be either less than or
equal to the number of rows.)

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-g_t_003c_003d-_0040r_007b_0028less-than-or-equal_0029_007d-228&quot;&gt;&lt;/a&gt;Lisp provides the &lt;code&gt;&amp;lt;=&lt;/code&gt; function that returns true if the value of
its first argument is less than or equal to the value of its second
argument and false otherwise.  So the expression that the &lt;code&gt;while&lt;/code&gt;
will evaluate as its test should look like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (&amp;lt;= row-number number-of-rows)
&lt;/pre&gt;
The total number of pebbles can be found by repeatedly adding the number
of pebbles in a row to the total already found.  Since the number of
pebbles in the row is equal to the row number, the total can be found by
adding the row number to the total.  (Clearly, in a more complex
situation, the number of pebbles in the row might be related to the row
number in a more complicated way; if this were the case, the row number
would be replaced by the appropriate expression.)

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq total (+ total row-number))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
What this does is set the new value of &lt;code&gt;total&lt;/code&gt; to be equal to the
sum of adding the number of pebbles in the row to the previous total.

   &lt;/div&gt;
After setting the value of &lt;code&gt;total&lt;/code&gt;, the conditions need to be
established for the next repetition of the loop, if there is one.  This
is done by incrementing the value of the &lt;code&gt;row-number&lt;/code&gt; variable,
which serves as a counter.  After the &lt;code&gt;row-number&lt;/code&gt; variable has
been incremented, the true-or-false-test at the beginning of the
&lt;code&gt;while&lt;/code&gt; loop tests whether its value is still less than or equal to
the value of the &lt;code&gt;number-of-rows&lt;/code&gt; and if it is, adds the new value
of the &lt;code&gt;row-number&lt;/code&gt; variable to the &lt;code&gt;total&lt;/code&gt; of the previous
repetition of the loop.

   &lt;br /&gt;
The built-in Emacs Lisp function &lt;code&gt;1+&lt;/code&gt; adds 1 to a number, so the
&lt;code&gt;row-number&lt;/code&gt; variable can be incremented with this expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq row-number (1+ row-number))
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Inc-Example-altogether&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Inc-Example-parts&quot; rel=&quot;previous&quot;&gt;Inc Example parts&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop-Details&quot; rel=&quot;up&quot;&gt;Incrementing Loop Details&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
Putting the function definition together&lt;/h5&gt;
We have created the parts for the function definition; now we need to
put them together.

   &lt;br /&gt;
First, the contents of the &lt;code&gt;while&lt;/code&gt; expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (while (&amp;lt;= row-number number-of-rows)   ; &lt;span class=&quot;roman&quot;&gt;true-or-false-test&lt;/span&gt;
       (setq total (+ total row-number))
       (setq row-number (1+ row-number)))    ; &lt;span class=&quot;roman&quot;&gt;incrementer&lt;/span&gt;
&lt;/pre&gt;
Along with the &lt;code&gt;let&lt;/code&gt; expression varlist, this very nearly
completes the body of the function definition.  However, it requires
one final element, the need for which is somewhat subtle.

   &lt;br /&gt;
The final touch is to place the variable &lt;code&gt;total&lt;/code&gt; on a line by
itself after the &lt;code&gt;while&lt;/code&gt; expression.  Otherwise, the value returned
by the whole function is the value of the last expression that is
evaluated in the body of the &lt;code&gt;let&lt;/code&gt;, and this is the value
returned by the &lt;code&gt;while&lt;/code&gt;, which is always &lt;code&gt;nil&lt;/code&gt;.

   &lt;br /&gt;
This may not be evident at first sight.  It almost looks as if the
incrementing expression is the last expression of the whole function. 
But that expression is part of the body of the &lt;code&gt;while&lt;/code&gt;; it is the
last element of the list that starts with the symbol &lt;code&gt;while&lt;/code&gt;. 
Moreover, the whole of the &lt;code&gt;while&lt;/code&gt; loop is a list within the body
of the &lt;code&gt;let&lt;/code&gt;.

   &lt;br /&gt;
In outline, the function will look like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun &lt;var&gt;name-of-function&lt;/var&gt; (&lt;var&gt;argument-list&lt;/var&gt;)
       &quot;&lt;var&gt;documentation&lt;/var&gt;...&quot;
       (let (&lt;var&gt;varlist&lt;/var&gt;)
         (while (&lt;var&gt;true-or-false-test&lt;/var&gt;)
           &lt;var&gt;body-of-while&lt;/var&gt;... )
         ... ))                    ; &lt;span class=&quot;roman&quot;&gt;Need final expression here.&lt;/span&gt;
&lt;/pre&gt;
The result of evaluating the &lt;code&gt;let&lt;/code&gt; is what is going to be returned
by the &lt;code&gt;defun&lt;/code&gt; since the &lt;code&gt;let&lt;/code&gt; is not embedded within any
containing list, except for the &lt;code&gt;defun&lt;/code&gt; as a whole.  However, if
the &lt;code&gt;while&lt;/code&gt; is the last element of the &lt;code&gt;let&lt;/code&gt; expression, the
function will always return &lt;code&gt;nil&lt;/code&gt;.  This is not what we want! 
Instead, what we want is the value of the variable &lt;code&gt;total&lt;/code&gt;.  This
is returned by simply placing the symbol as the last element of the list
starting with &lt;code&gt;let&lt;/code&gt;.  It gets evaluated after the preceding
elements of the list are evaluated, which means it gets evaluated after
it has been assigned the correct value for the total.

   &lt;br /&gt;
It may be easier to see this by printing the list starting with
&lt;code&gt;let&lt;/code&gt; all on one line.  This format makes it evident that the
&lt;var&gt;varlist&lt;/var&gt; and &lt;code&gt;while&lt;/code&gt; expressions are the second and third
elements of the list starting with &lt;code&gt;let&lt;/code&gt;, and the &lt;code&gt;total&lt;/code&gt; is
the last element:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let (&lt;var&gt;varlist&lt;/var&gt;) (while (&lt;var&gt;true-or-false-test&lt;/var&gt;) &lt;var&gt;body-of-while&lt;/var&gt;... ) total)
&lt;/pre&gt;
Putting everything together, the &lt;code&gt;triangle&lt;/code&gt; function definition
looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun triangle (number-of-rows)    ; &lt;span class=&quot;roman&quot;&gt;Version with&lt;/span&gt;
                                         ; &lt;span class=&quot;roman&quot;&gt;  incrementing counter.&lt;/span&gt;
       &quot;Add up the number of pebbles in a triangle.
     The first row has one pebble, the second row two pebbles,
     the third row three pebbles, and so on.
     The argument is NUMBER-OF-ROWS.&quot;
       (let ((total 0)
             (row-number 1))
         (while (&amp;lt;= row-number number-of-rows)
           (setq total (+ total row-number))
           (setq row-number (1+ row-number)))
         total))
&lt;/pre&gt;
After you have installed &lt;code&gt;triangle&lt;/code&gt; by evaluating the function, you
can try it out.  Here are two examples:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (triangle 4)
     
     (triangle 7)
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
The sum of the first four numbers is 10 and the sum of the first seven
numbers is 28.

&lt;/div&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Decrementing-Loop&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Incrementing-Loop-Details&quot; rel=&quot;previous&quot;&gt;Incrementing Loop Details&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#while&quot; rel=&quot;up&quot;&gt;while&lt;/a&gt;

&lt;/div&gt;
&lt;h4 class=&quot;subsection&quot;&gt;
11.1.4 Loop with a Decrementing Counter&lt;/h4&gt;
Another common way to write a &lt;code&gt;while&lt;/code&gt; loop is to write the test
so that it determines whether a counter is greater than zero.  So long
as the counter is greater than zero, the loop is repeated.  But when
the counter is equal to or less than zero, the loop is stopped.  For
this to work, the counter has to start out greater than zero and then
be made smaller and smaller by a form that is evaluated
repeatedly.

   &lt;br /&gt;
The test will be an expression such as &lt;code&gt;(&amp;gt; counter 0)&lt;/code&gt; which
returns &lt;code&gt;t&lt;/code&gt; for true if the value of &lt;code&gt;counter&lt;/code&gt; is greater
than zero, and &lt;code&gt;nil&lt;/code&gt; for false if the value of &lt;code&gt;counter&lt;/code&gt; is
equal to or less than zero.  The expression that makes the number
smaller and smaller can be a simple &lt;code&gt;setq&lt;/code&gt; such as &lt;code&gt;(setq
counter (1- counter))&lt;/code&gt;, where &lt;code&gt;1-&lt;/code&gt; is a built-in function in
Emacs Lisp that subtracts 1 from its argument.

   &lt;br /&gt;
The template for a decrementing &lt;code&gt;while&lt;/code&gt; loop looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (while (&amp;gt; counter 0)                    ; &lt;span class=&quot;roman&quot;&gt;true-or-false-test&lt;/span&gt;
       &lt;var&gt;body&lt;/var&gt;...
       (setq counter (1- counter)))          ; &lt;span class=&quot;roman&quot;&gt;decrementer&lt;/span&gt;
&lt;/pre&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Decrementing-Example&quot;&gt;Decrementing Example&lt;/a&gt;:         More pebbles on the beach. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Dec-Example-parts&quot;&gt;Dec Example parts&lt;/a&gt;:            The parts of the function definition. 
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;3&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Dec-Example-altogether&quot;&gt;Dec Example altogether&lt;/a&gt;:       Putting the function definition together. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Decrementing-Example&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Dec-Example-parts&quot; rel=&quot;next&quot;&gt;Dec Example parts&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Decrementing-Loop&quot; rel=&quot;up&quot;&gt;Decrementing Loop&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
Example with decrementing counter&lt;/h5&gt;
To illustrate a loop with a decrementing counter, we will rewrite the
&lt;code&gt;triangle&lt;/code&gt; function so the counter decreases to zero.

   &lt;br /&gt;
This is the reverse of the earlier version of the function.  In this
case, to find out how many pebbles are needed to make a triangle with
3 rows, add the number of pebbles in the third row, 3, to the number
in the preceding row, 2, and then add the total of those two rows to
the row that precedes them, which is 1.

   &lt;br /&gt;
Likewise, to find the number of pebbles in a triangle with 7 rows, add
the number of pebbles in the seventh row, 7, to the number in the
preceding row, which is 6, and then add the total of those two rows to
the row that precedes them, which is 5, and so on.  As in the previous
example, each addition only involves adding two numbers, the total of
the rows already added up and the number of pebbles in the row that is
being added to the total.  This process of adding two numbers is
repeated again and again until there are no more pebbles to add.

   &lt;br /&gt;
We know how many pebbles to start with: the number of pebbles in the
last row is equal to the number of rows.  If the triangle has seven
rows, the number of pebbles in the last row is 7.  Likewise, we know how
many pebbles are in the preceding row: it is one less than the number in
the row.

&lt;br /&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Dec-Example-parts&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Dec-Example-altogether&quot; rel=&quot;next&quot;&gt;Dec Example altogether&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Decrementing-Example&quot; rel=&quot;previous&quot;&gt;Decrementing Example&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Decrementing-Loop&quot; rel=&quot;up&quot;&gt;Decrementing Loop&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
The parts of the function definition&lt;/h5&gt;
We start with three variables: the total number of rows in the
triangle; the number of pebbles in a row; and the total number of
pebbles, which is what we want to calculate.  These variables can be
named &lt;code&gt;number-of-rows&lt;/code&gt;, &lt;code&gt;number-of-pebbles-in-row&lt;/code&gt;, and
&lt;code&gt;total&lt;/code&gt;, respectively.

   &lt;br /&gt;
Both &lt;code&gt;total&lt;/code&gt; and &lt;code&gt;number-of-pebbles-in-row&lt;/code&gt; are used only
inside the function and are declared with &lt;code&gt;let&lt;/code&gt;.  The initial
value of &lt;code&gt;total&lt;/code&gt; should, of course, be zero.  However, the
initial value of &lt;code&gt;number-of-pebbles-in-row&lt;/code&gt; should be equal to
the number of rows in the triangle, since the addition will start with
the longest row.

   &lt;br /&gt;
This means that the beginning of the &lt;code&gt;let&lt;/code&gt; expression will look
like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (let ((total 0)
           (number-of-pebbles-in-row number-of-rows))
       &lt;var&gt;body&lt;/var&gt;...)
&lt;/pre&gt;
The total number of pebbles can be found by repeatedly adding the number
of pebbles in a row to the total already found, that is, by repeatedly
evaluating the following expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq total (+ total number-of-pebbles-in-row))
&lt;/pre&gt;
&lt;div class=&quot;noindent&quot;&gt;
After the &lt;code&gt;number-of-pebbles-in-row&lt;/code&gt; is added to the &lt;code&gt;total&lt;/code&gt;,
the &lt;code&gt;number-of-pebbles-in-row&lt;/code&gt; should be decremented by one, since
the next time the loop repeats, the preceding row will be
added to the total.

   &lt;/div&gt;
The number of pebbles in a preceding row is one less than the number of
pebbles in a row, so the built-in Emacs Lisp function &lt;code&gt;1-&lt;/code&gt; can be
used to compute the number of pebbles in the preceding row.  This can be
done with the following expression:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (setq number-of-pebbles-in-row
           (1- number-of-pebbles-in-row))
&lt;/pre&gt;
Finally, we know that the &lt;code&gt;while&lt;/code&gt; loop should stop making repeated
additions when there are no pebbles in a row.  So the test for
the &lt;code&gt;while&lt;/code&gt; loop is simply:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (while (&amp;gt; number-of-pebbles-in-row 0)
&lt;/pre&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;Dec-Example-altogether&quot;&gt;&lt;/a&gt;

Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Dec-Example-parts&quot; rel=&quot;previous&quot;&gt;Dec Example parts&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Decrementing-Loop&quot; rel=&quot;up&quot;&gt;Decrementing Loop&lt;/a&gt;

&lt;/div&gt;
&lt;h5 class=&quot;unnumberedsubsubsec&quot;&gt;
Putting the function definition together&lt;/h5&gt;
We can put these expressions together to create a function definition
that works.  However, on examination, we find that one of the local
variables is unneeded!

   &lt;br /&gt;
The function definition looks like this:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     ;;; &lt;span class=&quot;roman&quot;&gt;First subtractive version.&lt;/span&gt;
     (defun triangle (number-of-rows)
       &quot;Add up the number of pebbles in a triangle.&quot;
       (let ((total 0)
             (number-of-pebbles-in-row number-of-rows))
         (while (&amp;gt; number-of-pebbles-in-row 0)
           (setq total (+ total number-of-pebbles-in-row))
           (setq number-of-pebbles-in-row
                 (1- number-of-pebbles-in-row)))
         total))
&lt;/pre&gt;
As written, this function works.

   &lt;br /&gt;
However, we do not need &lt;code&gt;number-of-pebbles-in-row&lt;/code&gt;.

   &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;index-Argument-as-local-variable-229&quot;&gt;&lt;/a&gt;When the &lt;code&gt;triangle&lt;/code&gt; function is evaluated, the symbol
&lt;code&gt;number-of-rows&lt;/code&gt; will be bound to a number, giving it an initial
value.  That number can be changed in the body of the function as if
it were a local variable, without any fear that such a change will
effect the value of the variable outside of the function.  This is a
very useful characteristic of Lisp; it means that the variable
&lt;code&gt;number-of-rows&lt;/code&gt; can be used anywhere in the function where
&lt;code&gt;number-of-pebbles-in-row&lt;/code&gt; is used.

   &lt;br /&gt;
Here is a second version of the function written a bit more cleanly:

&lt;br /&gt;
&lt;pre class=&quot;smallexample&quot;&gt;     (defun triangle (number)                ; &lt;span class=&quot;roman&quot;&gt;Second version.&lt;/span&gt;
       &quot;Return sum of numbers 1 through NUMBER inclusive.&quot;
       (let ((total 0))
         (while (&amp;gt; number 0)
           (setq total (+ total number))
           (setq number (1- number)))
         total))
&lt;/pre&gt;
In brief, a properly written &lt;code&gt;while&lt;/code&gt; loop will consist of three parts:

     &lt;br /&gt;
&lt;ol start=&quot;1&quot; type=&quot;1&quot;&gt;
&lt;li&gt;A test that will return false after the loop has repeated itself the
correct number of times.

     &lt;/li&gt;
&lt;li&gt;An expression the evaluation of which will return the value desired
after being repeatedly evaluated.

     &lt;/li&gt;
&lt;li&gt;An expression to change the value passed to the true-or-false-test so
that the test returns false after the loop has repeated itself the right
number of times.
        &lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;dolist-dotimes&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Recursion&quot; rel=&quot;next&quot;&gt;Recursion&lt;/a&gt;,
Previous:&amp;nbsp;&lt;a accesskey=&quot;p&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#while&quot; rel=&quot;previous&quot;&gt;while&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#Loops-_0026-Recursion&quot; rel=&quot;up&quot;&gt;Loops &amp;amp; Recursion&lt;/a&gt;

&lt;/div&gt;
&lt;h3 class=&quot;section&quot;&gt;
11.2 Save your time: &lt;code&gt;dolist&lt;/code&gt; and &lt;code&gt;dotimes&lt;/code&gt;&lt;/h3&gt;
In addition to &lt;code&gt;while&lt;/code&gt;, both &lt;code&gt;dolist&lt;/code&gt; and &lt;code&gt;dotimes&lt;/code&gt;
provide for looping.  Sometimes these are quicker to write than the
equivalent &lt;code&gt;while&lt;/code&gt; loop.  Both are Lisp macros.  (See &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Macros&quot;&gt;Macros&lt;/a&gt;. )

   &lt;br /&gt;
&lt;code&gt;dolist&lt;/code&gt; works like a &lt;code&gt;while&lt;/code&gt; loop that `&lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt;s down a
list&#39;:  &lt;code&gt;dolist&lt;/code&gt; automatically shortens the list each time it
loops—takes the &lt;span class=&quot;sc&quot;&gt;cdr&lt;/span&gt; of the list—and binds the &lt;span class=&quot;sc&quot;&gt;car&lt;/span&gt; of
each shorter version of the list to the first of its arguments.

   &lt;br /&gt;
&lt;code&gt;dotimes&lt;/code&gt; loops a specific number of times: you specify the number.

&lt;br /&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a accesskey=&quot;1&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#dolist&quot;&gt;dolist&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a accesskey=&quot;2&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#dotimes&quot;&gt;dotimes&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;node&quot; style=&quot;background-color: #ddddff;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;dolist&quot;&gt;&lt;/a&gt;

Next:&amp;nbsp;&lt;a accesskey=&quot;n&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#dotimes&quot; rel=&quot;next&quot;&gt;dotimes&lt;/a&gt;,
Up:&amp;nbsp;&lt;a accesskey=&quot;u&quot; href=&quot;http://www.gnu.org/software/emacs/manual/html_mono/eintr.html#dolist-dotimes&quot; rel=&quot;up&quot;&gt;dolist dotimes&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/1438459100881199243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/an-introduction-to-programming-in-emacs.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1438459100881199243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1438459100881199243'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/an-introduction-to-programming-in-emacs.html' title='An Introduction to Programming in Emacs Lisp'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-8380180926822810513</id><published>2013-08-13T04:37:00.003-07:00</published><updated>2013-08-13T20:10:20.872-07:00</updated><title type='text'>Using Voice to Code Faster than Keyboard</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1&gt;
&lt;a href=&quot;http://bit.ly/13VkVY6&quot; target=&quot;_blank&quot;&gt;Using Voice to Code Faster than Keyboard &lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;byline&quot;&gt;
&lt;address class=&quot;author&quot;&gt;
&lt;a href=&quot;https://plus.google.com/112757647855302148298?rel=author&quot; rel=&quot;author&quot;&gt;Xah Lee&lt;/a&gt;&lt;/address&gt;
, &lt;time&gt;2013-03-27&lt;/time&gt;&lt;/div&gt;
&lt;div class=&quot;share-buttons&quot;&gt;
&lt;div class=&quot;fb-like fb_edge_widget_with_comment fb_iframe_widget&quot; data-layout=&quot;button_count&quot; data-send=&quot;false&quot; data-show-faces=&quot;false&quot; data-width=&quot;90&quot;&gt;
&lt;span style=&quot;height: 20px; width: 74px;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
A very cool video. Using voice to code, and code faster than average 
programer with keyboard. It&#39;s a presentation at Python Conference 2013.&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/8SkdfdXWYaI?feature=player_embedded&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;


&lt;br /&gt;
&lt;br /&gt;
&lt;figure&gt;

&lt;figcaption&gt;Using Voice Recognition to write code, by &lt;a class=&quot;sorc&quot; data-accessed=&quot;2013-03-27&quot; href=&quot;https://github.com/tavisrudd&quot;&gt;Tavis Rudd&lt;/a&gt;.
Published on &lt;time&gt;2013-03-20&lt;/time&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;

The first demo, voice coding &lt;a href=&quot;http://bit.ly/1eInhLg&quot; target=&quot;_blank&quot;&gt;emacs lisp&lt;/a&gt;, starts at 09:00.&lt;br /&gt;
&lt;h3&gt;
Synopsis&lt;/h3&gt;
&lt;blockquote&gt;
&lt;mark&gt;Two years ago I developed a case of Emacs Pinkie&lt;/mark&gt;
 (RSI) so severe my hands went numb and I could no longer type or work. 
Desperate, I tried voice recognition. At first programming with it was 
painfully slow but, as I couldn&#39;t type, I persevered. After several 
months of vocab tweaking and duct-tape coding in &lt;mark&gt;Python&lt;/mark&gt; and &lt;mark&gt;Emacs Lisp&lt;/mark&gt;, &lt;mark&gt;I had a system that enabled me to code faster and more efficiently by voice than I ever had by hand&lt;/mark&gt;.&lt;br /&gt;
In a fast-paced live demo, I will create a small system using Python,
 plus a few other languages for good measure, and deploy it without 
touching the keyboard. The demo gods will make a scheduled appearance. I
 hope to convince you that voice recognition is no longer a crutch for 
the disabled or limited to plain prose. It&#39;s now a highly effective tool
 that could benefit all programmers.&lt;/blockquote&gt;
if you are impatient, here&#39;s a summary of the video:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;He uses &lt;a href=&quot;http://en.wikipedia.org/wiki/Dragon_NaturallySpeaking&quot;&gt;Dragon NaturallySpeaking&lt;/a&gt; &lt;a class=&quot;amz&quot; href=&quot;http://www.amazon.com/dp/B008MR36FE/?tag=xahh-20&quot; title=&quot;Dragon NaturallySpeaking Home 12 0 English&quot;&gt;amazon&lt;/a&gt; voice recognition software on Microsoft Windows. (he said he couldn&#39;t make the Linux &lt;a href=&quot;http://en.wikipedia.org/wiki/CMU_Sphinx&quot;&gt;CMU Sphinx&lt;/a&gt; work.) (though, he&#39;s using Mac, apparently running Microsoft Windows in a virtual box.)&lt;/li&gt;
&lt;li&gt;Dragon uses Python. He hacked it, together with a Python Speech recognition extension lib DragonFly by Christo Butcher, at &lt;a class=&quot;sorc&quot; data-accessed=&quot;2013-03-27&quot; href=&quot;https://pypi.python.org/pypi/dragonfly/0.6.5&quot;&gt;https://pypi.python.org/pypi/dragonfly/0.6.5&lt;/a&gt;.
 So now he can define his own voice commands. (type things, or move 
cursor to particular place in code, or keyboard shortcuts, switch apps, 
…, etc.)&lt;/li&gt;
&lt;li&gt;He created many short idiosyncratic/unique vocal utterances to do 
many things, such as insert line return, switch emacs buffer, start 
terminal, etc. So, when he&#39;s voice coding, you hear “twip, chirp, slap, 
derp, …”. Very funny.&lt;/li&gt;
&lt;li&gt;He has about 2k personal commands.&lt;/li&gt;
&lt;li&gt;He said everything he do with his system is inside vim or emacs. (in
 his demo, it seems it&#39;s all emacs, as interface to everything else. 
There&#39;s heavy use emacs features, including templates/completion, shell 
in emacs.).&lt;/li&gt;
&lt;li&gt;He demonstrated using it to code Emacs Lisp, Python, work in emacs, 
terminal. So efficient that it&#39;s faster than average programer can with 
hands on keyboard.&lt;/li&gt;
&lt;li&gt;Took him 3 to 6 months to come up with his system.&lt;/li&gt;
&lt;li&gt;His Repetitive Strain Injury (RSI) is completely healed by now, but 
he says he still use his voice system for coding, for about 40% to 60% 
of time.&lt;/li&gt;
&lt;li&gt;He said he&#39;ll release his code in about 4 months, follow him on twitter or github. &lt;a class=&quot;sorc&quot; data-accessed=&quot;2013-03-27&quot; href=&quot;https://github.com/tavisrudd&quot;&gt;https://github.com/tavisrudd&lt;/a&gt;, &lt;a class=&quot;sorc&quot; data-accessed=&quot;2013-03-27&quot; href=&quot;https://twitter.com/tavisrudd&quot;&gt;@tavisrudd&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
the expensive microphone he recommended is 〈Audix OM-7 Microphone〉 &lt;a class=&quot;amz&quot; href=&quot;http://www.amazon.com/dp/B0002H0M7W/?tag=xahh-20&quot; title=&quot;Audix OM7 OM 7 Microphone&quot;&gt;amazon&lt;/a&gt;&lt;br /&gt;
I&#39;ve used Microsoft speech recognition system, for a few months in 
2010. It comes with Microsoft Windows 7. It&#39;s pretty good for normal 
speech but impossible for coding (out of the box). It works well in 
normal Windows apps, especially ones from Microsoft such as Office, but 
doesn&#39;t work well in emacs.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/8380180926822810513/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/using-voice-to-code-faster-than-keyboard.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/8380180926822810513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/8380180926822810513'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/using-voice-to-code-faster-than-keyboard.html' title='Using Voice to Code Faster than Keyboard'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/8SkdfdXWYaI/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-6982430591021863714</id><published>2013-08-12T08:02:00.001-07:00</published><updated>2013-08-12T08:02:32.414-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="The algorithm for a perfectly balanced photo gallery"/><title type='text'>The algorithm for a perfectly balanced photo gallery</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://bit.ly/14oP7Xf&quot; target=&quot;_blank&quot;&gt;The algorithm for a perfectly balanced photo gallery&lt;/a&gt;&lt;/h1&gt;
&lt;h1 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;/h1&gt;
&lt;div class=&quot;meta&quot;&gt;
          &lt;a href=&quot;http://twitter.com/jtreitz&quot;&gt;Johannes Treitz&lt;/a&gt;
          on August 11th, 2013
          in
          &lt;a href=&quot;http://www.crispymtn.com/stories/technology&quot;&gt;Technology&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;meta&quot;&gt;
&amp;nbsp;
        &lt;/div&gt;
Remember the days in college when you learned all about the
        &lt;a href=&quot;http://en.wikipedia.org/wiki/Big_O_notation&quot; title=&quot;&quot;&gt;big Oh!&#39;s&lt;/a&gt; and re-implemented &lt;a href=&quot;http://en.wikipedia.org/wiki/Bubble_sort&quot; title=&quot;&quot;&gt;all&lt;/a&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/Quicksort&quot; title=&quot;&quot;&gt;these&lt;/a&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/Merge_sort&quot; title=&quot;&quot;&gt;sort-algorithms&lt;/a&gt;
 for the hundredth time? If you are a web developer like me, chances are
 you never had to touch a single one of these algorithms ever again.&lt;br /&gt;
&lt;br /&gt;

        
        I mean, hands down, 99% of the hard work in web development is working around &lt;a href=&quot;http://mlkshk.com/p/PPML&quot; title=&quot;&quot;&gt;browser quirks&lt;/a&gt; and messing with other people&#39;s code.&lt;br /&gt;
&lt;br /&gt;

        
        And then, all the sudden, that algorithm knowledge actually becomes very useful.&lt;br /&gt;

        
        &lt;h2&gt;
The idea&lt;/h2&gt;
Ever since we started working on &lt;a href=&quot;http://www.chromatic.io/&quot; title=&quot;&quot;&gt;Chromatic&lt;/a&gt;
 we knew we wanted the photos to be as big as possible. No tiny 
thumbnails, no square-cropping, no wasting of precious screen real 
estate.&lt;br /&gt;

        
        Galleries typically have between 10 and 100 photos with 
various aspect ratios (that&#39;s width divided by height) and we want them 
to be &lt;a href=&quot;http://www.chromatic.io/FQrLQsb&quot;&gt;equally distributed&lt;/a&gt; over the rows, taking up all the space available.&lt;br /&gt;

        
        Here&#39;s the kicker: While it looks like all the photos are the
 same height, each row is scaled slightly as a whole to fit in the 
horizontal space.&lt;br /&gt;

        
        &lt;h2&gt;
The problem&lt;/h2&gt;
But how do we know how to distribute them? As soon as you 
leave the well-trodden paths of how-do-I-get-library-x-to-do-y it gets 
much harder to elicit an answer from &lt;a href=&quot;http://stackoverflow.com/questions/tagged/jquery&quot; title=&quot;&quot;&gt;StackOverflow&lt;/a&gt;.&lt;br /&gt;

        
        Then we started thinking of our problem in an algorithmic sense:&lt;br /&gt;

        
        &lt;blockquote&gt;
Might this be a well-known standard problem? &lt;br /&gt; Or can it be turned into one?&lt;/blockquote&gt;
If so, chances are high someone already came up with an algorithm to solve it.&lt;br /&gt;

        
        Turns out it actually &lt;em&gt;was&lt;/em&gt;: &lt;a href=&quot;http://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK2/NODE45.HTM&quot; title=&quot;&quot;&gt;The partition problem&lt;/a&gt;. And even better, there was a working &lt;a href=&quot;http://stackoverflow.com/a/7942946&quot; title=&quot;&quot;&gt;Python implementation&lt;/a&gt; which we &lt;a href=&quot;https://github.com/crispymtn/linear-partition&quot;&gt;ported to Coffeescript.&lt;/a&gt;&lt;br /&gt;

        
        &lt;h2&gt;
The solution&lt;/h2&gt;
Once we got that down, the rest was fairly easy.&lt;br /&gt;
&lt;br /&gt;

        
        To find the number of rows (&lt;em&gt;k&lt;/em&gt;) needed, we first 
scale the photos to half the window&#39;s height (we found the photos look 
best when scaled to roughly half the window&#39;s height), sum up their 
widths, then divide by the window&#39;s width. That&#39;s probably not a whole 
number, so we round it.&lt;br /&gt;
&lt;br /&gt;

        
        The photos&#39; aspect ratios (multiplied by 100 and rounded) serve as a set (&lt;em&gt;S&lt;/em&gt;) of weights. We now use our newly gained algorithmic superpowers to find the perfect distribution of set &lt;em&gt;S&lt;/em&gt; over &lt;em&gt;k&lt;/em&gt;.&lt;br /&gt;
&lt;br /&gt;

        
        The result tells us the number of photos in each row. All we 
have left to do is fill the row with the appropriate range of photos and
 scale it to fit in the horizontal space available.&lt;br /&gt;
&lt;br /&gt;

        
        Here&#39;s the relevant code from the &lt;a href=&quot;http://backbonejs.org/&quot;&gt;Backbone&lt;/a&gt; gallery view. The actual linear partition algorithm can be found &lt;a href=&quot;https://github.com/crispymtn/linear-partition&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;

        &lt;code&gt;viewport_width = $(window).width()
ideal_height = parseInt($(window).height() / 2)
summed_width = photos.reduce ((sum, p) -&amp;gt; sum += 
p.get(&#39;aspect_ratio&#39;) * ideal_height), 0
rows = Math.round(summed_width / viewport_width)
 
if rows &amp;lt; 1
  # (2a) Fallback to just standard size 
  photos.each (photo) -&amp;gt; photo.view.resize parseInt(ideal_height * 
photo.get(&#39;aspect_ratio&#39;)), ideal_height
else
  # (2b) Distribute photos over rows using the aspect ratio as weight
  weights = photos.map (p) -&amp;gt; parseInt(p.get(&#39;aspect_ratio&#39;) * 100)
  partition = linear_partition(weights, rows)

  # (3) Iterate through partition
  index = 0
  row_buffer = new Backbone.Collection
  _.each partition, (row) -&amp;gt;
    row_buffer.reset()
    _.each row, -&amp;gt; row_buffer.add(photos.at(index++))
    summed_ratios = row_buffer.reduce ((sum, p) -&amp;gt; sum += 
p.get(&#39;aspect_ratio&#39;)), 0
    row_buffer.each (photo) -&amp;gt; photo.view.resize 
parseInt(viewport_width / summed_ratios * photo.get(&#39;aspect_ratio&#39;)), 
parseInt(viewport_width / summed_ratios)&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&lt;/code&gt;
        
        &lt;br /&gt;
It&#39;s taken a considerable effort, but hey, &lt;a href=&quot;http://www.chromatic.io/FQrLQsb&quot;&gt;look at the outcome!&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;

        &lt;a class=&quot;tweet&quot; href=&quot;http://twitter.com/share?text=The%20algorithm%20for%20a%20perfectly%20balanced%20photo%20gallery&amp;amp;via=crispymtn&quot;&gt;Tweet about this&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/6982430591021863714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/the-algorithm-for-perfectly-balanced.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/6982430591021863714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/6982430591021863714'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/the-algorithm-for-perfectly-balanced.html' title='The algorithm for a perfectly balanced photo gallery'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-2362842851445606172</id><published>2013-08-11T10:11:00.003-07:00</published><updated>2013-08-11T10:12:31.574-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TextBlob: Simplified Text Processing"/><title type='text'>TextBlob: Simplified Text Processing</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1&gt;
&lt;a href=&quot;http://bit.ly/13t1diZ&quot;&gt;TextBlob: Simplified Text Processing&lt;/a&gt;&lt;/h1&gt;
Release v0.5.0. (&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/install.html#install&quot;&gt;&lt;i&gt;Installation&lt;/i&gt;&lt;/a&gt;)&lt;br /&gt;
&lt;cite&gt;TextBlob&lt;/cite&gt; is a Python (2 and 3) library for processing 
textual data. It provides a simple API for diving into common natural 
language processing (NLP) tasks such as part-of-speech tagging, noun 
phrase extraction, sentiment analysis, translation, and more.&lt;br /&gt;
&lt;div class=&quot;highlight-python&quot;&gt;
&lt;div class=&quot;highlight&quot;&gt;
&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;text.blob&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TextBlob&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;&#39;&#39;&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;The titular threat of The Blob has always struck me as the ultimate movie&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;monster: an insatiably hungry, amoeba-like mass able to penetrate&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;virtually any safeguard, capable of--as a doomed doctor chillingly&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;describes it--&quot;assimilating flesh on contact.&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;Snide comparisons to gelatin be damned, it&#39;s a concept with the most&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;devastating of potential consequences, not unlike the grey goo scenario&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;proposed by technological theorists fearful of&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;artificial intelligence run rampant.&lt;/span&gt;
&lt;span class=&quot;s&quot;&gt;&#39;&#39;&#39;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;blob&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TextBlob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;blob&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tags&lt;/span&gt;           &lt;span class=&quot;c&quot;&gt;# [(u&#39;The&#39;, u&#39;DT&#39;), (u&#39;titular&#39;, u&#39;JJ&#39;),&lt;/span&gt;
                    &lt;span class=&quot;c&quot;&gt;#  (u&#39;threat&#39;, u&#39;NN&#39;), (u&#39;of&#39;, u&#39;IN&#39;), ...]&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;blob&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;noun_phrases&lt;/span&gt;   &lt;span class=&quot;c&quot;&gt;# WordList([&#39;titular threat&#39;, &#39;blob&#39;,&lt;/span&gt;
                    &lt;span class=&quot;c&quot;&gt;#            &#39;ultimate movie monster&#39;,&lt;/span&gt;
                    &lt;span class=&quot;c&quot;&gt;#            &#39;amoeba-like mass&#39;, ...])&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blob&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentiment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;# returns (polarity, subjectivity)&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# (0.060, 0.605)&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# (-0.341, 0.767)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;blob&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;translate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;es&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;# &#39;La amenaza titular de The Blob...&#39;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
TextBlob stands on the giant shoulders of &lt;a class=&quot;reference external&quot; href=&quot;http://www.nltk.org/&quot;&gt;NLTK&lt;/a&gt; and &lt;a class=&quot;reference external&quot; href=&quot;http://www.clips.ua.ac.be/pages/pattern-en&quot;&gt;pattern&lt;/a&gt;, and plays nicely with both.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;section&quot; id=&quot;features&quot;&gt;
&lt;h2&gt;
Features&lt;/h2&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;Noun phrase extraction&lt;/li&gt;
&lt;li&gt;Part-of-speech tagging&lt;/li&gt;
&lt;li&gt;Sentiment analysis&lt;/li&gt;
&lt;li&gt;Language translation and detection powered by Google Translate (&lt;i&gt;new in 0.5.0&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;Tokenization (splitting text into words and sentences)&lt;/li&gt;
&lt;li&gt;Word and phrase frequencies&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;n&lt;/cite&gt;-grams&lt;/li&gt;
&lt;li&gt;Word inflection (pluralization and singularization)&lt;/li&gt;
&lt;li&gt;JSON serialization&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;get-it-now&quot;&gt;
&lt;h2&gt;
Get it now&lt;/h2&gt;
&lt;div class=&quot;highlight-python&quot;&gt;
&lt;pre&gt;$ pip install -U textblob
$ curl https://raw.github.com/sloria/TextBlob/master/download_corpora.py | python&lt;/pre&gt;
&lt;/div&gt;
Ready to dive in? Go on to the &lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#quickstart&quot;&gt;&lt;i&gt;Quickstart guide&lt;/i&gt;&lt;/a&gt;.&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;guide&quot;&gt;
&lt;h1&gt;
Guide&lt;/h1&gt;
&lt;div class=&quot;toctree-wrapper compound&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;toctree-l1&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/license.html&quot;&gt;License&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l1&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/install.html&quot;&gt;Installation&lt;/a&gt;&lt;ul&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/install.html#from-the-pypi&quot;&gt;From the PyPI&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/install.html#from-source&quot;&gt;From Source&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/install.html#upgrading&quot;&gt;Upgrading&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toctree-l1&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html&quot;&gt;Quickstart&lt;/a&gt;&lt;ul&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#create-a-textblob&quot;&gt;Create a TextBlob&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#part-of-speech-tagging&quot;&gt;Part-of-speech Tagging&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#noun-phrase-extraction&quot;&gt;Noun Phrase Extraction&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#sentiment-analysis&quot;&gt;Sentiment Analysis&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#tokenization&quot;&gt;Tokenization&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#words-and-inflection&quot;&gt;Words and Inflection&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#wordlists&quot;&gt;WordLists&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#get-word-and-noun-phrase-frequencies&quot;&gt;Get Word and Noun Phrase Frequencies&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#translation-and-language-detection&quot;&gt;Translation and Language Detection&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#textblobs-are-like-python-strings&quot;&gt;TextBlobs Are Like Python Strings!&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#n-grams&quot;&gt;&lt;cite&gt;n&lt;/cite&gt;-grams&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#get-start-and-end-indices-of-sentences&quot;&gt;Get Start and End Indices of Sentences&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#dealing-with-html&quot;&gt;Dealing with HTML&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/quickstart.html#get-a-json-serialized-version-of-a-blob&quot;&gt;Get a JSON-serialized version of a blob&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toctree-l1&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/advanced_usage.html&quot;&gt;Advanced Usage&lt;/a&gt;&lt;ul&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/advanced_usage.html#sentiment-analyzers&quot;&gt;Sentiment Analyzers&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/advanced_usage.html#tokenizers&quot;&gt;Tokenizers&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/advanced_usage.html#noun-phrase-chunkers&quot;&gt;Noun Phrase Chunkers&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/advanced_usage.html#pos-taggers&quot;&gt;POS Taggers&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/advanced_usage.html#blobber-a-textblob-factory&quot;&gt;Blobber: A TextBlob Factory&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toctree-l1&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/api_reference.html&quot;&gt;API Reference&lt;/a&gt;&lt;ul&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/api_reference.html#module-text.blob&quot;&gt;Blob Classes&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/api_reference.html#lower-level-classes&quot;&gt;Lower-level classes&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/api_reference.html#tokenizers&quot;&gt;Tokenizers&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/api_reference.html#module-text.taggers&quot;&gt;POS Taggers&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/api_reference.html#module-text.np_extractors&quot;&gt;Noun Phrase Extractors&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/api_reference.html#sentiment-analyzers&quot;&gt;Sentiment Analyzers&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/api_reference.html#blobber&quot;&gt;Blobber&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/api_reference.html#module-text.exceptions&quot;&gt;Exceptions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;project-info&quot;&gt;
&lt;h1&gt;
Project info&lt;/h1&gt;
&lt;div class=&quot;toctree-wrapper compound&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;toctree-l1&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/contributing.html&quot;&gt;Contributing guidelines&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l1&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/changelog.html&quot;&gt;Changelog&lt;/a&gt;&lt;ul&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/changelog.html#id1&quot;&gt;0.5.0 (2013-08-10)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/changelog.html#id2&quot;&gt;0.4.0 (2013-08-05)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/changelog.html#id3&quot;&gt;0.3.10 (2013-08-02)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/changelog.html#id4&quot;&gt;0.3.9 (2013-07-31)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/changelog.html#id5&quot;&gt;0.3.8 (2013-07-30)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toctree-l2&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://textblob.readthedocs.org/en/latest/changelog.html#id6&quot;&gt;0.3.7 (2013-07-28)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/2362842851445606172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/textblob-simplified-text-processing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/2362842851445606172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/2362842851445606172'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/textblob-simplified-text-processing.html' title='TextBlob: Simplified Text Processing'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-7132682381413049780</id><published>2013-08-11T10:00:00.001-07:00</published><updated>2013-08-11T10:00:30.678-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Agda"/><title type='text'>Agda by Example: λ-calculus</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;article&quot;&gt;
  &lt;h1&gt;
&lt;a href=&quot;http://bit.ly/13t0f6f&quot;&gt;&lt;em&gt;2013-08-10&lt;/em&gt; Agda by Example: λ-calculus&lt;/a&gt;&lt;/h1&gt;
In the &lt;a href=&quot;http://mazzo.li/posts/AgdaSort.html&quot;&gt;previous Agda example&lt;/a&gt;
 we saw how we can approach the task of verifying a sorting function. 
This time, we are going to write a type checker for the simply typed 
λ-calculus, plus a simple optimization on said terms that we will prove 
correct. As in the other post the bulk of the thinking has been done by 
other people. The type checking is a modified version of an example 
given in &lt;a href=&quot;http://strictlypositive.org/view.ps.gz&quot;&gt;&lt;em&gt;The View from the Left&lt;/em&gt;&lt;/a&gt; by Conor McBride and James McKinna,&lt;sup&gt;&lt;a class=&quot;footnoteRef&quot; href=&quot;http://mazzo.li/posts/Lambda.html#fn1&quot; id=&quot;fnref1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; while the optimisation is inspired from a talk given by Adam Chlipala at POPL 2013—his Coq book &lt;a href=&quot;http://adam.chlipala.net/cpdt/&quot;&gt;&lt;em&gt;Certified Programming with Dependent Types&lt;/em&gt;&lt;/a&gt; contains many similar examples.&lt;br /&gt;

Let’s get started.&lt;br /&gt;

&lt;h2 id=&quot;useful-imports&quot;&gt;
&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#useful-imports&quot;&gt;Useful imports&lt;/a&gt;&lt;/h2&gt;
&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1031&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1046&quot;&gt;module&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1052&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Module&quot; href=&quot;http://mazzo.li/posts/Lambda.html#1&quot; name=&quot;1053&quot;&gt;Lambda&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1059&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1060&quot;&gt;where&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1065&quot;&gt;

&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1067&quot;&gt;open&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1071&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1072&quot;&gt;import&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1078&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Module&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1079&quot;&gt;Data.Nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1087&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1088&quot;&gt;using&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1093&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1094&quot;&gt;(&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1095&quot;&gt;ℕ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1096&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1097&quot;&gt; zero&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1102&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1103&quot;&gt; suc&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1107&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1108&quot;&gt; _+_&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1112&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1113&quot;&gt; _≤?_&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1118&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1119&quot;&gt; _≥_&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1123&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1124&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1125&quot;&gt;open&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1129&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1130&quot;&gt;import&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1136&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Module&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1137&quot;&gt;Data.Fin&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1145&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1146&quot;&gt;using&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1151&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1152&quot;&gt;(&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1153&quot;&gt;Fin&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1156&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1157&quot;&gt; zero&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1162&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1163&quot;&gt; suc&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1167&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1168&quot;&gt; toℕ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1172&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1173&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1174&quot;&gt;open&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1178&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1179&quot;&gt;import&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1185&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Module&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1186&quot;&gt;Data.List&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1195&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1196&quot;&gt;using&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1201&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1202&quot;&gt;(&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1203&quot;&gt;List&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1207&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1208&quot;&gt; []&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1211&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1212&quot;&gt; _∷_&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1216&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1217&quot;&gt; length&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1224&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1225&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1226&quot;&gt;open&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1230&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1231&quot;&gt;import&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1237&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Module&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1238&quot;&gt;Data.Vec&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1246&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1247&quot;&gt;using&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1252&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1253&quot;&gt;(&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1254&quot;&gt;Vec&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1257&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1258&quot;&gt; []&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1261&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1262&quot;&gt; _∷_&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1266&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1267&quot;&gt; lookup&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1274&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1275&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1276&quot;&gt;open&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1280&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1281&quot;&gt;import&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1287&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Module&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1288&quot;&gt;Relation.Binary.PropositionalEquality&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1325&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1326&quot;&gt;using&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1331&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1332&quot;&gt;(&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1333&quot;&gt;_≡_&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1336&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1337&quot;&gt; refl&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1342&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1343&quot;&gt; cong&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1348&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1349&quot;&gt; cong₂&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1355&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1356&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1357&quot;&gt;open&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1361&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1362&quot;&gt;import&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1368&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Module&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1369&quot;&gt;Relation.Nullary&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1385&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1386&quot;&gt;using&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1391&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1392&quot;&gt;(&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1393&quot;&gt;Dec&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1396&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1397&quot;&gt; yes&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1401&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1402&quot;&gt; no&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1405&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1406&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1407&quot;&gt;open&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1411&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1412&quot;&gt;import&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1418&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Module&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1419&quot;&gt;Function&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1427&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1428&quot;&gt;using&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1433&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1434&quot;&gt;(&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1435&quot;&gt;_∘_&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1438&quot;&gt;;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1439&quot;&gt; _$_&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1443&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1444&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1445&quot;&gt;open&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1449&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1450&quot;&gt;import&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;1456&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Module&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;1457&quot;&gt;Data.Product&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
After the module declaration, we include some useful modules from the &lt;a href=&quot;http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Libraries.StandardLibrary&quot;&gt;Agda standard library&lt;/a&gt;:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cse.chalmers.se/%7Enad/listings/lib-0.7/Data.Nat.html&quot;&gt;&lt;code&gt;Data.Nat&lt;/code&gt;&lt;/a&gt; defines natural numbers.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cse.chalmers.se/%7Enad/listings/lib-0.7/Data.Fin.html&quot;&gt;&lt;code&gt;Data.Fin&lt;/code&gt;&lt;/a&gt; defines an inductive families to represent the type of all numbers less than a given number. For instance &lt;code&gt;Fin 3&lt;/code&gt; will be inhabited by &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt;, and &lt;code&gt;2&lt;/code&gt;. Another interpretation is that &lt;code&gt;Fin n&lt;/code&gt; is the type inhabited by &lt;code&gt;n&lt;/code&gt; elements.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cse.chalmers.se/%7Enad/listings/lib-0.7/Data.List.html&quot;&gt;&lt;code&gt;Data.List&lt;/code&gt;&lt;/a&gt;, predictably, defines finite lists.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cse.chalmers.se/%7Enad/listings/lib-0.7/Data.Vec.html&quot;&gt;&lt;code&gt;Data.Vec&lt;/code&gt;&lt;/a&gt; defines lists indexed by their length. This allows, for example, for safe indexing of elements.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cse.chalmers.se/%7Enad/listings/lib-0.7/Relation.Binary.PropositionalEquality.html&quot;&gt;&lt;code&gt;Relation.Binary.PropositionalEquality&lt;/code&gt;&lt;/a&gt; defines propositional equality as &lt;a href=&quot;http://mazzo.li/posts/AgdaSort.html#propositional-equality&quot;&gt;presented&lt;/a&gt; in the previous post. &lt;code&gt;cong₂&lt;/code&gt; is the two-argument version of &lt;code&gt;cong&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cse.chalmers.se/%7Enad/listings/lib-0.7/Relation.Nullary.html#1&quot;&gt;&lt;code&gt;Relation.Nullary&lt;/code&gt;&lt;/a&gt; defines a type for decidable relations, &lt;code&gt;Dec&lt;/code&gt;:&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;data Dec (P : Set) : Set where
  yes : ( p :   P) → Dec P
  no  : (¬p : ¬ P) → Dec P&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cse.chalmers.se/%7Enad/listings/lib-0.7/Function.html&quot;&gt;&lt;code&gt;Function&lt;/code&gt;&lt;/a&gt;
 exports some common utilities regarding functions that should be 
familiar to the Haskell programmer, such as function composition (&lt;code&gt;_∘_&lt;/code&gt;) and explicit application (&lt;code&gt;_$_&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;simple-types-and-raw-terms&quot;&gt;
&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#simple-types-and-raw-terms&quot;&gt;Simple types and raw terms&lt;/a&gt;&lt;/h2&gt;
The language we are going to define is a simple &lt;a href=&quot;http://en.wikipedia.org/wiki/Simply_typed_lambda_calculus&quot;&gt;simply typed λ-calculus&lt;/a&gt;. The types for our language will be of two kinds: natural numbers and functions (arrow types):&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3462&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3477&quot;&gt;infixr&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3483&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Number&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3484&quot;&gt;30&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3486&quot;&gt; _⇒_
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3491&quot;&gt;data&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3495&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;3496&quot;&gt;Type&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3500&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3501&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3502&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3503&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3506&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3507&quot;&gt;where&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3512&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;3515&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3518&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3519&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3520&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;3521&quot;&gt;Type&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3525&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;3528&quot;&gt;_⇒_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3531&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3532&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3533&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;3534&quot;&gt;Type&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3538&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3539&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3540&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;3541&quot;&gt;Type&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3545&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;3546&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;3547&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;3548&quot;&gt;Type&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
We will use &lt;a href=&quot;http://en.wikipedia.org/wiki/De_Bruijn_index&quot;&gt;de Bruijn indices&lt;/a&gt; to represent bound variables, where &lt;code&gt;n&lt;/code&gt; represents the variable bound by the &lt;code&gt;n&lt;/code&gt;-th &lt;code&gt;λ&lt;/code&gt; going towards the top of the term. For example, using an Haskell notation for &lt;code&gt;λ&lt;/code&gt;s, we will have that&lt;br /&gt;

&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&quot;header&quot;&gt;
&lt;th align=&quot;left&quot;&gt;Named&lt;/th&gt;
&lt;th align=&quot;left&quot;&gt;de Bruijn&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&quot;odd&quot;&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code&gt;λx → x&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code&gt;λ 1&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;even&quot;&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code&gt;λx → λy → x&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code&gt;λ λ 2&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;odd&quot;&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code&gt;λx → λy → λz → x z (y z)&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;left&quot;&gt;&lt;code&gt;λ λ λ 3 1 (2 1)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
and so on. de Bruijn notation is a terrible device for humans to use 
directly, but it is often more convenient when dealing with terms 
mechanically. When parsing a language it is easy to go from names to 
nameless, so that we can have the best of both worlds.&lt;br /&gt;

Thus we will have:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4365&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4380&quot;&gt;infixl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4386&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Number&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4387&quot;&gt;80&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4389&quot;&gt; _·_
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4394&quot;&gt;data&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4398&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4399&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4405&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4406&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4407&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4408&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4411&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4412&quot;&gt;where&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4417&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;Comment&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4420&quot;&gt;-- A variable, the ℕ being a de Bruijn index.&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4465&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4468&quot; name=&quot;4468&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4471&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4472&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4473&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4474&quot;&gt;ℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4475&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4476&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4477&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4478&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4484&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;Comment&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4487&quot;&gt;-- A number literal.&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4507&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4510&quot; name=&quot;4510&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4513&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4514&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4515&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4516&quot;&gt;ℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4517&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4518&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4519&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4520&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4526&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;Comment&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4529&quot;&gt;-- Addition.&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4541&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4544&quot; name=&quot;4544&quot;&gt;_⊕_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4547&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4548&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4549&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4550&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4556&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4557&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4558&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4559&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4565&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4566&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4567&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4568&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4574&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;Comment&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4577&quot;&gt;-- Function application.&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4601&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4604&quot; name=&quot;4604&quot;&gt;_·_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4607&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4608&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4609&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4610&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4616&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4617&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4618&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4619&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4625&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4626&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4627&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4628&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4634&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;Comment&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4637&quot;&gt;-- Lambda abstraction, the type indicates the type of the argument: no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4707&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;Comment&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4710&quot;&gt;-- type inference here.&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4733&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4736&quot; name=&quot;4736&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4739&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4740&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4741&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;4742&quot;&gt;Type&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4746&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4747&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4748&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4749&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4755&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;4756&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;4757&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;4758&quot;&gt;Syntax&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;typed-terms-and-type-checking&quot;&gt;
&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#typed-terms-and-type-checking&quot;&gt;Typed terms, and type checking&lt;/a&gt;&lt;/h2&gt;
Our λ-calculus has a very unsurprising type system. Typing judgements
 will be done in a context, holding the types of the abstracted 
variables. Calling the context &lt;code&gt;Γ&lt;/code&gt;, we can give typing judgements for our syntax:&lt;br /&gt;

&lt;div class=&quot;center-image&quot;&gt;
&lt;img alt=&quot;The type system for our language&quot; src=&quot;http://mazzo.li/images/lambda-typ.png&quot; /&gt;
&lt;/div&gt;
For those unfamiliar with typing rules like the ones above, they can 
be read as “given what’s above the bar, what’s below holds”. In our case
 we have judgements of the form &lt;code&gt;Γ ⊢ t : τ&lt;/code&gt;, which can be read as “In context &lt;code&gt;Γ&lt;/code&gt;, term &lt;code&gt;t&lt;/code&gt; has type &lt;code&gt;τ&lt;/code&gt;”.&lt;br /&gt;

&lt;code class=&quot;sc&quot;&gt;Lit&lt;/code&gt; says that number literals have type &lt;code&gt;nat&lt;/code&gt;. &lt;code class=&quot;sc&quot;&gt;Add&lt;/code&gt; says that given two terms of type &lt;code&gt;nat&lt;/code&gt;, we can add them together yielding another term of type &lt;code&gt;nat&lt;/code&gt;. &lt;code class=&quot;sc&quot;&gt;Var&lt;/code&gt;
 says that given a variable we can get its type by looking it up in the 
context—we haven’t defined what a context is but we will soon. &lt;code class=&quot;sc&quot;&gt;App&lt;/code&gt; says that given a function of type &lt;code&gt;τ ⇒ σ&lt;/code&gt; we can apply it to a term of type &lt;code&gt;τ&lt;/code&gt; to get a term of type &lt;code&gt;σ&lt;/code&gt;. Finally, if we have a term &lt;code&gt;t : τ&lt;/code&gt; in a context with &lt;code&gt;σ&lt;/code&gt; “at its head”, we can form a function of type &lt;code&gt;σ ⇒ τ&lt;/code&gt;, typed in the context with &lt;code&gt;σ&lt;/code&gt; removed (&lt;code class=&quot;sc&quot;&gt;Lam&lt;/code&gt;).&lt;br /&gt;

Now, taking advantage of Agda’s facilities, we can define a &lt;code&gt;Term&lt;/code&gt; data type to represent terms together with their type—a &lt;code&gt;Term&lt;/code&gt; will essentially include a derivation that its type is valid.&lt;br /&gt;

We will represent the context as a &lt;code&gt;Vec&lt;/code&gt; containing &lt;code&gt;Type&lt;/code&gt;s. The fact that &lt;code&gt;Vec&lt;/code&gt;
 carry their length at the type is useful, since it will indicate how 
many variables are in scope, and thus what the largest de Bruijn index 
is.&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6480&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;6495&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6498&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6499&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6500&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6501&quot;&gt;ℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6502&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6503&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6504&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6505&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6508&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;6509&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6512&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6513&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6514&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6515&quot;&gt;Vec&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6518&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;6519&quot;&gt;Type&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
A type checked &lt;code&gt;Term&lt;/code&gt; will be parametrised over a context &lt;code&gt;Γ&lt;/code&gt; of some length &lt;code&gt;n&lt;/code&gt;.
 Moreover, it will be indexed by its type. The type is an index because 
different constructors will be typed differently, just like in the 
typing derivations.&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6777&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6792&quot;&gt;data&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6796&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;6797&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6801&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6802&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6803&quot; name=&quot;6803&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6804&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6805&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6806&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;6807&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6808&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6809&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6810&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;6811&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6814&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6803&quot; name=&quot;6815&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6816&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6817&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6818&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6819&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;6820&quot;&gt;Type&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6824&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6825&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6826&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6827&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6830&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6831&quot;&gt;where&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6836&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6839&quot; name=&quot;6839&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6842&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6843&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6844&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6845&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6846&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6847&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6848&quot; name=&quot;6848&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6849&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6850&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6851&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6852&quot; name=&quot;6852&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6853&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6854&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6855&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6856&quot;&gt;Fin&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6859&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6803&quot; name=&quot;6860&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6861&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6862&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6863&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6864&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6848&quot; name=&quot;6865&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6866&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6867&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6868&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6869&quot;&gt;lookup&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6875&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6852&quot; name=&quot;6876&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6877&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;6878&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6879&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6880&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6881&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;6882&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6886&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;6887&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6888&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6848&quot; name=&quot;6889&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6890&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6893&quot; name=&quot;6893&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6896&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6897&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6898&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6899&quot;&gt;ℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6900&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6901&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6902&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;6903&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6907&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;6908&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6909&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;6910&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6913&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6916&quot; name=&quot;6916&quot;&gt;_⊕_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6919&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6920&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6921&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;6922&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6926&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;6927&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6928&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;6929&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6932&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6933&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6934&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;6935&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6939&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;6940&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6941&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;6942&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6945&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6946&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6947&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;6948&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6952&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;6953&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6954&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;6955&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6958&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6961&quot; name=&quot;6961&quot;&gt;_·_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6964&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6965&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6966&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6967&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6968&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6969&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6970&quot; name=&quot;6970&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6971&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6972&quot; name=&quot;6972&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6973&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6974&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6975&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6976&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;6977&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6981&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;6982&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6983&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6984&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6970&quot; name=&quot;6985&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6986&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;6987&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6988&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6972&quot; name=&quot;6989&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6990&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6991&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;6992&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6993&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;6994&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;6998&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;6999&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7000&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6970&quot; name=&quot;7001&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7002&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7003&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7004&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;7005&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7009&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;7010&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7011&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6972&quot; name=&quot;7012&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7013&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7016&quot; name=&quot;7016&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7019&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7020&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7021&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7022&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7023&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7024&quot; name=&quot;7024&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7025&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7026&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7027&quot; name=&quot;7027&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7028&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7029&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7030&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7031&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;7032&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7036&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7037&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7024&quot; name=&quot;7038&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7039&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7040&quot;&gt;∷&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7041&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;7042&quot;&gt;Γ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7043&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7044&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7027&quot; name=&quot;7045&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7046&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7047&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7048&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;7049&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7053&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6807&quot; name=&quot;7054&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7055&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7056&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7024&quot; name=&quot;7057&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7058&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;7059&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7060&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7027&quot; name=&quot;7061&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7062&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Note that in the &lt;code&gt;var&lt;/code&gt; case we could have written&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;var : (v : Fin n) → Term Γ (lookup v Γ)&lt;/code&gt;&lt;/pre&gt;
However this would have caused problems further down the line,&lt;sup&gt;&lt;a class=&quot;footnoteRef&quot; href=&quot;http://mazzo.li/posts/Lambda.html#fn2&quot; id=&quot;fnref2&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; and thus we quantify over a type &lt;code&gt;τ&lt;/code&gt; and use an explicit equality.&lt;br /&gt;

Also in &lt;code&gt;var&lt;/code&gt;, we use &lt;code&gt;Fin&lt;/code&gt; to make sure that the index is indeed “in scope”. If the context is of length &lt;code&gt;n&lt;/code&gt;, an index of type &lt;code&gt;Fin n&lt;/code&gt; makes sure that we can look up the type of the variable, since &lt;code&gt;Fin n&lt;/code&gt; represents the type of all naturals less than &lt;code&gt;n&lt;/code&gt;:&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;lookup : ∀ {n} {A : Set} → Fin n → Vec A n → A&lt;/code&gt;&lt;/pre&gt;
Closed terms will be those living in empty contexts:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7757&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7772&quot; name=&quot;7772&quot;&gt;Closed&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7778&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7779&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7780&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;7781&quot;&gt;Type&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7785&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7786&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7787&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7788&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7791&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7772&quot; name=&quot;7792&quot;&gt;Closed&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7798&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7799&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7800&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;7801&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7805&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7806&quot;&gt;[]&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
For example, we can write a function doubling numbers in &lt;code&gt;Term&lt;/code&gt;. The type will predictably be &lt;code&gt;nat ⇒ nat&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7928&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7943&quot; name=&quot;7943&quot;&gt;double&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7949&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7950&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7951&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7772&quot; name=&quot;7952&quot;&gt;Closed&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7958&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7959&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;7960&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7963&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;7964&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7965&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;7966&quot;&gt;nat&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7969&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7970&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7943&quot; name=&quot;7971&quot;&gt;double&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7977&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7978&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7979&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7016&quot; name=&quot;7980&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7983&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;7984&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7987&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7988&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6839&quot; name=&quot;7989&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7992&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7993&quot;&gt;zero&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;7997&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;7998&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8002&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6916&quot; name=&quot;8003&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8004&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6839&quot; name=&quot;8005&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8008&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8009&quot;&gt;zero&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8013&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8014&quot;&gt;refl&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8018&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
We can also write a function that forgets the type information and gets us &lt;code&gt;Syntax&lt;/code&gt; from &lt;code&gt;Term&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8128&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8143&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8148&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8149&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8150&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8151&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8152&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8153&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8154&quot; name=&quot;8154&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8155&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8156&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8157&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8158&quot; name=&quot;8158&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8159&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8160&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8161&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;8162&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8165&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8154&quot; name=&quot;8166&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8167&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8168&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8169&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8170&quot; name=&quot;8170&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8171&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8172&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8173&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8174&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;8175&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8179&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8158&quot; name=&quot;8180&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8181&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8170&quot; name=&quot;8182&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8183&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8184&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8185&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;8186&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8192&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8193&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8198&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8199&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6839&quot; name=&quot;8200&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8203&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8204&quot; name=&quot;8204&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8205&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8206&quot;&gt;_)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8208&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8209&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8210&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4468&quot; name=&quot;8211&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8214&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8215&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8216&quot;&gt;toℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8219&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8204&quot; name=&quot;8220&quot;&gt;v&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8221&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8222&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8223&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8228&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8229&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6893&quot; name=&quot;8230&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8233&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8234&quot; name=&quot;8234&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8235&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8236&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8239&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8240&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4510&quot; name=&quot;8241&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8244&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8234&quot; name=&quot;8245&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8246&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8247&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8252&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8253&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8254&quot; name=&quot;8254&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8255&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6916&quot; name=&quot;8256&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8257&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8258&quot; name=&quot;8258&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8259&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8260&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8263&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8264&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8265&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8270&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8254&quot; name=&quot;8271&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8272&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4544&quot; name=&quot;8273&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8274&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8275&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8280&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8258&quot; name=&quot;8281&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8282&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8283&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8288&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8289&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8290&quot; name=&quot;8290&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8291&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6961&quot; name=&quot;8292&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8293&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8294&quot; name=&quot;8294&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8295&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8296&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8299&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8300&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8301&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8306&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8290&quot; name=&quot;8307&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8308&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4604&quot; name=&quot;8309&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8310&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8311&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8316&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8294&quot; name=&quot;8317&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8318&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8319&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8324&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8325&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7016&quot; name=&quot;8326&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8329&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8330&quot; name=&quot;8330&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8331&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8332&quot; name=&quot;8332&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8333&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8334&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8335&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8336&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4736&quot; name=&quot;8337&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8340&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8330&quot; name=&quot;8341&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8342&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8343&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;8344&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8349&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8332&quot; name=&quot;8350&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8351&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;type-equality&quot;&gt;
&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#type-equality&quot;&gt;Type equality&lt;/a&gt;&lt;/h3&gt;
Before writing our type checking function, we need some additional 
tools. We will begin by defining a decision procedure for equality 
between types. First two lemmas telling us that if two arrow types are 
equal, both sides of the arrows are equal too:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8637&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8652&quot; name=&quot;8652&quot;&gt;≡⇒₁&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8655&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8656&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8657&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8658&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8659&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8660&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8661&quot; name=&quot;8661&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8662&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8663&quot; name=&quot;8663&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8665&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8666&quot; name=&quot;8666&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8667&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8668&quot; name=&quot;8668&quot;&gt;τ′&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8670&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8671&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8672&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8673&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8661&quot; name=&quot;8674&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8675&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;8676&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8677&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8666&quot; name=&quot;8678&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8679&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8680&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8681&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8663&quot; name=&quot;8682&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8684&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;8685&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8686&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8668&quot; name=&quot;8687&quot;&gt;τ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8689&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8690&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8691&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8661&quot; name=&quot;8692&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8693&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8694&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8695&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8663&quot; name=&quot;8696&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8698&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8652&quot; name=&quot;8699&quot;&gt;≡⇒₁&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8702&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8703&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8707&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8708&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8709&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8710&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8714&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8715&quot; name=&quot;8715&quot;&gt;≡⇒₂&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8718&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8719&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8720&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8721&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8722&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8723&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8724&quot; name=&quot;8724&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8725&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8726&quot; name=&quot;8726&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8728&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8729&quot; name=&quot;8729&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8730&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8731&quot; name=&quot;8731&quot;&gt;τ′&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8733&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8734&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8735&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8736&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8724&quot; name=&quot;8737&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8738&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;8739&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8740&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8729&quot; name=&quot;8741&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8742&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8743&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8744&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8726&quot; name=&quot;8745&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8747&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;8748&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8749&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8731&quot; name=&quot;8750&quot;&gt;τ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8752&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8753&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8754&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8729&quot; name=&quot;8755&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8756&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8757&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8758&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8731&quot; name=&quot;8759&quot;&gt;τ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8761&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8715&quot; name=&quot;8762&quot;&gt;≡⇒₂&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8765&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8766&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8770&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8771&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8772&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8773&quot;&gt;refl&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Then the actual function. &lt;code&gt;Dec&lt;/code&gt; is inhabited by either evidence that the relation holds, using the constructor &lt;code&gt;yes&lt;/code&gt;; or that it doesn’t, using &lt;code&gt;no&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8940&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;8955&quot;&gt;_≟_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8958&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8959&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8960&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8961&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8962&quot; name=&quot;8962&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8963&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8964&quot; name=&quot;8964&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8965&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8966&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8967&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;8968&quot;&gt;Type&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8972&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8973&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8974&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8975&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8976&quot;&gt;Dec&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8979&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8980&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8962&quot; name=&quot;8981&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8982&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8983&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8984&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8964&quot; name=&quot;8985&quot;&gt;σ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;8986&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8987&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;8988&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8991&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;8994&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8995&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;8996&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;8999&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9002&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9003&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9004&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9007&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9008&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9012&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;9013&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9016&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;9019&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9020&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9021&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9022&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9023&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9024&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9025&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9026&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9027&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9028&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9029&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9031&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9032&quot;&gt;λ()&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9035&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9036&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9037&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9038&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9039&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9040&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9041&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;9042&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9043&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;9044&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9047&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9050&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9051&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9052&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9054&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9055&quot;&gt;λ()&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9058&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9059&quot; name=&quot;9059&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9060&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9061&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9062&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9063&quot; name=&quot;9063&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9064&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;9065&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9066&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9067&quot; name=&quot;9067&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9069&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9070&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9071&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9072&quot; name=&quot;9072&quot;&gt;τ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9074&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9075&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9079&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9059&quot; name=&quot;9080&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9081&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;9082&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9083&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9067&quot; name=&quot;9084&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9086&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9087&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9088&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9063&quot; name=&quot;9089&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9090&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;9091&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9092&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9072&quot; name=&quot;9093&quot;&gt;τ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9095&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9096&quot; name=&quot;9096&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9097&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9098&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9099&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9100&quot; name=&quot;9100&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9101&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;9102&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9103&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9104&quot;&gt;.&lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9096&quot; name=&quot;9105&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9106&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9107&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9108&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9109&quot;&gt;.&lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9100&quot; name=&quot;9110&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9111&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9112&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9113&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9114&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9117&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9118&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9122&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9123&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9124&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9125&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9128&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9129&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9133&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9134&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9135&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9136&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9139&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9140&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9144&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9145&quot; name=&quot;9145&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9146&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9147&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9148&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9149&quot; name=&quot;9149&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9150&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;9151&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9152&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9153&quot; name=&quot;9153&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9155&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9156&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9157&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9158&quot; name=&quot;9158&quot;&gt;τ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9160&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9161&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9162&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9163&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9165&quot;&gt;  &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9167&quot; name=&quot;9167&quot;&gt;σ≢σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9171&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9172&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9173&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9174&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9175&quot;&gt;        &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9183&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9184&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9185&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9187&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9188&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9167&quot; name=&quot;9189&quot;&gt;σ≢σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9193&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9194&quot;&gt;∘&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9195&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8652&quot; name=&quot;9196&quot;&gt;≡⇒₁&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9199&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9200&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9201&quot; name=&quot;9201&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9202&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9203&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9204&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9205&quot; name=&quot;9205&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9206&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;9207&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9208&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9209&quot; name=&quot;9209&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9211&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;9212&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9213&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9214&quot; name=&quot;9214&quot;&gt;τ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9216&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9217&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9218&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9219&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9220&quot;&gt;        &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9228&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9229&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9230&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9232&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9233&quot; name=&quot;9233&quot;&gt;τ≢τ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9237&quot;&gt;  &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9239&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9240&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9241&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9243&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9244&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#9233&quot; name=&quot;9245&quot;&gt;τ≢τ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9249&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9250&quot;&gt;∘&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;9251&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8715&quot; name=&quot;9252&quot;&gt;≡⇒₂&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;9255&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Note that in the cases where different constructors are present we use &lt;code&gt;λ()&lt;/code&gt;,
 which is a shorthand for a function with an empty pattern—meaning that 
its input cannot be inhabited. For example when faced with &lt;code&gt;nat ≟ σ ⇒ τ&lt;/code&gt; to prove the inequality we need to show that &lt;code&gt;¬ (nat ≡ σ ⇒ τ)&lt;/code&gt;, which is a shorthand for &lt;code&gt;(nat ≡ σ ⇒ τ) → ⊥&lt;/code&gt;—“We can derive falsity given that &lt;code&gt;nat&lt;/code&gt; is equal to an arrow type.” But given how &lt;code&gt;≡&lt;/code&gt; is defined Agda knows that its indices must be the same, and thus that &lt;code&gt;nat ≡ σ ⇒ τ&lt;/code&gt; cannot be inhabited, allowing us to use an empty pattern.&lt;br /&gt;

Moreover, note how we use dependent pattern matching when recursing 
down the structure of the types: when pattern matching on an equality 
proof in a &lt;code&gt;yes&lt;/code&gt; using &lt;code&gt;refl&lt;/code&gt; the two relevant types are constrained to be the same using dotted patterns, which allows us to use &lt;code&gt;refl&lt;/code&gt; again to prove equality of the type as a whole.&lt;br /&gt;

&lt;h3 id=&quot;from-fin-to-ℕ&quot;&gt;
&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#from-fin-to-%E2%84%95&quot;&gt;From &lt;code&gt;Fin&lt;/code&gt; to &lt;code&gt;ℕ&lt;/code&gt;&lt;/a&gt;&lt;/h3&gt;
The second tool that we will use is a “view” to tell us whether a given &lt;code&gt;ℕ&lt;/code&gt; “fits” in a &lt;code&gt;Fin n&lt;/code&gt;.&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10279&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10294&quot;&gt;data&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10298&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10299&quot; name=&quot;10299&quot;&gt;Fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10304&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10305&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10306&quot; name=&quot;10306&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10307&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10308&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10309&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10310&quot;&gt;ℕ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10311&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10312&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10313&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10314&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10315&quot;&gt;ℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10316&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10317&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10318&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10319&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10322&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10323&quot;&gt;where&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10328&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10331&quot; name=&quot;10331&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10334&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10335&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10336&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10337&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10338&quot; name=&quot;10338&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10339&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10340&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10341&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10342&quot;&gt;Fin&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10345&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10306&quot; name=&quot;10346&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10347&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10348&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10349&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10350&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10299&quot; name=&quot;10351&quot;&gt;Fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10356&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10306&quot; name=&quot;10357&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10358&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10359&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10360&quot;&gt;toℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10363&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10338&quot; name=&quot;10364&quot;&gt;m&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10365&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10366&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10369&quot; name=&quot;10369&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10371&quot;&gt;  &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10373&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10374&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10375&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10376&quot; name=&quot;10376&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10377&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10378&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10379&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10380&quot;&gt;ℕ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10381&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10382&quot;&gt;     &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10387&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10388&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10299&quot; name=&quot;10389&quot;&gt;Fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10394&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10306&quot; name=&quot;10395&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10396&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10397&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10306&quot; name=&quot;10398&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10399&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Primitive Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10400&quot;&gt;+&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10401&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10376&quot; name=&quot;10402&quot;&gt;m&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10403&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;code&gt;Fromℕ&lt;/code&gt; is parametrised over the “upper bound” &lt;code&gt;n&lt;/code&gt;, and indexed over the &lt;code&gt;ℕ&lt;/code&gt; that we are bringing into &lt;code&gt;Fin n&lt;/code&gt;. We can then write a function that tries to convert a number &lt;code&gt;m&lt;/code&gt; to a &lt;code&gt;Fin n&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10607&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10622&quot; name=&quot;10622&quot;&gt;fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10627&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10628&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10629&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10630&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10631&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10632&quot; name=&quot;10632&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10633&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10634&quot; name=&quot;10634&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10635&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10636&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10637&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10299&quot; name=&quot;10638&quot;&gt;Fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10643&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10632&quot; name=&quot;10644&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10645&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10634&quot; name=&quot;10646&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10647&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10622&quot; name=&quot;10648&quot;&gt;fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10653&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10654&quot;&gt;zero&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10658&quot;&gt;    &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10662&quot; name=&quot;10662&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10663&quot;&gt;    &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10667&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10668&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10369&quot; name=&quot;10669&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10671&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10662&quot; name=&quot;10672&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10673&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10622&quot; name=&quot;10674&quot;&gt;fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10679&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10680&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10681&quot;&gt;suc&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10684&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10685&quot; name=&quot;10685&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10686&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10687&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10688&quot;&gt;zero&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10692&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10693&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10694&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10331&quot; name=&quot;10695&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10698&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10699&quot;&gt;zero&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10703&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10622&quot; name=&quot;10704&quot;&gt;fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10709&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10710&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10711&quot;&gt;suc&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10714&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10715&quot; name=&quot;10715&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10716&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10717&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10718&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10719&quot;&gt;suc&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10722&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10723&quot; name=&quot;10723&quot;&gt;m&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10724&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10725&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10726&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10730&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10622&quot; name=&quot;10731&quot;&gt;fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10736&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10715&quot; name=&quot;10737&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10738&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10723&quot; name=&quot;10739&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10740&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10622&quot; name=&quot;10741&quot;&gt;fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10746&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10747&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10748&quot;&gt;suc&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10751&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10752&quot; name=&quot;10752&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10753&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10754&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10755&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10756&quot;&gt;suc&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10759&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10760&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10762&quot;&gt;toℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10765&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10776&quot; name=&quot;10766&quot;&gt;m&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10767&quot;&gt;)&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10768&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10769&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10770&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10771&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10331&quot; name=&quot;10772&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10775&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10776&quot; name=&quot;10776&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10777&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10778&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10779&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10331&quot; name=&quot;10780&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10783&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10784&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10785&quot;&gt;suc&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10788&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10776&quot; name=&quot;10789&quot;&gt;m&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10790&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10791&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10622&quot; name=&quot;10792&quot;&gt;fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10797&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10798&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10799&quot;&gt;suc&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10802&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10803&quot; name=&quot;10803&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10804&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10805&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10806&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10807&quot;&gt;suc&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10810&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10811&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10803&quot; name=&quot;10813&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10814&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Primitive Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10815&quot;&gt;+&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10816&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10827&quot; name=&quot;10817&quot;&gt;m&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10818&quot;&gt;)&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10819&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10820&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10821&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10822&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10369&quot; name=&quot;10823&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10825&quot;&gt;  &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10827&quot; name=&quot;10827&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10828&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;10829&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10830&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10369&quot; name=&quot;10831&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;10833&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10827&quot; name=&quot;10834&quot;&gt;m&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;type-checking&quot;&gt;
&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#type-checking&quot;&gt;Type checking&lt;/a&gt;&lt;/h3&gt;
Finally we can proceed to the actual type checking procedure. As with &lt;code&gt;Fromℕ&lt;/code&gt;, we define a data type indexed over what will be the input of our function—some piece of untyped &lt;code&gt;Syntax&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11054&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11069&quot;&gt;data&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11073&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11074&quot; name=&quot;11074&quot;&gt;Check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11079&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11080&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11081&quot; name=&quot;11081&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11082&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11083&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11084&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11085&quot; name=&quot;11085&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11086&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11087&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11088&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;11089&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11092&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11081&quot; name=&quot;11093&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11094&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11095&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11096&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11097&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;11098&quot;&gt;Syntax&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11104&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11105&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11106&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11107&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11110&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11111&quot;&gt;where&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11116&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;11119&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11122&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11123&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11124&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11125&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11126&quot; name=&quot;11126&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11127&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11128&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11129&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;11130&quot;&gt;Type&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11134&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11135&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11136&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11137&quot; name=&quot;11137&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11138&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11139&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11140&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;11141&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11145&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11085&quot; name=&quot;11146&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11147&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11126&quot; name=&quot;11148&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11149&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11150&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11151&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11152&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11074&quot; name=&quot;11153&quot;&gt;Check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11158&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11085&quot; name=&quot;11159&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11160&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11161&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;11162&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11167&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11137&quot; name=&quot;11168&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11169&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11170&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11173&quot; name=&quot;11173&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11175&quot;&gt;  &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11177&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11178&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11179&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11180&quot; name=&quot;11180&quot;&gt;e&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11181&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11182&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11183&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;11184&quot;&gt;Syntax&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11190&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11191&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;11192&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11193&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11074&quot; name=&quot;11194&quot;&gt;Check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11199&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11085&quot; name=&quot;11200&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;11201&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11180&quot; name=&quot;11202&quot;&gt;e&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;code&gt;Check&lt;/code&gt; is parametrised over contexts. If type checking succeeds, we return a type &lt;code&gt;τ&lt;/code&gt; and a term &lt;code&gt;t : τ&lt;/code&gt;, the erasure of &lt;code&gt;t&lt;/code&gt; being the &lt;code&gt;Syntax&lt;/code&gt; we were type checking—the &lt;code&gt;yes&lt;/code&gt; constructor. We can fail at any time using the constructor &lt;code&gt;no&lt;/code&gt;.&lt;sup&gt;&lt;a class=&quot;footnoteRef&quot; href=&quot;http://mazzo.li/posts/Lambda.html#fn3&quot; id=&quot;fnref3&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;br /&gt;

Our type checking procedure will work with a context and some &lt;code&gt;Syntax&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12213&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12228&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12233&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12234&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12235&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12236&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12237&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12238&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12239&quot; name=&quot;12239&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12240&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12241&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12242&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12243&quot; name=&quot;12243&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12244&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12245&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12246&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;12247&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12250&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12239&quot; name=&quot;12251&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12252&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12253&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12254&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12255&quot; name=&quot;12255&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12256&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12257&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12258&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4399&quot; name=&quot;12259&quot;&gt;Syntax&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12265&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12266&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12267&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12268&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11074&quot; name=&quot;12269&quot;&gt;Check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12274&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12243&quot; name=&quot;12275&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12276&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12255&quot; name=&quot;12277&quot;&gt;t&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
With &lt;code&gt;var&lt;/code&gt;, we make sure that the index is in scope using &lt;code&gt;fromℕ&lt;/code&gt;. If it is, the type is determined by what’s in the at the right index:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12428&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12443&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12448&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12449&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12450&quot; name=&quot;12450&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12451&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12452&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12453&quot; name=&quot;12453&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12454&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12455&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4468&quot; name=&quot;12456&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12459&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12460&quot; name=&quot;12460&quot;&gt;v&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12461&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12462&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12463&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12467&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10622&quot; name=&quot;12468&quot;&gt;fromℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12473&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12450&quot; name=&quot;12474&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12475&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12460&quot; name=&quot;12476&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12477&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12478&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12483&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12484&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12485&quot; name=&quot;12485&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12486&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12487&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12488&quot; name=&quot;12488&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12489&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12490&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12491&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12494&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12495&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12497&quot;&gt;toℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12500&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12511&quot; name=&quot;12501&quot;&gt;v&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12502&quot;&gt;)&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12503&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12504&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12505&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12506&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10331&quot; name=&quot;12507&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12510&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12511&quot; name=&quot;12511&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12512&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12513&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12514&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;12515&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12518&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12519&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12520&quot;&gt;lookup&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12526&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12511&quot; name=&quot;12527&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12528&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12488&quot; name=&quot;12529&quot;&gt;Γ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12530&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12531&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12532&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6839&quot; name=&quot;12533&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12536&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12511&quot; name=&quot;12537&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12538&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12539&quot;&gt;refl&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12543&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12544&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12545&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12550&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12551&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12552&quot; name=&quot;12552&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12553&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12554&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12555&quot; name=&quot;12555&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12556&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12557&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12558&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12561&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12562&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12552&quot; name=&quot;12564&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12565&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Primitive Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12566&quot;&gt;+&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12567&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12578&quot; name=&quot;12568&quot;&gt;m&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12569&quot;&gt;)&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12570&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12571&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12572&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12573&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#10369&quot; name=&quot;12574&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12576&quot;&gt;  &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12578&quot; name=&quot;12578&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12579&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12580&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12581&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11173&quot; name=&quot;12582&quot;&gt;no&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Literals are of type &lt;code&gt;nat&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12624&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12639&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12644&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12645&quot; name=&quot;12645&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12646&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12647&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4510&quot; name=&quot;12648&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12651&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12652&quot; name=&quot;12652&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12653&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12654&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12655&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12656&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;12657&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12660&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;12661&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12664&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12665&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6893&quot; name=&quot;12666&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12669&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12652&quot; name=&quot;12670&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12671&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
For additions, we recursively type check the two sides. If they are both &lt;code&gt;nat&lt;/code&gt;, the resulting term is &lt;code&gt;nat&lt;/code&gt; too. Otherwise, type checking fails:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12831&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12846&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12851&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12852&quot; name=&quot;12852&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12853&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12854&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12855&quot; name=&quot;12855&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12856&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4544&quot; name=&quot;12857&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12858&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12859&quot; name=&quot;12859&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12860&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12861&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12862&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12866&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12867&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12872&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12852&quot; name=&quot;12873&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12874&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12855&quot; name=&quot;12875&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12876&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12877&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12878&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12879&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12884&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12852&quot; name=&quot;12885&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12886&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12859&quot; name=&quot;12887&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12888&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12889&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12894&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12895&quot; name=&quot;12895&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12896&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12897&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12898&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;12900&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12905&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12933&quot; name=&quot;12906&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12907&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12908&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12909&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12910&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12911&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;12913&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12918&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12945&quot; name=&quot;12919&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12920&quot;&gt;)&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12921&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12922&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12923&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12924&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;12925&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12928&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;12929&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12932&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12933&quot; name=&quot;12933&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12934&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12935&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12936&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;12937&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12940&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;12941&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12944&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12945&quot; name=&quot;12945&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12946&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12947&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12948&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;12949&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12952&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;12953&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12956&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12957&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12933&quot; name=&quot;12958&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12959&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6916&quot; name=&quot;12960&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12961&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12945&quot; name=&quot;12962&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12963&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12964&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;12965&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12970&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12971&quot; name=&quot;12971&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12972&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12973&quot;&gt;(_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12975&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12976&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12977&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12978&quot;&gt;_)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;12980&quot;&gt;                   &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;12999&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;13000&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;13001&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;13002&quot;&gt;         &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;13011&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;13012&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;13013&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;13014&quot;&gt;         &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;13023&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;13024&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11173&quot; name=&quot;13025&quot;&gt;no&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Note that when checking against the results of the recursive calls, 
we use dotted matches to show the relationship between the input &lt;code&gt;Syntax&lt;/code&gt; terms and the type checked terms: the former is the erasure of the latter. This way we can invoke &lt;code&gt;yes&lt;/code&gt; so that the result will be well typed.&lt;br /&gt;

The interactive Agda mode is tremendously useful in these situations. If we are in the situation&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;check Γ (t ⊕ u) with check Γ t | check Γ u
check Γ (t ⊕ u) | p1 | p2 = {!!}&lt;/code&gt;&lt;/pre&gt;
We can pattern match by placing &lt;code&gt;p1&lt;/code&gt; in the hole and then invoking &lt;code&gt;C-c C-c&lt;/code&gt;, which will result in&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;check Γ (.(erase t) ⊕ u) | yes τ t | p2 = {!!}&lt;/code&gt;&lt;/pre&gt;
Agda automatically places the dotted patterns. Then after doing the same for &lt;code&gt;p2&lt;/code&gt; and matching &lt;code&gt;nat&lt;/code&gt;, we are left with&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;check Γ (.(erase t) ⊕ .(erase u)) | yes nat t | yes nat u = {!!}&lt;/code&gt;&lt;/pre&gt;
The goal for that hole, as Agda reminds us, is&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;Check Γ (erase t ⊕ erase u)&lt;/code&gt;&lt;/pre&gt;
We can type &lt;code&gt;yes&lt;/code&gt; and then &lt;code&gt;C-r&lt;/code&gt; to refine the hole, and then &lt;code&gt;C-a&lt;/code&gt;
 in each hole to tell Agda to try to search for an appropriate term, 
which in this case succeeds. In general with strong enough types we only
 write an outline of the function and then a lot of details can be 
filled in automatically.&lt;br /&gt;

For what concerns application, we check that the term we are applying
 something to has a function type, and that the argument’s type is equal
 to the domain of said function:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14409&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;14424&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14429&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14430&quot; name=&quot;14430&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14431&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14432&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14433&quot; name=&quot;14433&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14434&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4604&quot; name=&quot;14435&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14436&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14437&quot; name=&quot;14437&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14438&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14439&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14440&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14444&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;14445&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14450&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14430&quot; name=&quot;14451&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14452&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14433&quot; name=&quot;14453&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14454&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14455&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14456&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;14457&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14462&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14430&quot; name=&quot;14463&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14464&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14437&quot; name=&quot;14465&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14466&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;14467&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14472&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14473&quot; name=&quot;14473&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14474&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14475&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14476&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;14478&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14483&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14515&quot; name=&quot;14484&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14485&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14486&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14487&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14488&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14489&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;14491&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14496&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14526&quot; name=&quot;14497&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14498&quot;&gt;)&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14499&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14500&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14501&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14502&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;14503&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14506&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14507&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14508&quot; name=&quot;14508&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14509&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;14510&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14511&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14512&quot; name=&quot;14512&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14513&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14514&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14515&quot; name=&quot;14515&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14516&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14517&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14518&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;14519&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14522&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14523&quot; name=&quot;14523&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14525&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14526&quot; name=&quot;14526&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14527&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14528&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14532&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14508&quot; name=&quot;14533&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14534&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8955&quot; name=&quot;14535&quot;&gt;≟&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14536&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14523&quot; name=&quot;14537&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14539&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;14540&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14545&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14546&quot; name=&quot;14546&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14547&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14548&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14549&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;14551&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14556&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14588&quot; name=&quot;14557&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14558&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14559&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14560&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14561&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14562&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;14564&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14569&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14599&quot; name=&quot;14570&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14571&quot;&gt;)&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14572&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14573&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14574&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14575&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14576&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14579&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14580&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14581&quot; name=&quot;14581&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14582&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;14583&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14584&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14585&quot; name=&quot;14585&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14586&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14587&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14588&quot; name=&quot;14588&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14589&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14590&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14591&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14592&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14595&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14596&quot;&gt;.&lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14581&quot; name=&quot;14597&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14598&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14599&quot; name=&quot;14599&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14600&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14601&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14602&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14603&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14606&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14607&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14611&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14612&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14613&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;14614&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14617&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14585&quot; name=&quot;14618&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14619&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14620&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14588&quot; name=&quot;14621&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14622&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6961&quot; name=&quot;14623&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14624&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14599&quot; name=&quot;14625&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14626&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14627&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;14628&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14633&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14634&quot; name=&quot;14634&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14635&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14636&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14637&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;14639&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14644&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14676&quot; name=&quot;14645&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14646&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14647&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14648&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14649&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14650&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;14652&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14657&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14687&quot; name=&quot;14658&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14659&quot;&gt;)&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14660&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14661&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14662&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14663&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14664&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14667&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14668&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14669&quot; name=&quot;14669&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14670&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;14671&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14672&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14673&quot; name=&quot;14673&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14674&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14675&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14676&quot; name=&quot;14676&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14677&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14678&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14679&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14680&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14683&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14684&quot; name=&quot;14684&quot;&gt;σ′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14686&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14687&quot; name=&quot;14687&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14688&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14689&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14690&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14691&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14693&quot;&gt;  &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14695&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14696&quot;&gt;    &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14700&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14701&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11173&quot; name=&quot;14702&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14704&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;14705&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14710&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14711&quot; name=&quot;14711&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14712&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14713&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14714&quot; name=&quot;14714&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14715&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14716&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14717&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14718&quot; name=&quot;14718&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14719&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14720&quot;&gt;                   &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14739&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14740&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14741&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14742&quot;&gt;             &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14755&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14756&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14757&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14758&quot;&gt;       &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14765&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14766&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11173&quot; name=&quot;14767&quot;&gt;no&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Finally, with λs, we check that the body of the function is well 
typed in the context plus the type of the argument. If that’s the case, 
the resulting type is an arrow type:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14956&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;14971&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14976&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14977&quot; name=&quot;14977&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14978&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14979&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#4736&quot; name=&quot;14980&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14983&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14984&quot; name=&quot;14984&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14985&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14986&quot; name=&quot;14986&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14987&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14988&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;14989&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14993&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;14994&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;14999&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15000&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14984&quot; name=&quot;15001&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15002&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15003&quot;&gt;∷&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15004&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14977&quot; name=&quot;15005&quot;&gt;Γ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15006&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15007&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#14986&quot; name=&quot;15008&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15009&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;15010&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15015&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15016&quot; name=&quot;15016&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15017&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15018&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15019&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15022&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15023&quot; name=&quot;15023&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15024&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15025&quot;&gt;.(&lt;/a&gt;&lt;a class=&quot;DottedPattern Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#8143&quot; name=&quot;15027&quot;&gt;erase&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15032&quot;&gt; &lt;/a&gt;&lt;a class=&quot;DottedPattern Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15045&quot; name=&quot;15033&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;DottedPattern Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15034&quot;&gt;)&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15035&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15036&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15037&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15038&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;15039&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15042&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15043&quot; name=&quot;15043&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15044&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15045&quot; name=&quot;15045&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15046&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15047&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15048&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11119&quot; name=&quot;15049&quot;&gt;yes&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15052&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15053&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15023&quot; name=&quot;15054&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15055&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;15056&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15057&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15043&quot; name=&quot;15058&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15059&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15060&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15061&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7016&quot; name=&quot;15062&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15065&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15023&quot; name=&quot;15066&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15067&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15045&quot; name=&quot;15068&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15069&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15070&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#12228&quot; name=&quot;15071&quot;&gt;check&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15076&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15077&quot; name=&quot;15077&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15078&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15079&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15080&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15083&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15084&quot; name=&quot;15084&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15085&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15086&quot; name=&quot;15086&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15087&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15088&quot;&gt;          &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15098&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15099&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11173&quot; name=&quot;15100&quot;&gt;no&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15102&quot;&gt;      &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15108&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15109&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#11173&quot; name=&quot;15110&quot;&gt;no&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Type checking the syntax for &lt;code&gt;double&lt;/code&gt; will give good results:&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; C-c C-n check [] (lam nat (var 0 ⊕ var 0))
yes (nat ⇒ nat) (lam nat (var zero refl ⊕ var zero refl))&lt;/code&gt;&lt;/pre&gt;
While ill-typed examples will fail:&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; C-c C-n check [] (lam nat (var 0 · var 0))
no

&amp;gt; C-c C-n check [] (lam (nat ⇒ nat) (var 0 ⊕ var 0))
no&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;embedding-terms&quot;&gt;
&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#embedding-terms&quot;&gt;Embedding terms&lt;/a&gt;&lt;/h2&gt;
Now that we have a type checker, we can embed typed terms into Agda. 
This technique is a common and cheap way to give semantics to 
programming languages that we are modelling inside a theorem prover—we 
borrow the host language semantics.&lt;br /&gt;

In our case, we can easily define a function taking &lt;code&gt;Type&lt;/code&gt; into Agda’s &lt;code&gt;Set&lt;/code&gt;:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15797&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;15812&quot;&gt;⟦_⟧&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15815&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15816&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15817&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3496&quot; name=&quot;15818&quot;&gt;Type&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15822&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15823&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15824&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15825&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15828&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;15829&quot;&gt;⟦&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15830&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;15831&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15834&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;15837&quot;&gt;⟧&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15838&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15839&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15840&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15841&quot;&gt;ℕ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15842&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;15843&quot;&gt;⟦&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15844&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15845&quot; name=&quot;15845&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15846&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;15847&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15848&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15849&quot; name=&quot;15849&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15850&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;15851&quot;&gt;⟧&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15852&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15853&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15854&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;15855&quot;&gt;⟦&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15856&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15845&quot; name=&quot;15857&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15858&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;15859&quot;&gt;⟧&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15860&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;15861&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15862&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;15863&quot;&gt;⟦&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15864&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15849&quot; name=&quot;15865&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15866&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;15867&quot;&gt;⟧&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Then, to transport an arbitrary &lt;code&gt;Term Γ τ&lt;/code&gt; to &lt;code&gt;⟦ τ ⟧&lt;/code&gt;, we need an environment storing values for the bound variables:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;15998&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16013&quot;&gt;infixr&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16019&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Number&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16020&quot;&gt;5&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16021&quot;&gt; _∷_
&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16026&quot;&gt;data&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16030&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16031&quot; name=&quot;16031&quot;&gt;Env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16034&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16035&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16036&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16037&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16038&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16039&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16040&quot; name=&quot;16040&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16041&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16042&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16043&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16044&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;16045&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16048&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16040&quot; name=&quot;16049&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16050&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16051&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16052&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16053&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16056&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16057&quot;&gt;where&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16062&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16065&quot; name=&quot;16065&quot;&gt;[]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16067&quot;&gt;  &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16069&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16070&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16031&quot; name=&quot;16071&quot;&gt;Env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16074&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16075&quot;&gt;[]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16077&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16080&quot; name=&quot;16080&quot;&gt;_∷_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16083&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16084&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16085&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16086&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16087&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16088&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16089&quot; name=&quot;16089&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16090&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16091&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16092&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16093&quot; name=&quot;16093&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16094&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16095&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16096&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;16097&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16100&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16089&quot; name=&quot;16101&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16102&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16103&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16104&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16105&quot; name=&quot;16105&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16106&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16107&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16108&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16109&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;16110&quot;&gt;⟦&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16111&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16105&quot; name=&quot;16112&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16113&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;16114&quot;&gt;⟧&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16115&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16116&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16117&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16031&quot; name=&quot;16118&quot;&gt;Env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16121&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16093&quot; name=&quot;16122&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16123&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16124&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16125&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16031&quot; name=&quot;16126&quot;&gt;Env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16129&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16130&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16105&quot; name=&quot;16131&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16132&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16133&quot;&gt;∷&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16134&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16093&quot; name=&quot;16135&quot;&gt;Γ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16136&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;code&gt;Env Γ&lt;/code&gt; stores values corresponding to the types stored in &lt;code&gt;Γ&lt;/code&gt;. We can extend an existing &lt;code&gt;Env&lt;/code&gt; by consing a value of the right type to it, and extending the context.&lt;br /&gt;

We can also lookup values into the &lt;code&gt;Env&lt;/code&gt; just like we can index into &lt;code&gt;Vec&lt;/code&gt;s:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16395&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16410&quot; name=&quot;16410&quot;&gt;lookupEnv&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16419&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16420&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16421&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16422&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16423&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16424&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16425&quot; name=&quot;16425&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16426&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16427&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16428&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16429&quot; name=&quot;16429&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16430&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16431&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16432&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;16433&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16436&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16425&quot; name=&quot;16437&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16438&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16439&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16440&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16441&quot; name=&quot;16441&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16442&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16443&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16444&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16445&quot;&gt;Fin&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16448&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16425&quot; name=&quot;16449&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16450&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16451&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16452&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16453&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16031&quot; name=&quot;16454&quot;&gt;Env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16457&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16429&quot; name=&quot;16458&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16459&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16460&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16461&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;16462&quot;&gt;⟦&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16463&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16464&quot;&gt;lookup&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16470&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16441&quot; name=&quot;16471&quot;&gt;m&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16472&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16429&quot; name=&quot;16473&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16474&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;16475&quot;&gt;⟧&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16476&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16410&quot; name=&quot;16477&quot;&gt;lookupEnv&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16486&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16487&quot;&gt;zero&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16491&quot;&gt;    &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16495&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16496&quot; name=&quot;16496&quot;&gt;x&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16497&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16080&quot; name=&quot;16498&quot;&gt;∷&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16499&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16500&quot;&gt;_)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16502&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16505&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16506&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16496&quot; name=&quot;16507&quot;&gt;x&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16508&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16410&quot; name=&quot;16509&quot;&gt;lookupEnv&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16518&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16519&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16520&quot;&gt;suc&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16523&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16524&quot; name=&quot;16524&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16525&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16526&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16527&quot;&gt;(_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16529&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16080&quot; name=&quot;16530&quot;&gt;∷&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16531&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16532&quot; name=&quot;16532&quot;&gt;env&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16535&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16536&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16537&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16538&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16410&quot; name=&quot;16539&quot;&gt;lookupEnv&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16548&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16524&quot; name=&quot;16549&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16550&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16532&quot; name=&quot;16551&quot;&gt;env&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
With these tools, we can define a function evaluating a &lt;code&gt;Term&lt;/code&gt; into an Agda value of the right type:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16667&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16682&quot;&gt;_[_]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16686&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16687&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16688&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16689&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16690&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16691&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16692&quot; name=&quot;16692&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16693&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16694&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16695&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16696&quot; name=&quot;16696&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16697&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16698&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16699&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;16700&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16703&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16692&quot; name=&quot;16704&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16705&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16706&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16707&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16708&quot; name=&quot;16708&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16709&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16710&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16711&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16712&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16031&quot; name=&quot;16713&quot;&gt;Env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16716&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16696&quot; name=&quot;16717&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16718&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16719&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16720&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;16721&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16725&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16696&quot; name=&quot;16726&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16727&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16708&quot; name=&quot;16728&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16729&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16730&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16731&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;16732&quot;&gt;⟦&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16733&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16708&quot; name=&quot;16734&quot;&gt;τ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16735&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;16736&quot;&gt;⟧&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16737&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16738&quot; name=&quot;16738&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16741&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16742&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16743&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6839&quot; name=&quot;16744&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16747&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16748&quot; name=&quot;16748&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16749&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16750&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16754&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16755&quot;&gt;]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16756&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16757&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16758&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16410&quot; name=&quot;16759&quot;&gt;lookupEnv&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16768&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16748&quot; name=&quot;16769&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16770&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16738&quot; name=&quot;16771&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16774&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16775&quot; name=&quot;16775&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16778&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16779&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16780&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6893&quot; name=&quot;16781&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16784&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16785&quot; name=&quot;16785&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16786&quot;&gt;      &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16792&quot;&gt;]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16793&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16794&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16795&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16785&quot; name=&quot;16796&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16797&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16798&quot; name=&quot;16798&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16801&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16802&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16803&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16804&quot; name=&quot;16804&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16805&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6916&quot; name=&quot;16806&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16807&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16808&quot; name=&quot;16808&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16809&quot;&gt;      &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16815&quot;&gt;]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16816&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16817&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16818&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16798&quot; name=&quot;16819&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16822&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16823&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16824&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16804&quot; name=&quot;16825&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16826&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16827&quot;&gt;]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16828&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Primitive Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16829&quot;&gt;+&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16830&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16798&quot; name=&quot;16831&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16834&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16835&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16836&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16808&quot; name=&quot;16837&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16838&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16839&quot;&gt;]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16840&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16841&quot; name=&quot;16841&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16844&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16845&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16846&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16847&quot; name=&quot;16847&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16848&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6961&quot; name=&quot;16849&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16850&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16851&quot; name=&quot;16851&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16852&quot;&gt;      &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16858&quot;&gt;]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16859&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16860&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16861&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16862&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16841&quot; name=&quot;16863&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16866&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16867&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16868&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16847&quot; name=&quot;16869&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16870&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16871&quot;&gt;]&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16872&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16873&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16874&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16841&quot; name=&quot;16875&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16878&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16879&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16880&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16851&quot; name=&quot;16881&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16882&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16883&quot;&gt;]&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16884&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16885&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16886&quot; name=&quot;16886&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16889&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16890&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16891&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7016&quot; name=&quot;16892&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16895&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16896&quot;&gt;_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16897&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16898&quot; name=&quot;16898&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16899&quot;&gt;    &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16903&quot;&gt;]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16904&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16905&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16906&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16907&quot;&gt;λ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16908&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16909&quot; name=&quot;16909&quot;&gt;x&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16910&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16911&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16912&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16913&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16909&quot; name=&quot;16914&quot;&gt;x&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16915&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16080&quot; name=&quot;16916&quot;&gt;∷&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16917&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16886&quot; name=&quot;16918&quot;&gt;env&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;16921&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16922&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16923&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16924&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16898&quot; name=&quot;16925&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;16926&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;16927&quot;&gt;]&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Now we can verify, for example, that &lt;code&gt;double&lt;/code&gt; does the right thing:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17008&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17023&quot; name=&quot;17023&quot;&gt;double′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17030&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17031&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17032&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;17033&quot;&gt;⟦&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17034&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;17035&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17038&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3528&quot; name=&quot;17039&quot;&gt;⇒&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17040&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#3515&quot; name=&quot;17041&quot;&gt;nat&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17044&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#15812&quot; name=&quot;17045&quot;&gt;⟧&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17046&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17023&quot; name=&quot;17047&quot;&gt;double′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17054&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17055&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17056&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16065&quot; name=&quot;17057&quot;&gt;[]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17059&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;17060&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17061&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7943&quot; name=&quot;17062&quot;&gt;double&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17068&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;17069&quot;&gt;]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17070&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Comment&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17071&quot;&gt;-- A closed term, in an empty environment&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17112&quot;&gt;

&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17114&quot; name=&quot;17114&quot;&gt;doubleTest&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17124&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17125&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17126&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17023&quot; name=&quot;17127&quot;&gt;double′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17134&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Number&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17135&quot;&gt;3&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17136&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17137&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17138&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Number&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17139&quot;&gt;6&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17140&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17114&quot; name=&quot;17141&quot;&gt;doubleTest&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17151&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17152&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17153&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17154&quot;&gt;refl&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;constant-folding&quot;&gt;
&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#constant-folding&quot;&gt;Constant folding&lt;/a&gt;&lt;/h2&gt;
To conclude, we will write a simple optimisation our terms, and prove
 that it is sound by showing that it always preserves the semantics of 
the original term, using the embedding above.&lt;br /&gt;

To represent “optimised” terms, we will use a record parametrised 
over the original term and holding the optimised version, plus evidence 
that for all environments evaluating the original and optimised term 
will yield the same Agda value:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17617&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17632&quot;&gt;record&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17638&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Record&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17639&quot; name=&quot;17639&quot;&gt;Optimised&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17648&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17649&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17650&quot; name=&quot;17650&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17651&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17652&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17653&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17654&quot; name=&quot;17654&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17655&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17656&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17657&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;17658&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17661&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17650&quot; name=&quot;17662&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17663&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17664&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17665&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17666&quot; name=&quot;17666&quot;&gt;σ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17667&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17668&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17669&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17670&quot; name=&quot;17670&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17671&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17672&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17673&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;17674&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17678&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17654&quot; name=&quot;17679&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17680&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17666&quot; name=&quot;17681&quot;&gt;σ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17682&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17683&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17684&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17685&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17686&quot;&gt;Set&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17689&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17690&quot;&gt;where&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17695&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17698&quot;&gt;constructor&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17709&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;17710&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17713&quot;&gt;
  &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17716&quot;&gt;field&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17721&quot;&gt;
    &lt;/a&gt;&lt;a class=&quot;Field&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17726&quot; name=&quot;17726&quot;&gt;optimised&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17735&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17736&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17737&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;17738&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17742&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17654&quot; name=&quot;17743&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17744&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17666&quot; name=&quot;17745&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17746&quot;&gt;
    &lt;/a&gt;&lt;a class=&quot;Field&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17751&quot; name=&quot;17751&quot;&gt;sound&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17756&quot;&gt;     &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17761&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17762&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17763&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17764&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17765&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17766&quot; name=&quot;17766&quot;&gt;env&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17769&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17770&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17771&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17772&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17766&quot; name=&quot;17773&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17776&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;17777&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17778&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17670&quot; name=&quot;17779&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17780&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;17781&quot;&gt;]&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17782&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17783&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17784&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17766&quot; name=&quot;17785&quot;&gt;env&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17788&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;17789&quot;&gt;[&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17790&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17726&quot; name=&quot;17791&quot;&gt;optimised&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17800&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#16682&quot; name=&quot;17801&quot;&gt;]&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
However, to succeed, we need to postulate an axiom:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17866&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17881&quot;&gt;postulate&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17890&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Postulate&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17891&quot; name=&quot;17891&quot;&gt;ext&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17894&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17895&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17896&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17897&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17898&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17899&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17900&quot; name=&quot;17900&quot;&gt;A&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17901&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17902&quot; name=&quot;17902&quot;&gt;B&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17903&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17904&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17905&quot;&gt; &lt;/a&gt;&lt;a class=&quot;PrimitiveType&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17906&quot;&gt;Set&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17909&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17910&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17911&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17912&quot; name=&quot;17912&quot;&gt;f&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17913&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17914&quot; name=&quot;17914&quot;&gt;g&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17915&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17916&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17917&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17900&quot; name=&quot;17918&quot;&gt;A&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17919&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17920&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17921&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17902&quot; name=&quot;17922&quot;&gt;B&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17923&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17924&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17925&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17926&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17927&quot;&gt;({&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17929&quot; name=&quot;17929&quot;&gt;x&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17930&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17931&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17932&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17900&quot; name=&quot;17933&quot;&gt;A&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17934&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17935&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17936&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17937&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17912&quot; name=&quot;17938&quot;&gt;f&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17939&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17929&quot; name=&quot;17940&quot;&gt;x&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17941&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17942&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17943&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17914&quot; name=&quot;17944&quot;&gt;g&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17945&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17929&quot; name=&quot;17946&quot;&gt;x&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17947&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17948&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17949&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17950&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17912&quot; name=&quot;17951&quot;&gt;f&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17952&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;17953&quot;&gt;≡&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;17954&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17914&quot; name=&quot;17955&quot;&gt;g&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
This axiom says that if we have two functions &lt;code&gt;f&lt;/code&gt; and &lt;code&gt;g&lt;/code&gt;,
 and we have evidence that for all inputs the functions have equal 
outputs, then the functions themselves can be considered equal. This is 
usually know as &lt;a href=&quot;http://en.wikipedia.org/wiki/Extensionality&quot;&gt;&lt;em&gt;functional extensionality&lt;/em&gt;&lt;/a&gt;, and we cannot prove it in Agda and theorem provers based on similar theories.&lt;sup&gt;&lt;a class=&quot;footnoteRef&quot; href=&quot;http://mazzo.li/posts/Lambda.html#fn4&quot; id=&quot;fnref4&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;
 Postulating extensionality is still (hopefully) consistent with Agda’s 
theory, although obviously we will not be able to compute with 
it—definitions pattern matching on equality proofs will get stuck on 
invocations of &lt;code&gt;ext&lt;/code&gt;.&lt;br /&gt;

With this axiom and our record &lt;code&gt;Optimised&lt;/code&gt;, we will write 
the optimisation and the proof at the same time. The optimisation will 
consist of reducing constant expressions to number literals, so that for
 example&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;lit 3 ⊕ lit 7&lt;/code&gt;&lt;/pre&gt;
will be reduced to&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;lit 10&lt;/code&gt;&lt;/pre&gt;
So, our function will take a term and produce an optimised version of it:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19646&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;19661&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19666&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19667&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19668&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19669&quot;&gt;∀&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19670&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19671&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19672&quot; name=&quot;19672&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19673&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19674&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19675&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19676&quot; name=&quot;19676&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19677&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19678&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19679&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6495&quot; name=&quot;19680&quot;&gt;Ctx&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19683&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19672&quot; name=&quot;19684&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19685&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19686&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19687&quot;&gt;{&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19688&quot; name=&quot;19688&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19689&quot;&gt;}&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19690&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19691&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19692&quot; name=&quot;19692&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19693&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19694&quot;&gt;:&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19695&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Datatype&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6797&quot; name=&quot;19696&quot;&gt;Term&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19700&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19676&quot; name=&quot;19701&quot;&gt;Γ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19702&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19688&quot; name=&quot;19703&quot;&gt;τ&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19704&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19705&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19706&quot;&gt;→&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19707&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Record&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17639&quot; name=&quot;19708&quot;&gt;Optimised&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19717&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19692&quot; name=&quot;19718&quot;&gt;t&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Variables and literals stay untouched, so the proof of equality will be trivial:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19812&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;19827&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19832&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19833&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6839&quot; name=&quot;19834&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19837&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19838&quot; name=&quot;19838&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19839&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19840&quot; name=&quot;19840&quot;&gt;p&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19841&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19842&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19843&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19844&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;19845&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19848&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19849&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6839&quot; name=&quot;19850&quot;&gt;var&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19853&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19838&quot; name=&quot;19854&quot;&gt;v&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19855&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19840&quot; name=&quot;19856&quot;&gt;p&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19857&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19858&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19859&quot;&gt;refl&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19863&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;19864&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19869&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19870&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6893&quot; name=&quot;19871&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19874&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19875&quot; name=&quot;19875&quot;&gt;x&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19876&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19877&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19880&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19881&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;19882&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19885&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19886&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6893&quot; name=&quot;19887&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19890&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19875&quot; name=&quot;19891&quot;&gt;x&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19892&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;19893&quot;&gt;   &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;19896&quot;&gt;refl&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
For applications, we call &lt;code&gt;cfold&lt;/code&gt; recursively, and then we use &lt;code&gt;cong₂&lt;/code&gt; to combine the resulting proofs of soundness—since evaluating functions means applying them, we use &lt;code&gt;_$_&lt;/code&gt;:&lt;br /&gt;

&lt;pre&gt;&lt;code&gt;cong₂ : {A B C : Set} (f : A → B → C) {x y u v} → x ≡ y → u ≡ v → f x u ≡ f y v
_$_   : ∀ {A : Set} {B : A → Set} → ((x : A) → B x) → ((x : A) → B x)
cong₂ _$_ : {A B : Set} {f g : A → B} {x y : A} → f ≡ g → x ≡ y → (f $ x) ≡ (g $ y)&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20339&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;20354&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20359&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20360&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20361&quot; name=&quot;20361&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20362&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6961&quot; name=&quot;20363&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20364&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20365&quot; name=&quot;20365&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20366&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20367&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20368&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20372&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;20373&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20378&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20361&quot; name=&quot;20379&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20380&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20381&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20382&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;20383&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20388&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20365&quot; name=&quot;20389&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20390&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20391&quot;&gt;...&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20394&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20395&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20396&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;20397&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20400&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20401&quot; name=&quot;20401&quot;&gt;t′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20403&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20404&quot; name=&quot;20404&quot;&gt;p&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20405&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20406&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20407&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;20408&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20411&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20412&quot; name=&quot;20412&quot;&gt;u′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20414&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20415&quot; name=&quot;20415&quot;&gt;q&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20416&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20417&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20418&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;20419&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20422&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20423&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20401&quot; name=&quot;20424&quot;&gt;t′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20426&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6961&quot; name=&quot;20427&quot;&gt;·&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20428&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20412&quot; name=&quot;20429&quot;&gt;u′&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20431&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20432&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20433&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20434&quot;&gt;cong₂&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20439&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20440&quot;&gt;_$_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20443&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20404&quot; name=&quot;20444&quot;&gt;p&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20445&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20415&quot; name=&quot;20446&quot;&gt;q&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20447&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
For λs, we need to use &lt;code&gt;ext&lt;/code&gt; to prove that the optimised function is equal to the original one:&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20556&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;20571&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20576&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20577&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7016&quot; name=&quot;20578&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20581&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20582&quot; name=&quot;20582&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20583&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20584&quot; name=&quot;20584&quot;&gt;t&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20585&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20586&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20587&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20591&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;20592&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20597&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20584&quot; name=&quot;20598&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20599&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20600&quot;&gt;...&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20603&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20604&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20605&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;20606&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20609&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20610&quot; name=&quot;20610&quot;&gt;t′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20612&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20613&quot; name=&quot;20613&quot;&gt;p&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20614&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20615&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20616&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;20617&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20620&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20621&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#7016&quot; name=&quot;20622&quot;&gt;lam&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20625&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20582&quot; name=&quot;20626&quot;&gt;σ&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20627&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20610&quot; name=&quot;20628&quot;&gt;t′&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20630&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20631&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20632&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Postulate&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17891&quot; name=&quot;20633&quot;&gt;ext&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;20636&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#20613&quot; name=&quot;20637&quot;&gt;p&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;20638&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
Finally, with additions, we perform the actual optimisation. If both 
sides after optimisation are number literals we can replace them with 
another literal. Otherwise we leave the addition in place. We also 
combine the proofs of equality of the sides with &lt;code&gt;cong₂ _+_&lt;/code&gt;, given that the denotation uses &lt;code&gt;_+_&lt;/code&gt;.&lt;sup&gt;&lt;a class=&quot;footnoteRef&quot; href=&quot;http://mazzo.li/posts/Lambda.html#fn5&quot; id=&quot;fnref5&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;br /&gt;

&lt;pre class=&quot;Agda&quot;&gt;&lt;code&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21196&quot;&gt;&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;21211&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21216&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21217&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21218&quot; name=&quot;21218&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21219&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6916&quot; name=&quot;21220&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21221&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21222&quot; name=&quot;21222&quot;&gt;u&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21223&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21224&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Keyword&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21225&quot;&gt;with&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21229&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;21230&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21235&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21218&quot; name=&quot;21236&quot;&gt;t&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21237&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21238&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21239&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://mazzo.li/posts/Lambda.html#19661&quot; name=&quot;21240&quot;&gt;cfold&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21245&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21222&quot; name=&quot;21246&quot;&gt;u&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21247&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21248&quot;&gt;...&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21251&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21252&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21253&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;21254&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21257&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21258&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6893&quot; name=&quot;21259&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21262&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21263&quot; name=&quot;21263&quot;&gt;n&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21264&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21265&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21266&quot; name=&quot;21266&quot;&gt;p&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21267&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21268&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21269&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;21270&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21273&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21274&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6893&quot; name=&quot;21275&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21278&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21279&quot; name=&quot;21279&quot;&gt;m&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21280&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21281&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21282&quot; name=&quot;21282&quot;&gt;q&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21283&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21284&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21285&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;21286&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21289&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21290&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6893&quot; name=&quot;21291&quot;&gt;lit&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21294&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21295&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21263&quot; name=&quot;21296&quot;&gt;n&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21297&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Primitive Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21298&quot;&gt;+&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21299&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21279&quot; name=&quot;21300&quot;&gt;m&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21301&quot;&gt;))&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21303&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21304&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21305&quot;&gt;cong₂&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21310&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Primitive Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21311&quot;&gt;_+_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21314&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21266&quot; name=&quot;21315&quot;&gt;p&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21316&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21282&quot; name=&quot;21317&quot;&gt;q&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21318&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21319&quot;&gt;
&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21320&quot;&gt;...&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21323&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21324&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21325&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;21326&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21329&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21330&quot; name=&quot;21330&quot;&gt;t′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21332&quot;&gt;      &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21338&quot; name=&quot;21338&quot;&gt;p&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21339&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21340&quot;&gt;|&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21341&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;21342&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21345&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21346&quot; name=&quot;21346&quot;&gt;u′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21348&quot;&gt;      &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21354&quot; name=&quot;21354&quot;&gt;q&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21355&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21356&quot;&gt;=&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21357&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor&quot; href=&quot;http://mazzo.li/posts/Lambda.html#17710&quot; name=&quot;21358&quot;&gt;opt&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21361&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21362&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21330&quot; name=&quot;21363&quot;&gt;t′&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21365&quot;&gt; &lt;/a&gt;&lt;a class=&quot;InductiveConstructor Operator&quot; href=&quot;http://mazzo.li/posts/Lambda.html#6916&quot; name=&quot;21366&quot;&gt;⊕&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21367&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21346&quot; name=&quot;21368&quot;&gt;u′&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21370&quot;&gt;)&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21371&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21372&quot;&gt;(&lt;/a&gt;&lt;a class=&quot;Function&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21373&quot;&gt;cong₂&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21378&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Primitive Operator&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21379&quot;&gt;_+_&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21382&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21338&quot; name=&quot;21383&quot;&gt;p&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;21384&quot;&gt; &lt;/a&gt;&lt;a class=&quot;Bound&quot; href=&quot;http://mazzo.li/posts/Lambda.html#21354&quot; name=&quot;21385&quot;&gt;q&lt;/a&gt;&lt;a class=&quot;Symbol&quot; href=&quot;http://www.blogger.com/null&quot; name=&quot;21386&quot;&gt;)&lt;/a&gt;&lt;/code&gt;&lt;/pre&gt;
And that’s it.&lt;br /&gt;

You can comment this post &lt;a href=&quot;http://www.reddit.com/r/haskell/comments/1k3b8u/agda_by_example_lambdacalculus/&quot;&gt;on reddit&lt;/a&gt;.&lt;br /&gt;

&lt;div class=&quot;footnotes&quot;&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id=&quot;fn1&quot;&gt;See also the Agda version by Ulf Norell in his &lt;a href=&quot;http://www.cse.chalmers.se/%7Eulfn/papers/afp08/tutorial.pdf%E2%80%8E&quot;&gt;&lt;em&gt;Dependently Typed Programming in Agda&lt;/em&gt;&lt;/a&gt; tutorial, after which some of the data types for this tutorial are patterned after.&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#fnref1&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
&lt;li id=&quot;fn2&quot;&gt;See the footnote ad the end of &lt;a href=&quot;http://mazzo.li/posts/Lambda.html#constant-folding&quot;&gt;the section about constant folding&lt;/a&gt;.&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#fnref2&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
&lt;li id=&quot;fn3&quot;&gt;Notice that the &lt;code&gt;no&lt;/code&gt; constructor does not 
include evidence that the term is ill-typed. This could be fixed by 
having a data type representing ill-typed terms.&lt;br /&gt;

Precise types are usually a good idea, not only because they describe
 the program better to humans, but also because machines can do more 
with it. For example, when using &lt;a href=&quot;http://wiki.portal.chalmers.se/agda/agda.php?n=Main.Auto&quot;&gt;&lt;code&gt;Agsy&lt;/code&gt;&lt;/a&gt; with &lt;code&gt;Check&lt;/code&gt;, &lt;code&gt;bad&lt;/code&gt; is always going to be a valid candidate, even if the term we are checking is well typed.&lt;br /&gt;

Here we have chosen a simpler way for brevity, especially since the “error” data type would be fairly boring.&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#fnref3&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
&lt;li id=&quot;fn4&quot;&gt;It has been an ongoing challenge to find a workable theory where functional extensionality holds—a recent proposal is &lt;em&gt;&lt;a href=&quot;http://www.cs.nott.ac.uk/%7Etxa/publ/obseqnow.pdf&quot;&gt;observational equality&lt;/a&gt;&lt;/em&gt;.&lt;br /&gt;

With “workable” we mean among other things a theory where type 
checking is decidable, something that we lose if for example we “solve” 
the problem in a naïve way by adding a rule to derive definitional 
equality (the meta-judgement in the type checker for term equality) from
 propositional equality.&lt;br /&gt;

More broadly the theme of equality is a very debated one in type theory, with &lt;a href=&quot;http://homotopytypetheory.org/&quot;&gt;one related development&lt;/a&gt; getting a lot of people excited lately.&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#fnref4&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
&lt;li id=&quot;fn5&quot;&gt;If we had &lt;code&gt;var&lt;/code&gt; to have &lt;code&gt;lookup v Γ&lt;/code&gt;
 as an index, we would have been unable to pattern match on the 
optimised term here, since Agda would have got stuck trying to decide if
 there should be a case for &lt;code&gt;var&lt;/code&gt;.&lt;a href=&quot;http://mazzo.li/posts/Lambda.html#fnref5&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/7132682381413049780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/agda-by-example-calculus.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/7132682381413049780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/7132682381413049780'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/agda-by-example-calculus.html' title='Agda by Example: λ-calculus'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-498373126296640038</id><published>2013-08-11T09:55:00.001-07:00</published><updated>2013-08-11T09:57:31.730-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="The Importance of Realism in Startups"/><title type='text'>The Importance of Realism in Startups</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;hfeed&quot; id=&quot;container&quot;&gt;
&lt;div id=&quot;header&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;clearfix&quot; id=&quot;wrapper&quot;&gt;
&lt;div class=&quot;grid col-620&quot; id=&quot;content&quot;&gt;
&lt;div class=&quot;post-5814 post type-post status-publish format-standard hentry category-startup-advice&quot; id=&quot;post-5814&quot;&gt;
&lt;h1 class=&quot;entry-title post-title&quot;&gt;
&lt;a href=&quot;http://bit.ly/13sZLwU&quot;&gt;The Importance of Realism in Startups&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;post-meta&quot;&gt;
&lt;span class=&quot;meta-prep meta-prep-author posted&quot;&gt;Posted on &lt;/span&gt;&lt;a href=&quot;http://www.bothsidesofthetable.com/2013/08/10/the-importance-of-realism-in-startups/&quot; rel=&quot;bookmark&quot; title=&quot;8:32 pm&quot;&gt;&lt;span class=&quot;timestamp updated&quot;&gt;August 10, 2013&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;byline&quot;&gt; by &lt;/span&gt;&lt;span class=&quot;author vcard&quot;&gt;&lt;a class=&quot;url fn n&quot; href=&quot;http://www.bothsidesofthetable.com/author/mark-suster/&quot; title=&quot;View all posts by Mark Suster&quot;&gt;Mark Suster&lt;/a&gt;&lt;/span&gt;
   &lt;span class=&quot;comments-link&quot;&gt;
  &lt;span class=&quot;mdash&quot;&gt;—&lt;/span&gt;
 &lt;a data-disqus-identifier=&quot;5814 http://www.bothsidesofthetable.com/?p=5814&quot; href=&quot;http://www.bothsidesofthetable.com/2013/08/10/the-importance-of-realism-in-startups/#disqus_thread&quot; title=&quot;Comment on The Importance of Realism in Startups&quot;&gt;20 Comments and 0 Reactions&lt;/a&gt;  &lt;/span&gt;
&lt;/div&gt;
&lt;div class=&quot;post-entry&quot;&gt;
&lt;div class=&quot;awesm-buttons &quot; id=&quot;awesm-top&quot;&gt;
&lt;div class=&quot;awesm-button-item awesm-button-twitter-tweet&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;awesm-button-item awesm-button-facebook-like&quot;&gt;
&lt;div id=&quot;awesm_fblike_5814&quot;&gt;
&lt;div class=&quot;fb-like fb_edge_widget_with_comment fb_iframe_widget&quot; data-action=&quot;like&quot; data-app-id=&quot;&quot; data-awesm-buttonid=&quot;awesm_fblike_5814&quot; data-awesm-campaign=&quot;&quot; data-awesm-channel=&quot;facebook-like&quot; data-awesm-notes=&quot;&quot; data-awesm-tool=&quot;Dmopck&quot; data-colorscheme=&quot;light&quot; data-font=&quot;lucida grande&quot; data-height=&quot;20&quot; data-href=&quot;http://www.bothsidesofthetable.com/2013/08/10/the-importance-of-realism-in-startups/&quot; data-layout=&quot;button_count&quot; data-ref=&quot;awesmp:_oeem7aoU00kyZc&quot; data-show-faces=&quot;false&quot; data-width=&quot;90&quot;&gt;
&lt;span style=&quot;height: 20px; width: 74px;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;awesm-button-item awesm-button-linkedin&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
I’ve done a lot of video interviews. &lt;a href=&quot;http://techcrunch.com/2013/08/08/fail-week-mark-suster/&quot;&gt;This is one of my favorite if not my favorite outright&lt;/a&gt;.&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;http://techcrunch.com/2013/08/08/fail-week-mark-suster/&quot; rel=&quot;attachment wp-att-5815&quot;&gt;&lt;img alt=&quot;Screen Shot 2013-08-10 at 6.33.27 PM&quot; class=&quot;aligncenter  wp-image-5815&quot; height=&quot;348&quot; src=&quot;http://bothsides.wpengine.netdna-cdn.com/wp-content/uploads/2013/08/Screen-Shot-2013-08-10-at-6.33.27-PM.png&quot; width=&quot;564&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
It’s only 12 minutes long and if you’re a first-time entrepreneur (or second time, frankly) &lt;a href=&quot;http://techcrunch.com/2013/08/08/fail-week-mark-suster/&quot; target=&quot;_blank&quot;&gt;I encourage you to watch it&lt;/a&gt; if for nothing else than to get a sense that your struggles are universal.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
TechCrunch interviewed me and asked me to 
talk about failure. So I spoke for 12 minutes about my own failures. I 
made many classic first-time mistakes which makes it easier for me to 
spot when others make similar bad choices.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
It serves both as my warning signal of 
which teams to avoid funding, especially if I perceive they will make 
critical mistakes often led by hubris or naïveté. An obvious example is 
if they talk about M&amp;amp;A deals, teams they could just “bolt on” or 
“doing a rollup in their industry.”&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
It’s why I will never fund &lt;a href=&quot;http://www.bothsidesofthetable.com/2010/10/13/be-careful-not-to-become-a-conference-ho/&quot; target=&quot;_blank&quot;&gt;Conference Ho’s&lt;/a&gt;. I know that this is driven from an unhealthy ego, self-centrism and lack of regard for running options of one’s startup.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Vomit.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
My errors also serve as my source for coaching others teams for more benign mistakes like over-building functionality, &lt;a href=&quot;http://www.bothsidesofthetable.com/2010/11/22/design-for-the-novice-configure-for-the-pro/&quot; target=&quot;_blank&quot;&gt;over-complicating the product&lt;/a&gt; or &lt;a href=&quot;http://www.bothsidesofthetable.com/2011/03/17/whom-should-you-hire-at-a-startup-attitude-over-aptitude/&quot; target=&quot;_blank&quot;&gt;hiring too senior of people&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I think failure is critical for many reasons. Mostly because it makes us better leaders.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
As I’ve written before, “&lt;a href=&quot;http://www.bothsidesofthetable.com/2009/11/05/good-judgment-comes-with-experience-but-experience-comes-from-bad-judgment/&quot;&gt;Good Judgment Comes from Experience, But Experience Comes from Bad Judgment&lt;/a&gt;.”&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
We learn from mistakes. &lt;a href=&quot;http://www.bothsidesofthetable.com/2010/11/25/embrace-losing-it-will-make-you-stronger/&quot; target=&quot;_blank&quot;&gt;We learn from losses&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In part I felt it was important to let people know that we all have failure and make mistakes.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
As I’ve said before, all startups need to realize that &lt;a href=&quot;http://www.bothsidesofthetable.com/2009/08/28/start-ups-are-all-naked-in-the-mirror/&quot; target=&quot;_blank&quot;&gt;every other company still has to see itself naked in the mirror in the morning&lt;/a&gt;.
 Stop reading their press releases or hearing their founder talk about 
he is crushing it. We all know that people who truly are crushing it 
rarely talk about it.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Once you realize that we’re all the same, 
all dealing with the same pressures, fears and struggles – you’ll learn 
to keep more focused on what you’re doing and not whatever everybody 
else is doing.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In my “failure interview” with TechCrunch I
 talked about the biggest stress that really comes from startups – 
dealing with all the other people with whom you work. Startups are 
filled with enormously talented people – often product people &amp;amp; 
engineers. As an industry we’re hardly used to talking openly about 
feelings or resolving conflicts.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
It’s why I believe startup coaches are so 
important and I wish I knew more great ones. If you have great 
experiences please leave names in the comments section.&lt;/div&gt;
&lt;h2&gt;
The Success Bias&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In the end it’s easy to look back triumphantly at our startup experiences and define every move as heroic.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
We of course remember the positive 
outcomes, the rewards, the press celebrations at key moments or at the 
finish line. We of course get all of the accolades if at the tape there 
was a financial pay day.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
And with so many &lt;a href=&quot;http://www.bothsidesofthetable.com/2013/05/13/the-corrosive-downside-of-acquihires/&quot; target=&quot;_blank&quot;&gt;acquihires&lt;/a&gt; these days you never really know who was financially successful and who was safely landing a plane with no engines.&lt;/div&gt;
It’s certainly nice to look at your past accomplishments in your bio.&lt;br /&gt;
Yet these only tell the stories from one side of the startup ledger. 
They are whitewashed&amp;nbsp;falsehoods that mask the struggles. They are only 
one aspect of the startup experience.&lt;br /&gt;
Even along the journey and nowhere near the destination I see many 
startups with their chests pumped out touting their latest deals, 
showing off their swish offices funded by millions of venture funding 
(and not necessarily yet the commensurate business success to afford 
said offices or perks).&lt;br /&gt;
I understand the temptation. In a world with too much tech hype many teams &lt;a href=&quot;http://www.bothsidesofthetable.com/2009/11/29/save-your-spin-for-someone-who-cares/&quot; target=&quot;_blank&quot;&gt;feel the need to constantly spin&lt;/a&gt;.&lt;br /&gt;
I prefer the opposite.&lt;br /&gt;
I prefer realism in startups. It’s part of my stump speech to first-time founders or university students.&lt;br /&gt;
Avoid the stupid mistake I made (and talk about in the video):&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;line-height: 13px;&quot;&gt;raising too much money too quickly&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;building too many features (a mile wide &amp;amp; an inch deep)&lt;/li&gt;
&lt;li&gt;getting too much press before we were ready&lt;/li&gt;
&lt;li&gt;focusing on M&amp;amp;A to fix our problems&lt;/li&gt;
&lt;li&gt;believing our own hype&lt;/li&gt;
&lt;/ul&gt;
Most of the days at a startup are a grind. While you’re in the moment
 it feels like there are as many failures as their are successes.&lt;br /&gt;
Even success feels hollow. I had a friend who was on the front page 
of the business section of one of the top newspapers in the country 
while his company was 30 days from running out of cash. And in all 
seriousness the article prompted his relative to hit him up for money.&lt;br /&gt;
Every first-time entrepreneur who has raised millions in VC will know
 the surrealism of people calling you a millionaire while you are 
figuring out whether you can really afford to pay for a vacation since 
your credit card is already a little bit bruised.&lt;br /&gt;
We put on our brave faces and turn up everyday hoping that in the end
 we won’t feel like frauds. In fact, I believe that one of the largest 
motivators for startups to avoid the ultimate failure is to avoid the 
humiliation of not having every positive press mention seem like you 
were a phony.&lt;br /&gt;
It’s not that you don’t believe in your ultimate outcome – you &lt;i&gt;have&lt;/i&gt; to believe in order to be insane enough to continue the journey against all odds – it’s just that there is nagging self doubt.&lt;br /&gt;
There are of course also external factors you can’t control. You &lt;i&gt;think&lt;/i&gt; investors will continue to finance you – they promised they would – but you never &lt;i&gt;really&lt;/i&gt; know. Until you know.&lt;br /&gt;
In the end you don’t always get the answer you had hoped for.&lt;br /&gt;
&lt;h2&gt;
Youth vs. Wisdom&lt;/h2&gt;
In your youth you have the bravado to face uncertainty with the blind
 optimism that success is inevitable. In short, you don’t know what you 
don’t know. I keep coaching an investor friend of mine that this can be a
 good thing at times and that he shouldn’t be too quickly to discount 
lack of experience from a team with serious talent and full of ambition.&lt;br /&gt;
This “naive optimism” is why I believe younger entrepreneurs are more likely to produce insanely big outcomes.&lt;br /&gt;
Yet youth often brings a triumphalism that blindsides entrepreneurs into missing the macro picture.&lt;br /&gt;
It is why younger entrepreneurs are more likely to drink their own 
Kool-Aid, which of course is dangerous.In bull markets many credit 
themselves with brilliance and industry stewardship when perhaps they 
are merely riding an ephemeral trend fueled by speculative capital.&lt;br /&gt;
Age brings wisdom. Timidity, too. And sometimes cynicism. But age 
brings perspective. If older entrepreneurs are more cautious it’s 
because life’s experiences have taught them to be so.&lt;br /&gt;
Older entrepreneurs tend to spend cash more wisely, for example. They
 feel less in a rush to keep up with the Jones’s since they’ve seen a 
few boom-and-bust cycles and they know it’s a marathon.&lt;br /&gt;
I find older entrepreneurs more willing to have pragmatic debates about competition as well. They realize that &lt;a href=&quot;http://www.bothsidesofthetable.com/2010/12/27/why-you-should-make-your-competitors-your-frenemies/&quot; target=&quot;_blank&quot;&gt;there is often more to be gained by attacking the existing market structure than each other&lt;/a&gt;.&lt;br /&gt;
Older entrepreneurs tend to avoid lawsuits where possible. There is less ego. Younger people still like to fight.&lt;br /&gt;
And for the most part they shy away from premature press because they know the consequences of getting over one’s skis.&lt;br /&gt;
&lt;h2&gt;
The Case for Realism&lt;/h2&gt;
I try my best to blog from a realistic perspective because partly 
because I believe it’s important for people on the journey to have a 
realistic perspective and not feel ashamed at their progress or 
performance.&lt;br /&gt;
It’s why I wrote one of my most read posts – &lt;a href=&quot;http://www.bothsidesofthetable.com/2012/11/18/entrepreneurshit-the-blog-post-on-what-its-really-like/&quot; target=&quot;_blank&quot;&gt;Entrepreneurshit&lt;/a&gt;.&lt;br /&gt;
Because I know many people at big &amp;amp; successful companies or at 
fast-growing startups I know that even they have struggles, doubt, 
insecurities, fear of failure.&lt;br /&gt;
If you knew that it might help you realize that your failures are not so special.&lt;br /&gt;
There is always a tomorrow – even after bankruptcy. A second act. A new career if not a humbled one.&lt;br /&gt;
That’s why I loved the TechCrunch interview.&lt;br /&gt;
It gave me a chance to make sure that wherever you are in your career path you would know that we’ve all been there.&lt;br /&gt;
Even if our bio’s don’t mention it.&lt;br /&gt;
Failure is ok. It’s not the same as losing or being a loser. It’s a set back.&lt;br /&gt;
And it’s how you handle your failures that define you more than anything else.&lt;br /&gt;
****&lt;br /&gt;
p.s. If any of you were at the Foundry Group rock party in San 
Francisco where Ryan McIntyre and Seth Levine rocked with many other VCs
 (David Cremin, David Pakman, who am I forgetting?) then you’ll know how
 heroic this TechCrunch interview really was. It came with one hell of a
 hangover that I blame on unnamed LPs (ahem) and on my inability to say 
no to a challenge (and whiskey). Which come to think of it means I’ve 
really learned nothing at all in my old age. It came after only a few 
hours of sleep in which I had a meeting in the morning with an LP who 
will be smiling if he reads this because he knows that I had to stand 
for my whole meeting with him in order to get through the meeting.&lt;br /&gt;
&lt;div class=&quot;awesm-buttons &quot; id=&quot;awesm-bottom&quot;&gt;
&lt;div class=&quot;awesm-button-item awesm-button-twitter-tweet&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;awesm-button-item awesm-button-facebook-like&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;awesm-button-item awesm-button-facebook-share&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;awesm-button-item awesm-button-linkedin&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;awesm-button-item awesm-button-gplus&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;awesm-button-item awesm-button-email&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;navigation&quot;&gt;
&lt;div class=&quot;previous&quot;&gt;
‹ &lt;a href=&quot;http://www.bothsidesofthetable.com/2013/07/27/getting-back-your-series-a-mojo/&quot; rel=&quot;prev&quot;&gt;Getting Back Your Series A Mojo&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;post-data&quot;&gt;
Posted in &lt;a href=&quot;http://www.bothsidesofthetable.com/category/startup-advice/&quot; title=&quot;View all posts in Startup Advice&quot;&gt;Startup Advice&lt;/a&gt;
 &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;grid col-300 fit&quot; id=&quot;widgets&quot;&gt;
&lt;div class=&quot;widget-wrapper widget_text&quot; id=&quot;text-6&quot;&gt;
&lt;div class=&quot;textwidget&quot;&gt;
&lt;img src=&quot;http://bothsides.wpengine.netdna-cdn.com/wp-content/plugins/bsott-custom-css/images/mark.png&quot; /&gt;
&lt;br /&gt;
&lt;b&gt;Mark Suster&lt;/b&gt; is a 2x entrepreneur who has gone to the Dark Side of VC. He joined &lt;a href=&quot;http://www.upfront.com/&quot; target=&quot;_blank&quot;&gt;Upfront Ventures&lt;/a&gt; in 2007 as a General Partner after selling his company to Salesforce.com.  He focuses on early-stage technology companies. &lt;a href=&quot;http://bothsidesofthetable.com/about&quot;&gt;Read more about Mark&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/498373126296640038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/the-importance-of-realism-in-startups.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/498373126296640038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/498373126296640038'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/the-importance-of-realism-in-startups.html' title='The Importance of Realism in Startups'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-8308098015262892731</id><published>2013-08-11T09:52:00.002-07:00</published><updated>2013-08-11T09:52:48.731-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="haskell"/><title type='text'>The Evolution of a Haskell Programmer</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;

&lt;br /&gt;
&lt;h1&gt;
&lt;a href=&quot;http://bit.ly/13sZwlm&quot;&gt;The Evolution of a Haskell Programmer&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;auth&quot;&gt;
Fritz Ruehr, Willamette University&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;note&quot;&gt;
 See Iavor Diatchki’s page
 “&lt;a href=&quot;http://www.cse.ogi.edu/%7Ediatchki/jokes/programmer.html&quot;&gt;The Evolution of a Programmer&lt;/a&gt;”
 for the “original” (though he is not the author), and also 
 &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#backstory&quot;&gt;below&lt;/a&gt;
 for the story behind this version.
&lt;br /&gt;&lt;br /&gt;
&lt;small&gt;
&amp;nbsp;&amp;nbsp;
 (This page has been translated into the
  &lt;a href=&quot;http://science.webhostinggeeks.com/haskell-programer&quot;&gt;Serbo-Croatian&lt;/a&gt;
 language by Anja Skrba from &lt;a href=&quot;http://webhostinggeeks.com/&quot;&gt; Webhostinggeeks.com&lt;/a&gt;.
 &lt;i&gt;Thanks, Anja, for all your hard work!&lt;/i&gt;)
&lt;/small&gt;
&lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;freshman&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Freshman Haskell programmer&lt;/h3&gt;
&lt;code&gt;&lt;pre&gt;fac n = if n == 0 
           then 1
           else n * fac (n-1)
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;sophomore&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Sophomore Haskell programmer, at MIT&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (studied Scheme as a freshman)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;fac = (\(n) -&amp;gt;
        (if ((==) n 0)
            then 1
            else ((*) n (fac ((-) n 1)))))
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;junior&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Junior Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (beginning Peano player)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;fac  0    =  1
fac (n+1) = (n+1) * fac n
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;junior-no-nk&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Another junior Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (read that n+k patterns are “a disgusting part of Haskell” &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[1]&lt;/a&gt;
 &lt;br /&gt;
 and joined the “Ban n+k patterns”-movement &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[2]&lt;/a&gt;)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;fac 0 = 1
fac n = n * fac (n-1)
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;senior-right&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Senior Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (voted for &amp;nbsp; &lt;strike&gt;Nixon&lt;/strike&gt; &amp;nbsp; 
 &lt;strike&gt;Buchanan&lt;/strike&gt; &amp;nbsp; Bush — “leans right”)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;fac n = foldr (*) 1 [1..n]
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;senior-left&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Another senior Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (voted for &amp;nbsp; &lt;strike&gt;McGovern&lt;/strike&gt; &amp;nbsp; 
 &lt;strike&gt;Biafra&lt;/strike&gt; &amp;nbsp; Nader — “leans left”)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;fac n = foldl (*) 1 [1..n]
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;senior-left-right&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Yet another senior Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (leaned so far right he came back left again!)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;-- using foldr to simulate foldl

fac n = foldr (\x g n -&amp;gt; g (x*n)) id [1..n] 1
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;memoizing&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Memoizing Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (takes Ginkgo Biloba daily)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;facs = scanl (*) 1 [1..]

fac n = facs !! n
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;pointsfree&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
&lt;strike&gt;Pointless&lt;/strike&gt; &lt;i&gt;&lt;small&gt;(ahem)&lt;/small&gt; 
“Points-free”&lt;/i&gt; Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (studied at Oxford)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;fac = foldr (*) 1 . enumFromTo 1
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;iterative&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Iterative Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (former Pascal programmer)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;fac n = result (for init next done)
        where init = (0,1)
              next   (i,m) = (i+1, m * (i+1))
              done   (i,_) = i==n
              result (_,m) = m

for i n d = until d n i
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;oneliner&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Iterative one-liner Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (former APL and C programmer)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;fac n = snd (until ((&amp;gt;n) . fst) (\(i,m) -&amp;gt; (i+1, i*m)) (1,1))
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;accumulating&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Accumulating Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (building up to a quick climax)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;facAcc a 0 = a
facAcc a n = facAcc (n*a) (n-1)

fac = facAcc 1
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;continuation&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Continuation-passing Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (raised RABBITS in early years, then moved to New Jersey)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;facCps k 0 = k 1
facCps k n = facCps (k . (n *)) (n-1)

fac = facCps id
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;boyscout&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Boy Scout Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (likes tying knots; always “reverent,” he
 &lt;br /&gt;
 belongs to the &lt;i&gt;Church of the Least Fixed-Point&lt;/i&gt; &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[8]&lt;/a&gt;)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;y f = f (y f)

fac = y (\f n -&amp;gt; if (n==0) then 1 else n * f (n-1))
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;combinatory&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Combinatory Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (eschews variables, if not obfuscation;
 &lt;br /&gt;
 all this currying’s just a phase, though it seldom hinders)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;s f g x = f x (g x)

k x y   = x

b f g x = f (g x)

c f g x = f x g

y f     = f (y f)

cond p f g x = if p x then f x else g x

fac  = y (b (cond ((==) 0) (k 1)) (b (s (*)) (c b pred)))
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;listencoding&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
List-encoding Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (prefers to count in unary)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;arb = ()    -- &quot;undefined&quot; is also a good RHS, as is &quot;arb&quot; :)

listenc n = replicate n arb
listprj f = length . f . listenc

listprod xs ys = [ i (x,y) | x&amp;lt;-xs, y&amp;lt;-ys ]
                 where i _ = arb

facl []         = listenc  1
facl n@(_:pred) = listprod n (facl pred)

fac = listprj facl
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;interpretive&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Interpretive Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (never “met a language” he didn&#39;t like)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;-- a dynamically-typed term language

data Term = Occ Var
          | Use Prim
          | Lit Integer
          | App Term Term
          | Abs Var  Term
          | Rec Var  Term

type Var  = String
type Prim = String


-- a domain of values, including functions

data Value = Num  Integer
           | Bool Bool
           | Fun (Value -&amp;gt; Value)

instance Show Value where
  show (Num  n) = show n
  show (Bool b) = show b
  show (Fun  _) = &quot;&quot;

prjFun (Fun f) = f
prjFun  _      = error &quot;bad function value&quot;

prjNum (Num n) = n
prjNum  _      = error &quot;bad numeric value&quot;

prjBool (Bool b) = b
prjBool  _       = error &quot;bad boolean value&quot;

binOp inj f = Fun (\i -&amp;gt; (Fun (\j -&amp;gt; inj (f (prjNum i) (prjNum j)))))


-- environments mapping variables to values

type Env = [(Var, Value)]

getval x env =  case lookup x env of
                  Just v  -&amp;gt; v
                  Nothing -&amp;gt; error (&quot;no value for &quot; ++ x)


-- an environment-based evaluation function

eval env (Occ x) = getval x env
eval env (Use c) = getval c prims
eval env (Lit k) = Num k
eval env (App m n) = prjFun (eval env m) (eval env n)
eval env (Abs x m) = Fun  (\v -&amp;gt; eval ((x,v) : env) m)
eval env (Rec x m) = f where f = eval ((x,f) : env) m


-- a (fixed) &quot;environment&quot; of language primitives

times = binOp Num  (*)
minus = binOp Num  (-)
equal = binOp Bool (==)
cond  = Fun (\b -&amp;gt; Fun (\x -&amp;gt; Fun (\y -&amp;gt; if (prjBool b) then x else y)))

prims = [ (&quot;*&quot;, times), (&quot;-&quot;, minus), (&quot;==&quot;, equal), (&quot;if&quot;, cond) ]


-- a term representing factorial and a &quot;wrapper&quot; for evaluation

facTerm = Rec &quot;f&quot; (Abs &quot;n&quot; 
              (App (App (App (Use &quot;if&quot;)
                   (App (App (Use &quot;==&quot;) (Occ &quot;n&quot;)) (Lit 0))) (Lit 1))
                   (App (App (Use &quot;*&quot;)  (Occ &quot;n&quot;))
                        (App (Occ &quot;f&quot;)  
                             (App (App (Use &quot;-&quot;) (Occ &quot;n&quot;)) (Lit 1))))))

fac n = prjNum (eval [] (App facTerm (Lit n)))
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;fundep&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Static Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (he does it with class, he’s got that fundep Jones!
 &lt;br /&gt;
 After Thomas Hallgren’s “Fun with Functional Dependencies” &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[7]&lt;/a&gt;)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;-- static Peano constructors and numerals

data Zero
data Succ n

type One   = Succ Zero
type Two   = Succ One
type Three = Succ Two
type Four  = Succ Three


-- dynamic representatives for static Peanos

zero  = undefined :: Zero
one   = undefined :: One
two   = undefined :: Two
three = undefined :: Three
four  = undefined :: Four


-- addition, a la Prolog

class Add a b c | a b -&amp;gt; c where
  add :: a -&amp;gt; b -&amp;gt; c
  
instance              Add  Zero    b  b
instance Add a b c =&amp;gt; Add (Succ a) b (Succ c)


-- multiplication, a la Prolog

class Mul a b c | a b -&amp;gt; c where
  mul :: a -&amp;gt; b -&amp;gt; c

instance                           Mul  Zero    b Zero
instance (Mul a b c, Add b c d) =&amp;gt; Mul (Succ a) b d


-- factorial, a la Prolog

class Fac a b | a -&amp;gt; b where
  fac :: a -&amp;gt; b

instance                                Fac  Zero    One
instance (Fac n k, Mul (Succ n) k m) =&amp;gt; Fac (Succ n) m

-- try, for &quot;instance&quot; (sorry):
-- 
--     :t fac four
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;peano&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Beginning graduate Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (graduate education tends to liberate one from petty concerns
 &lt;br /&gt;
 about, e.g., the efficiency of hardware-based integers)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;-- the natural numbers, a la Peano

data Nat = Zero | Succ Nat


-- iteration and some applications

iter z s  Zero    = z
iter z s (Succ n) = s (iter z s n)

plus n = iter n     Succ
mult n = iter Zero (plus n)


-- primitive recursion

primrec z s  Zero    = z
primrec z s (Succ n) = s n (primrec z s n)


-- two versions of factorial

fac  = snd . iter (one, one) (\(a,b) -&amp;gt; (Succ a, mult a b))
fac&#39; = primrec one (mult . Succ)


-- for convenience and testing (try e.g. &quot;fac five&quot;)

int = iter 0 (1+)

instance Show Nat where
  show = show . int

(zero : one : two : three : four : five : _) = iterate Succ Zero
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;origami&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Origamist Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (always starts out with the “basic Bird fold”)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;-- (curried, list) fold and an application

fold c n []     = n
fold c n (x:xs) = c x (fold c n xs)

prod = fold (*) 1


-- (curried, boolean-based, list) unfold and an application

unfold p f g x = 
  if p x 
     then [] 
     else f x : unfold p f g (g x)

downfrom = unfold (==0) id pred


-- hylomorphisms, as-is or &quot;unfolded&quot; (ouch! sorry ...)

refold  c n p f g   = fold c n . unfold p f g

refold&#39; c n p f g x = 
  if p x 
     then n 
     else c (f x) (refold&#39; c n p f g (g x))
                         

-- several versions of factorial, all (extensionally) equivalent

fac   = prod . downfrom
fac&#39;  = refold  (*) 1 (==0) id pred
fac&#39;&#39; = refold&#39; (*) 1 (==0) id pred
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;cartesian&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Cartesianally-inclined Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (prefers Greek food, avoids the spicy Indian stuff;
 &lt;br /&gt;
 inspired by Lex Augusteijn’s “Sorting Morphisms” &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[3]&lt;/a&gt;)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;-- (product-based, list) catamorphisms and an application

cata (n,c) []     = n
cata (n,c) (x:xs) = c (x, cata (n,c) xs)

mult = uncurry (*)
prod = cata (1, mult)


-- (co-product-based, list) anamorphisms and an application

ana f = either (const []) (cons . pair (id, ana f)) . f

cons = uncurry (:)

downfrom = ana uncount

uncount 0 = Left  ()
uncount n = Right (n, n-1)


-- two variations on list hylomorphisms

hylo  f  g    = cata g . ana f

hylo&#39; f (n,c) = either (const n) (c . pair (id, hylo&#39; f (c,n))) . f

pair (f,g) (x,y) = (f x, g y)


-- several versions of factorial, all (extensionally) equivalent

fac   = prod . downfrom
fac&#39;  = hylo  uncount (1, mult)
fac&#39;&#39; = hylo&#39; uncount (1, mult)
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;categorical&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Ph.D. Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (ate so many bananas that his eyes bugged out, now he needs new lenses!)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;-- explicit type recursion based on functors

newtype Mu f = Mu (f (Mu f))  deriving Show

in      x  = Mu x
out (Mu x) = x


-- cata- and ana-morphisms, now for *arbitrary* (regular) base functors

cata phi = phi . fmap (cata phi) . out
ana  psi = in  . fmap (ana  psi) . psi


-- base functor and data type for natural numbers,
-- using a curried elimination operator

data N b = Zero | Succ b  deriving Show

instance Functor N where
  fmap f = nelim Zero (Succ . f)

nelim z s  Zero    = z
nelim z s (Succ n) = s n

type Nat = Mu N


-- conversion to internal numbers, conveniences and applications

int = cata (nelim 0 (1+))

instance Show Nat where
  show = show . int

zero = in   Zero
suck = in . Succ       -- pardon my &quot;French&quot; (Prelude conflict)

plus n = cata (nelim n     suck   )
mult n = cata (nelim zero (plus n))


-- base functor and data type for lists

data L a b = Nil | Cons a b  deriving Show

instance Functor (L a) where
  fmap f = lelim Nil (\a b -&amp;gt; Cons a (f b))

lelim n c  Nil       = n
lelim n c (Cons a b) = c a b

type List a = Mu (L a)


-- conversion to internal lists, conveniences and applications

list = cata (lelim [] (:))

instance Show a =&amp;gt; Show (List a) where
  show = show . list

prod = cata (lelim (suck zero) mult)

upto = ana (nelim Nil (diag (Cons . suck)) . out)

diag f x = f x x

fac = prod . upto
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;comonadic&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Post-doc Haskell programmer&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (from Uustalu, Vene and Pardo’s “Recursion Schemes from Comonads” &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[4]&lt;/a&gt;)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;-- explicit type recursion with functors and catamorphisms

newtype Mu f = In (f (Mu f))

unIn (In x) = x

cata phi = phi . fmap (cata phi) . unIn


-- base functor and data type for natural numbers,
-- using locally-defined &quot;eliminators&quot;

data N c = Z | S c

instance Functor N where
  fmap g  Z    = Z
  fmap g (S x) = S (g x)

type Nat = Mu N

zero   = In  Z
suck n = In (S n)

add m = cata phi where
  phi  Z    = m
  phi (S f) = suck f

mult m = cata phi where
  phi  Z    = zero
  phi (S f) = add m f


-- explicit products and their functorial action

data Prod e c = Pair c e

outl (Pair x y) = x
outr (Pair x y) = y

fork f g x = Pair (f x) (g x)

instance Functor (Prod e) where
  fmap g = fork (g . outl) outr


-- comonads, the categorical &quot;opposite&quot; of monads

class Functor n =&amp;gt; Comonad n where
  extr :: n a -&amp;gt; a
  dupl :: n a -&amp;gt; n (n a)

instance Comonad (Prod e) where
  extr = outl
  dupl = fork id outr


-- generalized catamorphisms, zygomorphisms and paramorphisms

gcata :: (Functor f, Comonad n) =&amp;gt;
           (forall a. f (n a) -&amp;gt; n (f a))
             -&amp;gt; (f (n c) -&amp;gt; c) -&amp;gt; Mu f -&amp;gt; c

gcata dist phi = extr . cata (fmap phi . dist . fmap dupl)

zygo chi = gcata (fork (fmap outl) (chi . fmap outr))

para :: Functor f =&amp;gt; (f (Prod (Mu f) c) -&amp;gt; c) -&amp;gt; Mu f -&amp;gt; c
para = zygo In


-- factorial, the *hard* way!

fac = para phi where
  phi  Z             = suck zero
  phi (S (Pair f n)) = mult f (suck n)
  

-- for convenience and testing

int = cata phi where
  phi  Z    = 0
  phi (S f) = 1 + f

instance Show (Mu N) where
  show = show . int
&lt;/pre&gt;
&lt;/code&gt;



&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;tenured&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h3&gt;
Tenured professor&lt;/h3&gt;
&lt;div class=&quot;cmt&quot;&gt;
 (teaching Haskell to freshmen)
&lt;/div&gt;
&lt;code&gt;&lt;pre&gt;fac n = product [1..n]
&lt;/pre&gt;
&lt;/code&gt;





&lt;br /&gt;
&lt;hr /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;backstory&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h2&gt;
Background&lt;/h2&gt;
On 19 June 2001, at the 
&lt;a href=&quot;http://www.cse.ogi.edu/%7Emagnus/SeminarSeries/&quot;&gt;
 OGI PacSoft Tuesday Morning Seminar Series
&lt;/a&gt;,
&lt;a href=&quot;http://www.cse.ogi.edu/%7Ediatchki/&quot;&gt;Iavor Diatchki&lt;/a&gt;
presented the paper 
“Recursion Schemes from Comonads” by 
Uustalu, Vene and Pardo &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[4]&lt;/a&gt;. 
I attended Iavor’s excellent presentation 
and remarked that I found the end of the paper
rather anti-climactic: after much categorical effort and the definition
of several generalized recursion combinators, the main examples were
the factorial and Fibonacci functions. (Of course, I offered no better
examples myself, so this was rather unfair carping.)

Some time later, I came across Iavor’s &quot;jokes&quot; page, including a 
funny bit called
“&lt;a href=&quot;http://www.cse.ogi.edu/%7Ediatchki/jokes/programmer.html&quot;&gt;The Evolution of a Programmer&lt;/a&gt;” 
in which the traditional imperative &quot;Hello, world&quot; program is
developed through several variations,
from simple beginnings to a ridiculously complex extreme.
A moment’s thought turned up the factorial function as the best
functional counterpart of &quot;Hello, world&quot;. 
Suddenly the Muse struck and I knew I must write out these examples,
culminating (well, almost) in the heavily generalized categorical
version of factorial provided by Uustalu, Vene and Pardo.

&lt;br /&gt;

I suppose this is what you’d have to call “small-audience” humour.

&lt;br /&gt;

&lt;b&gt;PS:&lt;/b&gt;
I’ve put all the code into a 
&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.hs&quot;&gt;better-formatted text file&lt;/a&gt;
for those who might like to experiment with the different variations 
(you could also just cut and paste a section from your browser).

&lt;br /&gt;

&lt;b&gt;PPS:&lt;/b&gt;
As noted above, Iavor is not the original author of
“The Evolution of a Programmer.”
A quick web search suggests that there are thousands of copies
floating around and it appears (unattributed) in humor newsgroups as
far back as 1995. But I suspect some version of it goes back much
further than that. Of course, if anyone does know who wrote the original, 
please let me know so that I may credit them here.
&lt;br /&gt;





&lt;br /&gt;
&lt;hr /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;pedagogy&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h2&gt;
But seriously, folks, ...&lt;/h2&gt;
On a more serious note, I think that the basic idea of the joke
(successive variations on a theme, building in complexity)
can serve a good pedagogical purpose as well as a humorous one.
To that end, and for those who may not be familiar
with all of the ideas represented above, I offer the following
comments on the variations:

The &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#freshman&quot;&gt;first version&lt;/a&gt;
(straight recursion with conditionals)
is probably familiar to programmers of all stripes;
fans of LISP and Scheme will find the 
&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#freshman&quot;&gt;sophomore version&lt;/a&gt; especially readable,
except for the funny spelling of 
“lambda” and the absence of “define”
(or “defun”).
The use of &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#junior&quot;&gt;patterns&lt;/a&gt; 
may seem only a slight shift in perspective, 
but in addition to mirroring mathematical notation,
patterns encourage the view of data types as 
initial algebras (or as inductively defined).
&lt;br /&gt;

The use of more “structural” recursion combinators (such as 
&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#senior-right&quot;&gt;foldr&lt;/a&gt; and &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#senior-left&quot;&gt;foldl&lt;/a&gt;) is 
square in the spirit of functional programming: these higher-order functions
abstract away from the common details of different instances of
recursive definitions, recovering the specifics through function arguments. 
The “&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#points-free&quot;&gt;points-free&lt;/a&gt;” style 
(defining functions without explicit reference to their formal parameters)
can be compelling, but it can also be over-done;
here the intent is to foreshadow similar usage in some of the
later, more stridently algebraic variations.
&lt;br /&gt;

The &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#accumulating&quot;&gt;accumulating-parameter&lt;/a&gt; version illustrates
a traditional technique for speeding up functional code. It is the
second fastest implementation here, at least as measured in terms of
number of reductions reported by Hugs,
with the &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#iterative&quot;&gt;iterative&lt;/a&gt; versions coming in third. 
Although the latter run somewhat against the spirit of functional 
programming, they do give the flavor of the functional simulation
of state as used in denotational semantics or, for that matter,
in monads. (Monads are woefully un-represented here; I would
be grateful if someone could contribute a few (progressive)
examples in the spirit of the development above.) The 
&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#continuation&quot;&gt;continuation-passing&lt;/a&gt; version 
recalls a denotational account of control 
(the references are to Steele’s RABBIT compiler for Scheme 
and the SML/NJ compiler).
&lt;br /&gt;

The &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#boyscout&quot;&gt;fixed-point version&lt;/a&gt;
demonstrates that we can isolate recursion in a general Y combinator.
The &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#combinatory&quot;&gt;combinatory&lt;/a&gt; version provides an
extreme take on the points-free style inspired by Combinatory Logic,
isolating dependence on variable names to the definitions of a few combinators.
Of course we could go further, defining the Naturals and Booleans
in combinatory terms, but note that the predecessor function will be
a bit hard to accomodate (this is one good justification for algebraic
types). Also note that we cannot define the Y combinator in terms of the 
others without running into typing problems (due essentially to issues of
self-application). Interestingly, this is the fastest of all of the
implementations, perhaps reflecting the underlying graph reduction 
mechanisms used in the implementation.
&lt;br /&gt;

The &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#listencoding&quot;&gt;list-encoded&lt;/a&gt; version exploits the simple
observation that we can count in unary by using lists of arbitrary
elements, so that the length of a list encodes a natural number.
In some sense this idea foreshadows later versions based on recursive
type definitions for Peano’s naturals, since lists of units are
isomorphic to naturals. The only interesting thing here is that
multiplication (numeric product) is seen to arise naturally out of 
combination (Cartesian product) by way of cardinality.
Typing issues make it hard to express this correspondence as directly 
as we’d like:
the following definition of listprod would break the definition
of the facl function due to an occurs-check/infinite type:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;code&gt;listprod xs ys = [ (x,y) | x&amp;lt;-xs, y&amp;lt;-ys ]&lt;/code&gt;
&lt;/blockquote&gt;
Of course we could also simplify as follows, but only at the expense
of obscuring the relationship between the two kinds of products:
&lt;blockquote&gt;
&lt;code&gt;listprod xs ys = [ arb | x&amp;lt;-xs, y&amp;lt;-ys ]&lt;/code&gt;
&lt;/blockquote&gt;
The &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#interpretive&quot;&gt;interpretive&lt;/a&gt; version implements a small 
object language rich enough to express factorial, and then implements
an interpreter for it based on a simple environment model. Exercises
along these lines run all through the latter half of the Friedman,
Wand and Haynes text (&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[6]&lt;/a&gt;), albeit expressed
there in Scheme. We used to get
flack from students at &lt;a href=&quot;http://www.cs.oberlin.edu/&quot;&gt;Oberlin&lt;/a&gt; 
when we made them implement twelve interpreters in a single 
week-long lab, successively exposing more of the implementation by
moving the real work from the meta-language to the interpreter. This
implementation leaves a whole lot on the shoulders of the meta-language,
corresponding to about Tuesday or Wednesday in their week. Industrious 
readers are invited to implement a compiler for a Squiggol-like language
of polytypic folds and unfolds, targeting (and simulating) a suitable
categorical abstract machine (see &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[9]&lt;/a&gt;), 
and then to implement factorial in that setting 
(but don&#39;t blame me if it makes you late for lunch ...).
&lt;br /&gt;

The &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#fundep&quot;&gt;statically-computed&lt;/a&gt; version uses 
type classes and &lt;i&gt;functional dependencies&lt;/i&gt; to facilitate computation 
at compile time 
(the latter are recent extensions to the Haskell 98 standard by Mark Jones,
and are available in Hugs and GHC). 
The same kinds of techniques can also be used to encode behaviors more often
associated with dependent types and polytypic programming, and are thus a 
topic of much recent interest in the Haskell community. 
The code shown here is based on an account by
Thomas Hallgren (see &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[7]&lt;/a&gt;), extended to include
factorial. Prolog fans will find the definitions particularly easy to read, 
if a bit backwards.
&lt;br /&gt;

The first of the “&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#peano&quot;&gt;graduate&lt;/a&gt;”
versions gets more serious about
recursion, defining natural numbers as a recursive
algebraic datatype and highlighting the difference between
iteration and primitive recursion.  
The “&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#origami&quot;&gt;origamist&lt;/a&gt;”
and “&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#cartesian&quot;&gt;cartesian&lt;/a&gt;”
variations take a small step backwards in this regard,
as they return to the use of internal integer and list types.
They serve, however, to introduce anamorphic and hylomorphic notions 
in a more familiar context.
&lt;br /&gt;

The “&lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#categorical&quot;&gt;Ph.D&lt;/a&gt;” example 
employs the categorical style
of BMF/Squiggol in a serious way (we could actually
go a bit further, by using co-products more directly, and thus
eliminate some of the overt dependence on the “internal 
sums” of the data type definition mechanism). 
&lt;br /&gt;

By the time we arrive at the “pièce de résistance”,
the &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#comonadic&quot;&gt;comonadic&lt;/a&gt; version of Uustalu, Vene and Pardo, 
we have covered most of the underlying ideas and can (hopefully)
concentrate better on their specific contributions. 
The &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#tenured&quot;&gt;final&lt;/a&gt; version, 
using the Prelude-defined product function and ellipsis 
notation, is how I think the function is most clearly expressed,
presuming some knowledge of the language and Prelude definitions. 
(This definition also dates back at least to David Turner’s KRC* language &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[5]&lt;/a&gt;.)
&lt;br /&gt;

It is comforting to know that the Prelude ultimately uses
a recursion combinator (foldl&#39;, the strict version of foldl)
to define product.
I guess we can all hope to see the day when the Prelude
will define gcatamorphic, zygomorphic and paramorphic combinators
for us, so that factorial can be defined both conveniently &lt;em&gt;and&lt;/em&gt;
with greater dignity :) .

&lt;br /&gt;


&lt;br /&gt;
&lt;hr align=&quot;left&quot; width=&quot;200&quot; /&gt;

* &lt;small&gt;&lt;i&gt;KRC may or may not be a trademark of Research Software, Ltd.,
&lt;br /&gt;&amp;nbsp; &amp;nbsp; but you can bet your sweet bippy that 
&lt;/i&gt;Miranda ™ &lt;i&gt;is!&lt;/i&gt;&lt;/small&gt;







&lt;br /&gt;
&lt;hr /&gt;
&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;revisions&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h2&gt;
Revision history&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;20 August 01&lt;/i&gt;: 
 added the &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#interpretive&quot;&gt;interpretive&lt;/a&gt; version,
 based on an environment model of a small object language 
 (no, not in &lt;i&gt;that &lt;/i&gt; sense of object ...).
 I’m thinking about re-arranging the order of the
 examples, so that longer ones that are not part of
 the main line of development don&#39;t intrude so much.
 I also advertised the page on 
 &lt;a href=&quot;http://haskell.org/mailman/listinfo/haskell-cafe&quot;&gt;the Haskell Café&lt;/a&gt;
 mailing list and requested that a link be added to the 
 &lt;a href=&quot;http://www.haskell.org/humor&quot;&gt;Haskell humor page.&lt;/a&gt;
 Finally, I have an interesting new example in the works that
 may actually have some original research value; more on this soon.
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;14 August 01 (afternoon)&lt;/i&gt;: 
 added the &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#combinatory&quot;&gt;combinatory&lt;/a&gt; version,
 now the fastest of the bunch, as measured in number of
 reductions reported by Hugs.
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;14 August 01 (morning)&lt;/i&gt;: 
 adjusted the &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#sophomore&quot;&gt;sophomore/Scheme&lt;/a&gt; version 
 to use an explicit &quot;lambda&quot; (though we spell it differently
 in Haskell land) and added the &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#boyscout&quot;&gt;fixed-point&lt;/a&gt;
 version.
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;10 August 01&lt;/i&gt;: 
 added the &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#listencoding&quot;&gt;list-encoding&lt;/a&gt; and 
 &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#fundep&quot;&gt;static computation&lt;/a&gt; versions
 (the latter uses type classes and functional dependencies to
 compute factorial during type-checking; it is an
 extended version of code from Thomas Hallgren’s “Fun with
 Functional Dependencies” &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[7]&lt;/a&gt;).
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;1 August 01&lt;/i&gt;: 
 added &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#accumulating&quot;&gt;accumulating-parameter&lt;/a&gt; and 
 &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#continuation&quot;&gt;continuation-passing&lt;/a&gt; versions
 (the latter is a revised
 transliteration from Friedman, Wand and Haynes’ “Essentials
 of Programming Languages” &lt;a href=&quot;http://www.willamette.edu/%7Efruehr/haskell/evolution.html#references&quot;&gt;[5]&lt;/a&gt;).
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;11 July 01&lt;/i&gt;: 
 date of the original posting.
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;hr /&gt;

&lt;a href=&quot;http://www.blogger.com/null&quot; name=&quot;references&quot;&gt;&lt;/a&gt;
&amp;nbsp;
&lt;h2&gt;
References&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;i&gt;Highlights from nhc - a Space-efficient Haskell Compiler,&lt;/i&gt; Niklas Röjemo.
  In the &lt;b&gt;FPCA ‘95 proceedings&lt;/b&gt;. ACM Press, 1995 (see also
  &lt;a href=&quot;http://citeseer.nj.nec.com/nbib/5076458&quot;&gt;CiteSeer&lt;/a&gt;
  or 
  &lt;a href=&quot;ftp://ftp.cs.chalmers.se/pub/users/rojemo/fpca95.ps.gz&quot;&gt;Chalmers ftp archive&lt;/a&gt;)
  
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;n+k patterns,&lt;/i&gt; Lennart Augustsson. Message to the haskell mailing list,
  Mon, 17 May 93 (see
  &lt;a href=&quot;http://www.mail-archive.com/haskell@haskell.org/msg01261.html&quot;&gt;
  the mailing list archive&lt;/a&gt;)
  
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;Sorting Morphisms,&lt;/i&gt;Lex Augusteijn. In &lt;b&gt;Advanced Functional Programming&lt;/b&gt;, 
  (LNCS 1608). Springer-Verlag, 1999 (see also 
  &lt;a href=&quot;http://citeseer.nj.nec.com/augusteijn99sorting.html&quot;&gt;CiteSeer&lt;/a&gt;).
  
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;Recursion Schemes from Comonads,&lt;/i&gt; T. Uustalu, V. Vene and A. Pardo. 
  &lt;b&gt;Nordic Journal of Computing&lt;/b&gt;, to appear (see also
  &lt;a href=&quot;http://www.cs.ioc.ee/%7Etarmo/papers/&quot;&gt;
  Tarmo Uustalu’s papers page&lt;/a&gt;).
  
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;Recursion Equations as a Programming Language,&lt;/i&gt; D. A. Turner. 
  In &lt;b&gt;Functional Programming and its Applications&lt;/b&gt;. Cambridge University Press, 1982.
  
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;Essentials of Programming Languages,&lt;/i&gt; D. Friedman, M. Wand and C. Haynes. 
  MIT PRess and McGraw-Hill, 1994.
  
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;Fun with Functional Dependencies,&lt;/i&gt; Thomas Hallgren. 
  &lt;b&gt;Joint Winter Meeting of the Departments of Science and Computer Engineering&lt;/b&gt;,
  Chalmers University of Technology and Göteborg University, Varberg, Sweden, 2001 
  (available at
  &lt;a href=&quot;http://www.cs.chalmers.se/%7Ehallgren/Papers/wm01.html&quot;&gt;
  the author’s web archive&lt;/a&gt;).
  
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;The Church of the Least Fixed-Point,&lt;/i&gt; authour unknown. 
  (A little bit of lambda calculus humor which circulated in the
  mid-1980’s (at least that’s when I saw it), probably from the 
  comp.lang.functional newsgroup or somesuch. 
  Please &lt;a href=&quot;mailto://fruehr@willamette.edu&quot;&gt;write me&lt;/a&gt; 
  if you know the author or any other citation information).
  
 
 &lt;/li&gt;
&lt;li&gt;&lt;i&gt;Categorical Combinators, Sequential Algorithms and Functional Programming,&lt;/i&gt;
  Pierre-Louis Curien. Springer Verlag (2nd edition), 1993.
  

&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;



&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/8308098015262892731/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/the-evolution-of-haskell-programmer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/8308098015262892731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/8308098015262892731'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/the-evolution-of-haskell-programmer.html' title='The Evolution of a Haskell Programmer'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-7631260715445400640</id><published>2013-08-11T09:49:00.001-07:00</published><updated>2013-08-11T09:50:28.471-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mpv"/><title type='text'>Free and open-source general-purpose video player</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;big center&quot;&gt;
      &lt;a href=&quot;http://mpv.io/index.html&quot;&gt;mpv&lt;/a&gt; is a free and open-source general-purpose video player.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;big center&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;big center&quot;&gt;
      &lt;a href=&quot;http://mpv.io/index.html&quot;&gt;mpv&lt;/a&gt; is based on the MPlayer and mplayer2 projects which it greatly improves.
      Learn about the &lt;a href=&quot;https://github.com/mpv-player/mpv/blob/master/DOCS/man/en/changes.rst&quot;&gt;differences&lt;/a&gt;
      with the former projects.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;big center&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;big center&quot;&gt;
Website: &lt;a href=&quot;http://mpv.io/index.html&quot;&gt;http://mpv.io/index.html &lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;big center&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;big center&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/7631260715445400640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/free-and-open-source-general-purpose.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/7631260715445400640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/7631260715445400640'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/free-and-open-source-general-purpose.html' title='Free and open-source general-purpose video player'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-1003217875687179849</id><published>2013-08-05T05:07:00.002-07:00</published><updated>2013-08-05T05:07:48.597-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cricket"/><title type='text'>Cricket</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://bit.ly/193VmIt&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://bit.ly/193VmIt&quot; width=&quot;272&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
A cheating and misappropriation case was registered against the 
Himachal Pradesh Cricket Association (HPCA) on Thursday over alleged 
wrongdoings in allotment of land to the state&#39;s sports body, police 
said. The HPCA said the case was politically motivated.&lt;br /&gt;
&lt;br /&gt;
&quot;The case
 was registered against the HPCA under sections 406, 420 and 120-B of 
the IPC (Indian penal Code) for various irregularities. We will reach 
out to the individuals during the course of investigation,&quot; 
Superintendent of Police (Vigilance) Bimal Gupta told IANS.&lt;br /&gt;
&lt;br /&gt;
Earlier
 in the day, Chief Minister Virbhadra Singh said &quot;Investigation against 
the HPCA is in advance stage. Regular FIR (first information report) 
will be registered shortly.&quot;&lt;br /&gt;
&lt;br /&gt;
The HPCA objected to the case and 
said: &quot;It&#39;s aimed at garnering cheap publicity to divert the attention 
of the people against more pressing and important issues of the people 
of the state.&quot;&lt;br /&gt;
&lt;br /&gt;
On July 26, two Indian Administrative Service 
officers - Deepak Sanan and R.S. Gupta - were charge-sheeted by the 
government for allegedly allowing a change in the land-use of village 
community land for building a residential complex for players near 
HPCA&#39;s cricket stadium in Dharamsala, some 250 km from here.&lt;br /&gt;
&lt;br /&gt;
The HPCA built the complex with 38 rooms, 32 huts and gym just three km from the stadium.&lt;br /&gt;
&lt;br /&gt;
Earlier, the two officers were served show-cause notices over the issue.&lt;br /&gt;
&lt;br /&gt;
The alleged land-use change was approved during the tenure of the previous Bharatiya Janata Party (BJP) government.&lt;br /&gt;
&lt;br /&gt;
The
 state cricket body is headed by BJP MP Anurag Thakur, who is son of 
then chief minister Prem Kumar Dhumal and is the current BCCI joint 
secretary.&lt;br /&gt;
&lt;br /&gt;
Sanan is currently additional chief secretary, animal husbandry, while Gupta is posted as commissioner, inquiries.&lt;br /&gt;
&lt;br /&gt;
The Congress, which at the time of the land change was in the opposition, objected to the land allotment.&lt;br /&gt;
&lt;br /&gt;
The
 Communist Party of India-Marxist, citing a Supreme Court judgment of 
2011 which held the transfer of village community land for private and 
commercial use as illegal, has also demanded that the HPCA should be 
evicted from the land.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;i&gt;Source: http://bit.ly/193VvMh &lt;/i&gt;&lt;/u&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/1003217875687179849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/cricket_5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1003217875687179849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1003217875687179849'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/cricket_5.html' title='Cricket'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-8006005252812109313</id><published>2013-08-05T04:59:00.001-07:00</published><updated>2013-08-05T05:04:02.949-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Moto X"/><title type='text'>Moto X</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The much anticipated smartphone that also takes the title of being the 
worst-kept secret in recent times is finally here. Well sort of. 
Motorola today unveiled the Moto X, the first smartphone made after 
Google announced it was acquiring the company almost exactly two years 
ago. To be available initially in the US for $199 with a two-year 
contract and in Canada and Latin America (sorry, no word on India launch
 but we’d suggest not holding your breath for it), the Moto X aspires to
 be the iPhone of the Android world. Rather than concentrating on 
specifications, Motorola claims it is looking at enhancing experiences. 
The core propositions being a battery that lasts all day, a camera that 
clicks great photos and a user experience that does not require users to
 touch the phone to get information.&lt;br /&gt;
Rather than going for the most expensive silicon, the Moto X is powered
 by a custom Qualcomm Snapdragon S4 dual-core processor that has two 
Krait 300 cores clocked at 1.7GHz and a quad-core Adreno 320 GPU. Along 
with this, Motorola has added two additional DSPs – one that always 
listens for “OK Google Now” command to fire up Google Now and another 
that keeps a track of the phone’s motion to power up the information 
display or turn on the camera. Motorola calls it the Motorola X8 Mobile 
processor.&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/xXyCbrdQEyA?feature=player_embedded&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
For a touch-free experience, users can simply use the command “OK Google
 Now” even when the phone is in sleep mode that wakes it up and will 
initiate Google Now. The phone’s information display also turns on when 
the user picks it up or takes it out from the pocket to display the time
 and notification icons. Rather than keeping the main processor turned 
on all the time, the Moto X uses the two low-power DSPs for these tasks,
 ensuring there is minimal battery drain.&lt;br /&gt;
&lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/vpU1mW0Mjm8?feature=player_embedded&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;br /&gt;
&lt;br /&gt;
Then there is the camera, which Motorola claims enables the users to 
click a photo from the lock screen in the shortest time when compared to
 rival smartphones. A flick of the wrist signals the phone that a user 
wants to click a photo and turns on the camera automatically. Motorola 
is touting a 10-megapixel Clear Pixel (RGBC) camera, which it claims 
takes better low-light photographs. There is a 2-megapixel front facing 
camera too.
&lt;br /&gt;

 Surprisingly, despite being a Google company, the Moto X still runs 
Android 4.2.2. Yes, Google had promised that Motorola will get access to
 Android at the same time as its other OEM partners but it remains to be
 seen how long the charade lasts. Thankfully, Android 4.3 has been a 
minor update and we will get to know for sure whether the wall between 
Google and Motorola Mobility indeed exists or if it is a mere 
smokescreen for other OEMs.&lt;br /&gt;


 Talking about hardware specs (yes, despite focusing purely on 
experience, the specifications are important too) we are looking at a 
4.7-inch Super AMOLED 720p display, 2GB of RAM, 16GB of internal 
storage, a 2,200mAh battery, Bluetooth 4.0 and Wi-Fi 802.11 a/b/g/n/ac. 
We have already visited the processor and camera.&lt;br /&gt;
&lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/HnTvmB44Cec?feature=player_embedded&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Motorola is also offering users over 2,000 customization options 
where they can choose the back panel (there’s a wooden option too), the 
accents, engraving and much more. This is limited to the US for the 
moment and it remains to be seen whether Motorola extends it to other 
markets as well.
&lt;br /&gt;

 The Moto X marks the beginning of a trend when Android device vendors 
finally understand that importance of user experience over core hardware
 specifications. But, as things would have it, we are not sure if users 
are ready to accept what’s eventually good for them. After all, most pay
 for the hardware they get and the market value of a smartphone is still
 pegged on the basis of the hardware it runs rather than its 
capabilities and the experience it provides. And that is where Motorola 
probably lost the opportunity. It could have passed on the cost savings 
of using last year’s hardware to potential customers rather than 
matching the price tags of today’s flagship smartphones.&lt;br /&gt;


 View the original article &lt;a href=&quot;http://www.bgr.in/manufacturers/motorola/moto-x-officially-launches-focuses-on-experience-over-specifications/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/8006005252812109313/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/moto-x.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/8006005252812109313'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/8006005252812109313'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/moto-x.html' title='Moto X'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/xXyCbrdQEyA/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-6952317048333277576</id><published>2013-08-05T04:56:00.002-07:00</published><updated>2013-08-05T04:56:54.630-07:00</updated><title type='text'>Cricket</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;article-body-blocks&quot;&gt;
     For advocates of sports technology, a summer watching &lt;a href=&quot;http://www.theguardian.com/sport/2013/aug/01/australia-usman-khawaja-dismissal&quot; title=&quot;&quot;&gt;DRS doing its best to add controversy to the Ashes&lt;/a&gt;,
 rather than take it away, has been a faith-tester. But the story has 
called attention to some key lessons – and football needs to learn them.&lt;br /&gt;
On Thursday the &lt;a href=&quot;http://www.theguardian.com/football/2013/apr/11/premier-league-hawkeye-goalline-technology?CMP=twt_gu&quot; title=&quot;&quot;&gt;Premier League launches its new Hawk-Eye system&lt;/a&gt;, installed at all 20 &lt;a href=&quot;http://www.theguardian.com/football/premierleague&quot; title=&quot;More from guardian.co.uk on Premier League&quot;&gt;Premier League&lt;/a&gt;
 grounds. It&#39;s a historic moment: a game-changing shift in the way the 
laws are applied, and the first significant intervention of technology 
in our game. In my view it is a brilliant, overdue development – but how
 we handle it from this point forwards will be crucial.&lt;br /&gt;
We set off
 on this road back in the summer of 2006 when I met Dr Paul Hawkins, the
 head of Hawk-Eye, to trial a rudimentary prototype system at Fulham&#39;s 
training ground. Even then, his early, scaffolding-rigged system was 
most noticeable for being unnoticeable: the decisions it made were 
instant, accurate and unobtrusive, and relayed in a heartbeat to the 
referee.&lt;br /&gt;
The delay since then in rolling it out was &lt;a href=&quot;http://www.theguardian.com/football/2013/apr/13/keith-hackett-goalline-technology-hawk-eye&quot; title=&quot;&quot;&gt;down to a frustrating, stubborn lack of vision&lt;/a&gt;
 from the world game&#39;s governing bodies – resisting change despite the 
evidence, and despite the fact that in England alone we were seeing 
around 10 valid goals ruled out every season.&lt;br /&gt;
But now, seven years
 on, we are finally in a position to be able to show off this &quot;new&quot; 
technology. The relief will be immense for those officials who go into 
the opening day equipped with wrist sensors – small devices which will 
alert them when the whole of the ball has crossed the line. It is as 
simple as that – no stoppage, no waiting for a third party, no endless 
replays. And that is crucial.&lt;br /&gt;
The Ashes has taught us two things. 
First, that the use of technology in cricket – and in rugby and tennis –
 fits stop-start games in a way it could never fit with free-flowing 
football. Second, a black and white pre-emptive clarity, one which 
protects the referee&#39;s credibility, is essential.&lt;br /&gt;
The beauty of 
the goalline system is that it makes the decision almost before anyone 
has a chance to react, and without an appeal. In cricket, the ability of
 players to call for reviews leads to delays and, most crucially, 
undermines the umpires&#39; authority, with everyone encouraged to doubt 
them. We cannot follow that path.&lt;br /&gt;
Technology can contribute to 
football in two ways: for matter-of-fact, instant goalline decisions, 
and for retrospective punishments where players have committed red card 
offences which have been missed. On every other aspect of the game, for 
corners, offsides, cards and so on, we need to resist calls for further 
intervention.&lt;br /&gt;
Our referees are the best trained in the world, and 
they are employed specifically for their well-tested ability to judge 
and read a game, and to interpret events in a human way. This season 
they will be doing that backed by one simple piece of kit which takes  
only one decision – the most crucial in the game – out of their hands, 
while leaving their authority intact.&lt;br /&gt;
They will be better for it, and so will the game.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;i&gt;Source: &lt;a href=&quot;http://bit.ly/193TX4Q&quot;&gt;The Guardian&lt;/a&gt;&lt;/i&gt;&lt;/u&gt;&lt;br /&gt;

    &lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/6952317048333277576/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/cricket.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/6952317048333277576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/6952317048333277576'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/cricket.html' title='Cricket'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-2054546536163447047</id><published>2013-08-05T04:51:00.001-07:00</published><updated>2013-08-05T04:51:53.137-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CAT 2013"/><title type='text'>CAT 2013</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span id=&quot;advenueINTEXT&quot; name=&quot;advenueINTEXT&quot; style=&quot;float: left;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;Normal&quot;&gt;
&lt;em&gt;Management aspirants can register for CAT 2013 from August 5, Monday&lt;/em&gt;&lt;br /&gt; &lt;br /&gt;
 Registrations for the Common Admission Test 2013 (CAT 2013) will begin 
from today and continue till September 26. Conducted by Indian 
Institutes of Management (IIMs) to admit students to their management 
programmes, CAT is one of the most sought-after management exams in the 
country.&lt;br /&gt; &lt;br /&gt; Besides the 13 IIMs, several other B-schools like 
Faculty of Management Studies, Delhi; Mudra Institute of Communications,
 Ahmedabad; SP Jain Institute of Management and Research, Mumbai, etc, 
also consider CAT scores to admit students. This year, CAT will be 
conducted from October 16 to November 11 across 40 cities. Last year, 
there were 36 locations.&lt;br /&gt; &lt;br /&gt; CAT aspirants can buy vouchers online directly from the CAT website. The vouchers are also available through  &lt;a href=&quot;http://economictimes.indiatimes.com/axis-bank-ltd/stocks/companyid-9175.cms&quot; target=&quot;_blank&quot;&gt;Axis Bank&lt;/a&gt; branches and this year 30 more branches have been added.&lt;br /&gt; &lt;br /&gt;
 &quot;IIMs give students an opportunity to pursue their career through a 
personally and professionally-enriching experience. During their IIM  &lt;a href=&quot;http://timesofindia.speakingtree.in/topics/journey/journey&quot; target=&quot;_blank&quot;&gt;journey&lt;/a&gt;,
 if they develop the right skill-sets and are able to put their best 
foot forward then there will be promising career choices. CAT is their 
first step to achieving their goals,&quot; says Rohit Kapoor, professor IIM 
Indore, convenor, CAT 2013.&lt;br /&gt; &lt;br /&gt; Similar to last year&#39;s exam 
pattern, CAT will have two sections. The first section will focus on 
quantitative ability and data interpretation, while the second will test
 the verbal ability and logical reasoning in a duration of 70 minutes 
for each section.&lt;br /&gt; &lt;br /&gt; Aspirants can register and schedule for CAT 2013 on the website, &lt;a href=&quot;http://www.cat2013.iimidr.ac.in/&quot;&gt;www.cat2013.iimidr.ac.in&lt;/a&gt; or &lt;a href=&quot;https://iim.prometric.com/&quot;&gt;https://iim.prometric.com&lt;/a&gt;.
 For support and assistance, candidates can call the toll-free candidate
 care number 1-800-419-0080, Monday to Saturday, 9am to 6pm, from August
 5.&lt;br /&gt; &lt;br /&gt; To read more stories on management education, visit &lt;a href=&quot;http://www.educationtimes.com/&quot;&gt;www.educationtimes.com &lt;/a&gt;  &lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/2054546536163447047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/cat-2013.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/2054546536163447047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/2054546536163447047'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/cat-2013.html' title='CAT 2013'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-2168006234877887982</id><published>2013-08-05T04:50:00.000-07:00</published><updated>2013-08-05T04:50:01.930-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Friendship"/><title type='text'>Friendship</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;hottrends-single-trend-news-snippet&quot;&gt;&lt;b&gt;Friendship&lt;/b&gt; in itself is an incredible gift to mankind and it is a reason to celebrate.&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/2168006234877887982/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/friendship.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/2168006234877887982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/2168006234877887982'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/friendship.html' title='Friendship'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-6018276553653470533</id><published>2013-08-01T12:05:00.001-07:00</published><updated>2013-08-01T12:05:06.775-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="deadline"/><category scheme="http://www.blogger.com/atom/ns#" term="Income tax"/><category scheme="http://www.blogger.com/atom/ns#" term="income tax returns"/><category scheme="http://www.blogger.com/atom/ns#" term="Incometax"/><title type='text'>Income tax return: What if you miss the deadline</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
A lot of people miss the deadline every year due to lack of time or 
plain laziness. Did you miss it too? In case you have, do not worry, you
 can still file a belated return. As a tax payer, you are likely to fall
 under one of these four categories. The associated rules and 
implications are outlined below.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;Case 1: No pending tax liability&lt;/strong&gt;&lt;br /&gt;
 Cases where all the taxes have been paid through TDS or advance tax and
 you don&#39;t owe any more to the tax department. This is the safest 
situation. The income tax return for any assessment year can be filed 
till the end of that assessment year without any penalty. If it is filed
 after the end of the assessment year, there is a lump sum penalty of &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt; 5,000.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;Case 2: Tax liability exists&lt;/strong&gt;&lt;br /&gt;
 This is the case where you still owe taxes to the government. It can 
happen due to many reasons. For example: if you have income from other 
sources, if you have worked in more than one company, etc. In such 
cases, the basic rule remains the same, i.e., the income tax return for 
any assessment year can be filed till the end of that assessment year 
without any penalty. You will be liable to pay a penalty of 1 per cent 
interest on the balance tax payable.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;Case 3: You have a tax refund&lt;/strong&gt;&lt;br /&gt;
 If you have any tax refund then you can file the return even after the 
deadline without any issue. The only disadvantage will be that your 
return may be processed late, which may delay the refund process.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;Case 4: You have to carry forward losses&lt;/strong&gt;&lt;br /&gt;
 Irrespective of the fact whether you have tax liability or not, if you 
do not file your income tax return by the deadline then you cannot carry
 forward the losses of that year to the next year. Thus, you would lose 
the benefit of setting off of these losses against the income of next 
year. However, there is an exception to this rule. This rule doesn&#39;t 
apply to loss from house property, which means this loss can be carried 
forward even if the income tax return is filed after the deadline.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;Important points:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;
  Returns filed after the due date cannot be revised&lt;/li&gt;
&lt;li&gt;
  Some of the deductions under section 80 are not available in case returns are being filed late.&lt;/li&gt;
&lt;/ul&gt;
&lt;em&gt;InvestmentYogi.com is a leading &lt;a href=&quot;http://www.investmentyogi.com/&quot; target=&quot;_blank&quot;&gt;personal finance&lt;/a&gt; portal.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;

 &lt;em&gt;Disclaimer: All information in this article has been provided by 
InvestmentYogi.com and NDTV Profit is not responsible for the accuracy 
and completeness of the same.&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;i&gt;Source:&lt;a href=&quot;http://bit.ly/19A6491&quot; target=&quot;_blank&quot;&gt;NDTVProfit.com&lt;/a&gt;&lt;/i&gt;&lt;/u&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/6018276553653470533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/income-tax-return-what-if-you-miss.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/6018276553653470533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/6018276553653470533'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/income-tax-return-what-if-you-miss.html' title='Income tax return: What if you miss the deadline'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-7048285860135790357</id><published>2013-08-01T12:01:00.004-07:00</published><updated>2013-08-01T12:28:59.026-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Jagdish Raj"/><title type='text'>Bollywood mourns death of Jagdish Raj</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;mod-timesofindiaarticletext mod-articletext&quot; id=&quot;mod-a-body-first-para&quot; style=&quot;margin-right: 280px; text-align: left;&quot;&gt;
&lt;div dir=&quot;rtl&quot; style=&quot;text-align: right;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://timesofindia.indiatimes.com/photo/21453444.cms&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Celebrities expressed grief over the demise of veteran actor Jagdish Raj, who had &lt;a href=&quot;http://timesofindia.indiatimes.com/topic/The-Record&quot;&gt;the record&lt;/a&gt; of playing a police officer 144 times in various &lt;a href=&quot;http://timesofindia.indiatimes.com/topic/Bollywood&quot;&gt;Bollywood&lt;/a&gt; films.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Jagdish,
 the famous police officer of Bollywood, passed away on Sunday at his 
Juhu residence following respiratory ailment. He was 85.&lt;br /&gt;
&lt;br /&gt;
&quot;He
 was not keeping well for the past two years. He had lung and 
respiratory problems. He passed away yesterday due to respiratory 
problems,&quot; the actor&quot;s son-in law Rakesh Malhotra told&lt;br /&gt;
&lt;/div&gt;
&lt;div class=&quot;float&quot; style=&quot;clear: both; height: 1px; line-height: 1px;&quot;&gt;
&lt;img alt=&quot;&quot; height=&quot;1&quot; src=&quot;http://articles.timesofindia.indiatimes.com/images/pixel.gif&quot; width=&quot;1&quot; /&gt;&lt;/div&gt;
&quot;Shri Jagdish Raj, the official &#39;Police Inspector&#39; of the Indian film 
industry, passed away. RIP,&quot; director Rahul Rawail wrote on 
micro-blogging site twitter.&lt;br /&gt;
&lt;br /&gt;
Filmmaker Ashok Pandit said, &quot;Sad to know Jagdish Raj is no more. The industry lost its great Police officer. RIP.&quot;&lt;br /&gt;
&lt;br /&gt;
&quot;RIP Jagdish Raj, the quintessential police officer for generations in 
Indian films. Your works will live on,&quot; actress Soumya Tandon said.&lt;br /&gt;
&lt;br /&gt;
&quot;Not seen any news channel cover the demise of Jagdish Raj. Sad,&quot; Tanuj
 Garg of Balaji Telefilms said. The last rites of the actor were 
performed yesterday evening at the Pawan Hans crematorium here.&lt;br /&gt;
&lt;br /&gt;
&quot;Only family and close &lt;a href=&quot;http://timesofindia.speakingtree.in/topics/life/friends&quot;&gt;friends&lt;/a&gt; had come for the last rites. From the industry, &lt;a href=&quot;http://timesofindia.indiatimes.com/topic/Rishi-Kapoor&quot;&gt;Rishi Kapoor&lt;/a&gt;, &lt;a href=&quot;http://timesofindia.indiatimes.com/topic/David-Dhawan&quot;&gt;David Dhawan&lt;/a&gt;, Rahul Rawail had come. The&lt;i&gt; chautha&lt;/i&gt; will be held tomorrow,&quot; Malhotra said.&lt;br /&gt;
&lt;br /&gt;
Born as Jagdish Raj Khurana in Sargodha, British India (now part of 
Pakistan), he acted in films from 1960 till retirement in 1992.&lt;br /&gt;
&lt;br /&gt;
Some of his popular movies include &lt;i&gt; Deewar, Don, Shakti, Mazdoor, Imaan Dharam, Gopichand Jasoos, Silsila, Aaina &lt;/i&gt;and &lt;i&gt;Besharam&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Though Jagdish occasionally played a villain and a couple of times 
essayed the role of a judge, he was best known for being cast a record 
144 times as a police officer.&lt;br /&gt;
&lt;br /&gt;
He is survived by two daughters and a son.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;i&gt;Source: &lt;a href=&quot;http://bit.ly/19A5Dvk&quot; target=&quot;_blank&quot;&gt;The Times of India &lt;/a&gt;&lt;/i&gt;&lt;/u&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/7048285860135790357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/bollywood-mourns-death-of-jagdish-raj.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/7048285860135790357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/7048285860135790357'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/bollywood-mourns-death-of-jagdish-raj.html' title='Bollywood mourns death of Jagdish Raj'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-3033610669067347796</id><published>2013-08-01T11:55:00.000-07:00</published><updated>2013-08-01T11:55:01.665-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Income Tax Return"/><title type='text'>How to facilitate the filing of income tax returns</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;em&gt;Aloke Gupta is unable to handle the paperwork when it is time to file his &lt;a href=&quot;http://economictimes.indiatimes.com/topic/income%20tax&quot;&gt;income tax&lt;/a&gt;
 returns. He ends up filing the return based on the Form 16 provided by 
his employer since salary is his primary source of income. It is easier 
to take care of the interest earned on deposits based on the TDS 
certificate, but the rest of his investments in shares and mutual funds 
are tough to manage for tax purposes. What should Gupta do?&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;em&gt;&lt;a href=&quot;http://economictimes.indiatimes.com/photo/21396015.cms&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;150&quot; src=&quot;http://economictimes.indiatimes.com/photo/21396015.cms&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/em&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
 If Gupta has too many transactions in equity and mutual funds, it may help to find a &lt;a href=&quot;http://economictimes.indiatimes.com/topic/chartered%20accountant&quot;&gt;chartered accountant&lt;/a&gt;
 to maintain his accounts and file the tax returns. Equity transactions 
may create shortterm capital gains, which are taxable. Similarly, there 
may be capital losses that can be set off against some gains. Mutual 
fund transactions may also have short- and long-term capital gains that 
are taxable. Gupta may not be complying with tax laws if he does not 
account for and pay taxes that may be due on these transactions.&lt;br /&gt;
 
Many service providers and brokers provide periodic statements, which 
show tax liability with respect to equity, debt, mutual fund and 
derivative transactions. Gupta should subscribe to these services and 
use the statements after due verification by his CA to ensure that he is
 paying the right amount as tax. He should remember that the tax on 
these investment gains is not subject to TDS. Therefore, Gupta may have 
to fill up the required tax challans and pay the taxes as applicable. It
 might help to consolidate his transactions in investments with one or 
two advisory services.&lt;br /&gt;
 Gupta also needs to ensure he does not 
have too many bank accounts that are used for making these investments. 
The non-payment of taxes may lead to fines and penalties if his returns 
come up for scrutiny. The cost of maintaining his accounts and books 
might turn out to be lower in comparison.&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;&lt;strong&gt;The content on this page is courtesy &lt;a href=&quot;http://economictimes.indiatimes.com/topic/Centre%20for%20Investment%20Education%20and%20Learning&quot;&gt;Centre for Investment Education and Learning&lt;/a&gt; (CIEL). Contributions by &lt;a href=&quot;http://economictimes.indiatimes.com/topic/Girija%20Gadre&quot;&gt;Girija Gadre&lt;/a&gt; and Arti Bhargava&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;&lt;strong&gt;Source:&lt;a href=&quot;http://bit.ly/19A4rIv&quot; target=&quot;_blank&quot;&gt;The Economic Times&amp;nbsp;&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt;&lt;a href=&quot;http://bit.ly/19A4rIv&quot; target=&quot;_blank&quot;&gt; &lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/3033610669067347796/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/how-to-facilitate-filing-of-income-tax.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/3033610669067347796'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/3033610669067347796'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/how-to-facilitate-filing-of-income-tax.html' title='How to facilitate the filing of income tax returns'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-5032888983484998303</id><published>2013-08-01T11:50:00.003-07:00</published><updated>2013-08-01T11:50:58.539-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Income tax"/><title type='text'>Income tax returns: 9 tax saving options other than Section 80C</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Before you calculate your tax liabilities, remember to analyze the 
various sections of tax deductions under the Income Tax Act as tax 
planning does not end with Section 80C. (&lt;a href=&quot;http://profit.ndtv.com/budget/tax-calculator&quot; target=&quot;_blank&quot;&gt;Calculate your tax liability here&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;80D:&lt;/strong&gt;&lt;br /&gt;
 Tax deduction under section 80D qualifies for mediclaim policies. The 
premium, which is paid for medical insurance policy for self and family 
members to protect them from sudden medical expenses, comes under this 
section. The maximum amount allowed for exemption annually for self, 
spouse and dependent parents/children is &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt; 15,000. In case of a senior citizen, the maximum amount extends up to &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt;
 20,000. If you are paying the premium for your parents (whether 
dependent or not), you can claim an additional maximum deduction of &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt; 15,000.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;80DD:&lt;/strong&gt;&lt;br /&gt;
 According to the Income Tax Act, if you are paying a premium to LIC or 
any other insurance company (approved by the Income Tax board) for the 
medical treatment of a dependent physically disabled person, you can 
avail exemption under the section 80DD. Here, the dependent should be 
none other than your spouse, children, parents or sibling. If the person
 is suffering from 40 per cent of any disability, a fixed sum of &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt; 50,000 can be claimed in a year. Similarly, if the disability is 80 per cent, the fixed sum goes up to &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt;
 1,00,000 per year. For initiating the process of deduction you need to 
submit the medical certificate issued by a medical authority along with 
the return of income.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;80DDB:&lt;/strong&gt;&lt;br /&gt;
 If you have incurred expenses for the medical treatment of self or your dependents, you can claim a deduction of up to &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt;
 40,000 or the actual amount paid, whichever is less, under the section 
80DDB. For a senior citizen, the maximum exempted amount is &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt;
 60,000, or the amount actually paid for medical expenses. To claim a 
deduction under this section, you need to submit a medical certificate 
from a doctor working in a government hospital.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;80E:&lt;/strong&gt;&lt;br /&gt;
 The interest paid on loan taken for pursuing higher education of self 
or any dependent is exempted from tax under section 80E. An education 
loan can be taken for wife, children and minors for whom you are the 
legal guardian. This deduction is applicable for a period of eight years
 or till the interest is paid, whichever is earlier. The deduction is 
only approved for higher studies, which means full-time graduate or 
postgraduate courses in engineering, management or applied sciences, 
pure sciences including mathematics or statistics. However, from 2011 
onwards, the scope of this exemption has been extended to cover all 
fields of studies including vocational studies pursued after completing 
the senior secondary examination or equivalent. No exemption is 
applicable for part-time courses.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;80G:&lt;/strong&gt;&lt;br /&gt;
 One often donates on philanthropic grounds to help the destitute. Such 
an amount can be donated to trusts, charitable institutions and approved
 educational institutions, and qualifies for deduction under Section 
80G. The exemptions can be up to 50 per cent or 100 per cent of the 
donations made. Funds in which the donations are eligible for tax 
exemptions include the National Defence Fund, Prime Minister Drought 
Relief Fund, National Foundation for Communal Harmony, National 
Children&#39;s Fund, Prime Minister&#39;s National Relief Fund, etc.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;80GG:&lt;/strong&gt;&lt;br /&gt;
 If a salaried or self-employed person staying in a rented house does 
not receive any kind of HRA, they can claim a deduction under this 
section. However, you cannot avail any such benefit if you, your spouse 
and/or your child owns any residential accommodation in India or abroad.
 You can claim the least of the following under Section 80GG: 25 per 
cent of the total income, or &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt; 2000 per month, or excess of rent paid over 10 per cent of total income.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;80GGC:&lt;/strong&gt;&lt;br /&gt;
 Any monetary contribution to any political party or electoral trust is 
eligible for tax exemption. Thus, your contribution, as a matter of 
appreciation for their work, will serve both the purposes.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;80U:&lt;/strong&gt;&lt;br /&gt;
 A resident of India suffering from any kind of specified disability is 
eligible to claim tax deduction under this section. In order to enjoy 
this opportunity, one should be suffering from not less than 40 per cent
 of the following diseases: blindness, low vision, mental illness, 
mental retardation, hearing impairment. The deduction provided is flat &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt; 50,000, irrespective of the expense incurred. If the disability is severe, the deduction can be up to &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt; 1 lakh. One needs to provide a copy of all the certificates issued by a medical authority in order to avail this benefit.&lt;br /&gt;&lt;br /&gt;

 &lt;strong&gt;80CCG:&lt;/strong&gt;&lt;br /&gt;
 The Finance Act 2012 introduced a new Section 80CCG to offer 50 per cent tax break to new investors who invest up to &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt; 50,000 and whose GTI is less than or equal to &lt;span class=&quot;rupee&quot;&gt;R&lt;span&gt;s.&lt;/span&gt;&lt;/span&gt;
 10 lakh. It has been introduced for budding investors entering the 
equity markets for the first time and is a once-in-a-lifetime benefit.&lt;br /&gt;&lt;br /&gt;

 Hence, there are several sections apart from 80C that can help an 
individual benefit from tax exemptions. It is time to start looking 
beyond 80C for tax savings.&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;Disclaimer: &lt;/em&gt;&lt;em&gt;All information in this article has been 
provided by BankBazaar.com and NDTV Profit is not responsible for the 
accuracy and completeness of the same.&lt;/em&gt; &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/5032888983484998303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/income-tax-returns-9-tax-saving-options.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/5032888983484998303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/5032888983484998303'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/income-tax-returns-9-tax-saving-options.html' title='Income tax returns: 9 tax saving options other than Section 80C'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-1069819046128581630</id><published>2013-08-01T11:49:00.001-07:00</published><updated>2013-08-01T11:49:15.232-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Telangana"/><title type='text'>Telangana: Near total bandh in coastal, southern AP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span id=&quot;advenueINTEXT&quot; name=&quot;advenueINTEXT&quot;&gt;New Delhi: India is all 
set to get its 29th state – Telangana, which was endorsed by UPA allies 
and cleared by the powerful Congress Working Committee on Tuesday 
evening.
&lt;br /&gt;&lt;br /&gt;
While the decision has been welcomed by pro-Telangana supporters, those opposed to the move have termed it suicidal.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span id=&quot;advenueINTEXT&quot; name=&quot;advenueINTEXT&quot;&gt;New Delhi: India is all 
set to get its 29th state – Telangana, which was endorsed by UPA allies 
and cleared by the powerful Congress Working Committee on Tuesday 
evening.
&lt;br /&gt;&lt;br /&gt;
While the decision has been welcomed by pro-Telangana supporters, those opposed to the move have termed it suicidal.
&lt;br /&gt;&lt;br /&gt;
Here are the updates:
&lt;br /&gt;&lt;br /&gt;







&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;right&quot; style=&quot;height: 260px;&quot;&gt;
    &lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;
    


    &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span id=&quot;advenueINTEXT&quot; name=&quot;advenueINTEXT&quot;&gt;
&lt;li&gt; Shutdown has been effective in coastal and southern Andhra Pradesh; near total bandh observed.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; West Bengal Chief Minister Mamata Banerjee condemns UPA 
government for endorsing statehood to Telangana, calls the decision 
&quot;divisive politics&quot;. Mamata has also written to Prime Minister Manmohan 
Singh asking for the reasons behind the decision.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; TDP chief N Chandrababu Naidu calls on the Centre to develop a
 city at par with Hyderabad as the capital of Andhra Pradesh following 
the formation of Telangana.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; The decision to create Telangana &quot;seems to have been impelled 
by the forthcoming Lok Sabha elections. It will give a fillip to demands
 for separate states in other places&quot;, says CPI(M).
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Digvijay Singh says there is nothing wrong in having Hyderabad
 as joint capital for the two states of Telangana and Andhra Pradesh.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Six state ministers who are opposed to the creation of 
Telangana state have submitted resignations to the Andhra CM, say 
reports.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Reports said Andhra CM Kiran Kumar Reddy, who is from the 
Rayalaseema region and is a staunch supporter of the &quot;united Andhra 
Pradesh&quot; cause, told his ministers today that the decision on Telangana 
was &quot;painful&quot; for him as well. He however added that there was now a 
need to look at the road ahead and how to move ahead on the new states.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; P Ramesh Babu, Congress MLA from Pendurthy Assembly 
constituency, resigns to protest the Congress decision to form a 
separate Telangana state.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Decision is in favour of Telangana because ultimately 
Hyderabad will be Telangana&#39;s capital, says Digvijay Singh. Decision is 
also in favour of Rayalaseema and Andhra so that both can progress and 
be self-reliant, he adds.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Until a new capital is formed for Andhra Pradesh, Hyderabad will be capital of both states, says Congress&#39; Digvijay Singh.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; BJP and Narendra Modi should welcome the decision (on 
Telangana) and not question the delay, intentions behind the decision 
etc, says Jagdambika Pal of the Congress.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Effigies of Congress president Sonia Gandhi burnt during anti-Telangana protests. 
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; The shutdown has hit normal life in Visakhapatnam, 
Vijayanagaram, Eluru, Kakinada, Vijayawada, Guntur, Nellore, Ongole, 
Chittoor, Tirupati, Anantapur, Kadapa, Kurnool and other towns.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Hundreds of vehicles are on the Vijayawada-Hyderabad and the Chennai-Bhubaneswar highways.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Road transport has come to a standstill while shops, business 
establishments and educational institutions have remained closed in the 
two regions. 
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Protests have begun in coastal Andhra and Rayalaseema regions. &lt;/li&gt;
&lt;li&gt;&lt;span id=&quot;advenueINTEXT&quot; name=&quot;advenueINTEXT&quot;&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt; Hundreds of police and paramilitary personnel have been deployed in the two regions to maintain law and order.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Union Cabinet is set to meet on Wednesday to discuss Telangana
 - a separate state to be carved out of Andhra Pradesh. While the agenda
 of the special Cabinet meeting has not been disclosed, sources say it 
is most likely to take up and approve the creation of Telangana.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; A day-long bandh has been called across coastal and southern Andhra Pradesh to protest the proposed creation of Telangana.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; A &#39;hurt&#39; Rayapati Sambasiva Rao, senior Congress leader and 
Lok Sabha member from Guntur, said he was resigning from the party as 
well as his Parliamentary seat in protest.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Congress ministers and MPs from Andhra Pradesh are expected to meet state Chief Minister Kiran Kumar Reddy today.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Congress general secretary Digvijay Singh told a press 
conference last evening that the creation of Telangana will take around 
four to five months. &quot;The entire process should take around four to five
 months,&quot; he said.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; After the Cabinet approves Telangana, the CWC resolution will 
be sent to the Andhra Pradesh Assembly, which will have to approve it.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; Next, the Central government would set up a group of ministers
 (GoM) which will go into the details of sharing the assets like water 
resources, boundary, finances and security related issues between 
Telangana and the rest of Andhra Pradesh.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; The Law Ministry will then draft a bill for creation of Telangana state which will be sent to the Union Home Ministry.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; The suggestions of the state Assembly will not be binding on the Home Ministry.
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; The bill, once approved by the Union Cabinet, will then be sent to President Pranab Mukherjee for his approval. 
&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; It will then be sent to Parliament to be passed by a simple 
majority in both the Houses. Once approved by Parliament, the bill will 
again be sent to the President for his assent.&amp;nbsp;
&lt;/li&gt;
&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/1069819046128581630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/telangana-near-total-bandh-in-coastal.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1069819046128581630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1069819046128581630'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/telangana-near-total-bandh-in-coastal.html' title='Telangana: Near total bandh in coastal, southern AP'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-5295090242891951361</id><published>2013-08-01T11:45:00.002-07:00</published><updated>2013-08-01T11:45:33.300-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Telangana"/><title type='text'>Indian IT cheers Telangana state formation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span id=&quot;advenueINTEXT&quot; name=&quot;advenueINTEXT&quot; style=&quot;float: left;&quot;&gt;HYDERABAD: After over three years of uncertainty, the Information Technology industry here heaved a sigh of relief with the  &lt;a href=&quot;http://timesofindia.indiatimes.com/topic/Congress&quot;&gt;Congress&lt;/a&gt; party&#39;s announcement to carve out a separate  &lt;a href=&quot;http://timesofindia.indiatimes.com/topic/Telangana&quot;&gt;Telangana&lt;/a&gt; state. &lt;br /&gt;&lt;br /&gt; The announcement has cleared the air over the future of Hyderabad, a major IT destination in the country. &lt;br /&gt;&lt;br /&gt; This fast growing metropolis will be the joint capital of Telangana and  &lt;a href=&quot;http://timesofindia.indiatimes.com/topic/Andhra-Pradesh&quot;&gt;Andhra Pradesh&lt;/a&gt; for 10 years. Andhra Pradesh is expected to build its own capital within that period. &lt;br /&gt;&lt;br /&gt;
 The IT industry welcomed the decision, saying it brought an end to 
uncertainty and brightened the prospects of the city attracting new 
investments. &lt;br /&gt;&lt;br /&gt; The industry with software exports to the tune of 
Rs 40,000 crore was worried over frequent shutdowns and spells of 
violent protests for separate Telangana state. This had taken sheen off 
brand Hyderabad. &lt;br /&gt;&lt;br /&gt; &quot;I believe the decision has brought in a 
positive sentiment as the uncertainty surrounding the matter has finally
 been resolved,&quot; said V. Laxmikanth, managing director, Broadridge 
India. &lt;br /&gt;&lt;br /&gt; &quot;Hyderabad, known for its large pool of talented IT 
professionals and as a base for leading MNCs, is expected to reclaim its
 reputation of being the destination of choice for businesses across 
industries,&quot; he said. &lt;br /&gt;&lt;br /&gt; BVR Mohan Reddy, chairman and managing 
director, Infotech Enterprises, said while he was not for or against the
 decision, he was anxiously looking forward for this decisive movement. &lt;br /&gt;&lt;br /&gt;
 &quot;The separation problem has been voiced for the last 50 years but in 
the last three years some of these agitations have been (hurdles) for 
progress of the state. The uncertainty has slowed down the growth. That 
is now past.&quot; &lt;br /&gt;&lt;br /&gt; Suman Reddy, vice president and managing 
director, Pegasystems India, hoped the development will bring back 
stability in the business environment of the city. &lt;br /&gt;&lt;br /&gt; &quot;Growth and 
expansion from the perspective of IT MNCs investing in the state had 
been stalled/relatively slow due to this issue, which hopefully will 
resume after the decision is announced,&quot; he said. &lt;br /&gt;&lt;br /&gt; Hyderabad, 
which emerged on the world IT map only in mid-1990s, is home to over 
1,000 IT and ITeS companies including global majors like Microsoft, 
Google, Facebook,  &lt;a href=&quot;http://timesofindia.indiatimes.com/topic/Dell&quot;&gt;Dell&lt;/a&gt;, Oracle and Amazon. &lt;br /&gt;&lt;br /&gt; The IT and ITes sector provides nearly five lakh jobs. &lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/5295090242891951361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/indian-it-cheers-telangana-state.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/5295090242891951361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/5295090242891951361'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/indian-it-cheers-telangana-state.html' title='Indian IT cheers Telangana state formation'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-5038937245348183252</id><published>2013-08-01T11:43:00.001-07:00</published><updated>2013-08-01T11:44:05.548-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NSEL"/><title type='text'>NSEL crisis to negatively impact equity mkts</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;i&gt;NSEL crisis which came into light Thursday morning is seen adding to
 pain in equity markets, which are going through a bear phase, Dipan 
Mehta, Member of BSE and NSE said.&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;a href=&quot;http://bit.ly/19A378k&quot;&gt;http://bit.ly/19A378k&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/5038937245348183252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/nsel-crisis-to-negatively-impact-equity.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/5038937245348183252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/5038937245348183252'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/nsel-crisis-to-negatively-impact-equity.html' title='NSEL crisis to negatively impact equity mkts'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-5191370404115854100</id><published>2013-08-01T11:39:00.000-07:00</published><updated>2013-08-01T11:39:11.464-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cricket"/><title type='text'>Clarke Leads Australia to 303-3 Against England in Ashes Cricket</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Captain &lt;a href=&quot;http://topics.bloomberg.com/michael-clarke/&quot;&gt;Michael Clarke&lt;/a&gt;’s unbeaten
century led Australia to 303-3 on the opening day of the third
Ashes cricket Test against England. &lt;br /&gt;

Clarke reached 125, Australia’s first century of the
series, at stumps at Old Trafford in Manchester and &lt;a href=&quot;http://topics.bloomberg.com/steven-smith/&quot;&gt;Steven Smith&lt;/a&gt;
was 70 not out. The two will resume a 174-run partnership
tomorrow. &lt;br /&gt;

“It’s always tough when the wicket plays like that,”
England seam bowler &lt;a href=&quot;http://topics.bloomberg.com/tim-bresnan/&quot;&gt;Tim Bresnan&lt;/a&gt;, who took 1-51, told Sky Sports.
“Ultimately, the Aussies played really well today.” &lt;br /&gt;

&lt;a href=&quot;http://topics.bloomberg.com/chris-rogers/&quot;&gt;Chris Rogers&lt;/a&gt; added 84 runs as Australia looks to rebound
from two losses to open the five-game series. England would win
the Ashes for the third straight time with a victory. &lt;br /&gt;

Australia made three changes to its team as David Warner
returned from suspension in place of Phil Hughes, off-spinner
Nathan Lyon replaced Ashton Agar and left-arm seamer Mitchell
Starc came in for injured James Pattinson. &lt;br /&gt;

Meanwhile, England captain &lt;a href=&quot;http://topics.bloomberg.com/alastair-cook/&quot;&gt;Alastair Cook&lt;/a&gt; named an unchanged
team after Kevin Pietersen was declared fit following his calf
strain in the second Test. &lt;br /&gt;

Clarke elected to bat after winning the toss and his team
reached 76 before Shane Watson was caught for 19 by Cook at
first slip from Bresnan. &lt;br /&gt;

A controversial decision then left the visitors on 82-2
after umpire Tony Hill ruled Usman Khawaja was caught behind by
Matt Prior off Graeme Swann. Australia called for video review,
which appeared to show the ball missing the bat, but TV umpire
Kumar Dharmasena upheld the original call. &lt;br /&gt;

Swann trapped Rogers leg-before-wicket after lunch for his
second wicket. The Australian opener chatted with Clarke about a
review before leaving the field. &lt;br /&gt;

Clarke, who has 17 fours, and Smith then took control to
see out the day’s play. Smith escaped an lbw dismissal because
England had used up its two reviews, as Hawk-Eye showed the ball
from Stuart Broad would have hit the middle stump.&lt;br /&gt;
&lt;br /&gt;
To contact the reporter on this story:
Bob Bensch in London at 
&lt;a href=&quot;mailto:bbensch@bloomberg.net&quot; title=&quot;Send E-mail&quot;&gt;bbensch@bloomberg.net&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;

To contact the editor responsible for this story:
&lt;a href=&quot;http://topics.bloomberg.com/christopher-elser/&quot;&gt;Christopher Elser&lt;/a&gt; at  &lt;a href=&quot;mailto:celser@bloomberg.net&quot; title=&quot;Send E-mail&quot;&gt;celser@bloomberg.net&lt;/a&gt;. &lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/5191370404115854100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/clarke-leads-australia-to-303-3-against.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/5191370404115854100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/5191370404115854100'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2013/08/clarke-leads-australia-to-303-3-against.html' title='Clarke Leads Australia to 303-3 Against England in Ashes Cricket'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-2164836166392053478</id><published>2012-10-01T02:08:00.000-07:00</published><updated>2013-02-12T03:19:42.054-08:00</updated><title type='text'>Web Expert</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dzCpj_EoJSvpCn0wxoYCjy8fiJDiGxwsEdeWOxSi13QTwIjXa2qti5iGyqGMVYV5in_xVf9iZWkQHN48Z20Dg&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;iframe src=&quot;http://www.appsgeyser.com/social_widget/social_widget.php?width=300&amp;height=160&amp;apkName=Web Expert&amp;simpleVersion=no&quot; width=&quot;310&quot; height=&quot;180&quot; vspace=&quot;0&quot; hspace=&quot;0&quot; frameborder=&quot;no&quot; scrolling=&quot;no&quot; seamless=&quot;&quot; allowtransparency=&quot;true&quot;&gt; &lt;/iframe&gt;
&lt;iframe src=&quot;http://www.iceni.com&quot;/width=300&amp;height=160&amp;apkName=Web Expert&amp;simpleVersion=no&quot; width=&quot;310&quot; height=&quot;180&quot; vspace=&quot;0&quot; hspace=&quot;0&quot; frameborder=&quot;no&quot; scrolling=&quot;no&quot; seamless=&quot;&quot; allowtransparency=&quot;true&quot;&gt; &lt;/iframe&gt;
&lt;a href=&quot;http://www.iceni.com&quot;&gt;PDF Editor&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/2164836166392053478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2012/10/web-expert.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/2164836166392053478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/2164836166392053478'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2012/10/web-expert.html' title='Web Expert'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-1716154673980015775</id><published>2012-09-26T07:07:00.000-07:00</published><updated>2012-10-12T06:09:23.919-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Developer platform"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Tizen- An open source, standards-based software platform</title><content type='html'>&lt;a href=&quot;http://www.linkreferral.com/adwel.pl?oldrefid=377391&quot;&gt;&lt;img src=&quot;http://www.linkreferral.com/images/linkreferal/linkbutton.gif&quot; border=&quot;0&quot; alt=&quot;free web site traffic and promotion&quot; width=&quot;114&quot; height=&quot;32&quot;&gt;&lt;/a&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div itemprop=&quot;rating&quot; itemscope itemtype=&quot;http://www.vikaswebgyan.blogspot.com/Rating&quot;&gt;
   Rating: &lt;span itemprop=&quot;value&quot;&gt;8.5&lt;/span&gt;
   &lt;meta itemprop=&quot;best&quot; content=&quot;10&quot; /&gt;
&lt;/div&gt;
&lt;a href=&quot;http://www.amfibi.com/&quot; target=&quot;_top&quot;&gt;&lt;img src=&quot;http://banners.amfibi.com/small/red.gif&quot; border=&quot;0&quot; alt=&quot;Amfibi Web Search &amp; Directory&quot;&gt;&lt;/a&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpM6Tshldqo4WFpMCgxbGkRRUW76_pFWk5bRAMJRF7Mub-n8dtiP5c9X__UVo-WO3-P1Fnri0n58HdfVRNznoDm3U96wgtn9EtuKl5A3KPetgV3Ei0WWhW1BClx0AvvblBVbUlXMh3Sxk/s1600/tizen-logo-white-mascot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;100&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpM6Tshldqo4WFpMCgxbGkRRUW76_pFWk5bRAMJRF7Mub-n8dtiP5c9X__UVo-WO3-P1Fnri0n58HdfVRNznoDm3U96wgtn9EtuKl5A3KPetgV3Ei0WWhW1BClx0AvvblBVbUlXMh3Sxk/s320/tizen-logo-white-mascot.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;section&gt;
&lt;h1 align=&quot;left&quot;&gt;&lt;b&gt;Tizen&lt;/b&gt;&lt;/h1&gt;
&lt;blockquote&gt;The open-source Smartphone Operating System&lt;/blockquote&gt;&lt;br/&gt;
Tizen is an open source, standards-based software platform supported by leading mobile operators, device manufacturers, and silicon suppliers for multiple device categories, including smartphones, tablets, netbooks, in-vehicle infotainment devices, smart TVs, and more. Tizen offers an innovative operating system, applications, and a user experience that consumers can take from device to device.&lt;br/&gt;
The Tizen project resides within the &lt;a href=&quot;http://www.linuxfoundation.org/collaborate/labs/tizen&quot;&gt;Linux Foundation&lt;/a&gt; and is governed by a Technical Steering Group. The Technical Steering Group is the primary decision-making body for the open source project, with a focus on platform development and delivery, along with the formation of working groups to support device verticals. &lt;br/&gt;
The &lt;a href=&quot;http://www.tizenassociation.org/&quot;&gt;Tizen Association&lt;/a&gt; has been formed to guide the industry role of Tizen, including gathering of requirements, identification and facilitation of service models, and overall industry marketing and education. &lt;br/&gt;
Tizen provides a robust and flexible environment for application developers, based on HTML5. With HTML5&#39;s robust capabilities and cross platform flexibility, it is rapidly becoming the preferred development environment for mobile apps and services. The Tizen SDK and API allow developers to use HTML5 and related web technologies to write applications that run across multiple device segments. &lt;br/&gt;
The Tizen application programming interfaces are based on HTML5 and other web standards. 
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr/&gt;Community&lt;/b&gt;&lt;/h4&gt;
The Tizen community is made up of all of the people who collectively work on or with Tizen:&lt;br/&gt;
&lt;ul&gt;
&lt;li&gt;Product contributors: kernel/distribution developers, release managers, quality assurance, localization, etc. &lt;/li&gt;
&lt;li&gt;Application developers: people who write applications to run on top of Tizen&lt;/li&gt;
&lt;li&gt;Users: people who run Tizen on their device and provide feedback&lt;/li&gt;
&lt;li&gt;Vendors: companies who create products based on Tizen&lt;/li&gt;
&lt;li&gt;Other contributors: promotion, documentation, and much more&lt;/li&gt;&lt;/ul&gt;
&lt;h4 align=&quot;left&quot;&gt;&lt;b&gt;&lt;hr/&gt;Anyone can contribute by: &lt;/b&gt;&lt;/h4&gt;&lt;br/&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://source.tizen.org/&quot;&gt;Submitting patches&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.tizen.org/community/bug-tracker&quot;&gt;Filing bugs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Documenting Feature requests&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.tizen.org/&quot;&gt;Developing applications&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Helping with wiki documentation&lt;/li&gt;
&lt;li&gt;Participating in other community efforts and programs&lt;/li&gt;&lt;/ul&gt;&lt;br/&gt;
Membership in most project teams (Release Engineering, QA, Program Management, etc.) is invite-only and will mainly be open to people at companies who are building products based on Tizen. However, Community Office, Localization, and some Middleware development teams will be open to participation on a merit basis.
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr/&gt;The Tizen SDK&lt;/b&gt;&lt;/h4&gt;
The Tizen SDK provides you with the essential tools and images to begin development.&lt;br/&gt;
&lt;a href=&quot;https://developer.tizen.org/sdk/&quot;&gt;Download the Tizen SDK&lt;/a&gt;
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr/&gt;&lt;a href=&quot;https://developer.tizen.org/documentation/&quot;&gt;Getting Started&lt;/a&gt;&lt;/h4&gt;
Learn the application development process with step-by-step instructions including SDK basics.&lt;br/&gt;
Developing your first Tizen application

&lt;h4 align=&quot;left&quot;&gt;Tizen Source&lt;/b&gt;&lt;/h4&gt;
Find all Tizen components and explore the Tizen source code.&lt;br/&gt;
&lt;a href=&quot;https://source.tizen.org/&quot;&gt;Source Code&lt;/a&gt;

&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr/&gt;Join the Tizen Community&lt;/b&gt;&lt;/h4&gt;
The Tizen community is made up of all the people who collectively work on or with Tizen. Come and get involved.&lt;br/&gt;
&lt;a href=&quot;https://www.tizen.org/community/&quot;&gt;More about the Tizen Community&lt;/a&gt;

&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr/&gt;Source Code Available for Tizen 2.0 Alpha&lt;/b&gt;&lt;/h4&gt;
The source code for the Tizen 2.0 Alpha has been released. This release is targeted towards smartphones and runs on the PC emulator and an ARM-based reference device. This release allows OEMs to begin considering Tizen 2.0 for their commercial devices, and open source developers to look into Tizen to find what they can improve and contribute.&lt;br/&gt;
Tizen provides a standards-based software platform for multiple device categories, which supports Web applications. The API reference provides a comprehensive description for application development.&lt;br/&gt;
For information on how to obtain the source code and start platform development, visit our &lt;br/&gt;&lt;a href=&quot;https://source.tizen.org/documentation/developer-guide/&quot;&gt;Developer Guide.&lt;/a&gt;
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr/&gt;Devices&lt;/b&gt;&lt;/h4&gt;
Tizen is an open source, standards-based software platform for multiple device categories, including smartphones, tablets, netbooks, in-vehicle infotainment devices, smart TVs, and more. Tizen offers an innovative operating system, applications, and a user experience that consumers can take from device to device.
&lt;h5 align=&quot;left&quot;&gt;&lt;b&gt;Smartphones&lt;/b&gt;&lt;/h5&gt;
Tizen smartphone technologies include a flexible and powerful user interface, 3D window effects, advanced multimedia, location based service frameworks, sensor frameworks, and multi-tasking and multi-touch capabilities. In addition, support for scalable screen resolution means that the platform can deliver a consistent user experience across a broad range of handset types and form factors.
&lt;h5 align=&quot;left&quot;&gt;&lt;b&gt;Tablets&lt;/b&gt;&lt;/h5&gt;
Tizen offers a touch-optimized user interface for tablets with a suite of built-in applications for Web browsing, personal information management, and media consumption.
&lt;h5 align=&quot;left&quot;&gt;&lt;b&gt;Netbooks&lt;/b&gt;&lt;/h5&gt;
Tizen will provide expanded features, improved performance, and a richer user experience for netbooks. Tizen is a light-weight, scalable, fast-booting, brand-able operating system, with advanced support for touch and connectivity.
&lt;h5 align=&quot;left&quot;&gt;&lt;b&gt;In-Vehicle Infotainment&lt;/b&gt;&lt;/h5&gt;
In-Vehicle infotainment systems are devices that deliver navigation, entertainment, and networked computing services in vehicles, such as cars, trucks, planes, and buses. The Tizen In-Vehicle infotainment software platform is designed to enable rich internet and multimedia consumer experiences for vehicles.
&lt;h5 align=&quot;left&quot;&gt;&lt;b&gt;Smart TV&lt;/b&gt;&lt;/h5&gt;
Tizen for Smart TV delivers a complete, open standards-based Linux stack, optimized for living room devices, such as Blu-ray players, set top boxes, and digital TVs. It is designed for an Internet-connected TV experience, allowing users to enjoy access to multiple applications, services, and personal media, all while watching TV.
&lt;h4 align=&quot;left&quot;&gt;&lt;b&gt;&lt;hr/&gt;Tizen Developer Conference&lt;/b&gt;&lt;/h4&gt;&lt;br/&gt;
The first annual Tizen Conference engages and educates developers on Tizen technology and HTML5 app development for Tizen devices. This conference is for Tizen developers, app developers, platform designers, operators, OEMs, hardware vendors, software vendors, open source enthusiasts, and anyone engaged in Tizen. The Tizen conference will be hosted at the downtown Hyatt in San Francisco, CA on May 7-9th, 2012. You can view the full schedule online. Conference highlights Monday, May 7th, we will open registration at 12:00. There will be a welcoming reception from 15:00-18:00, with demos from our sponsor companies, and afterwards, dinner will be provided. There will be a 24-hour hacker lounge open during the conference, with many games (including werewolf), networking, quiet space, food, and drinks. Tuesday, May 8th, after a full day of sessions, we will host an offsite party for all conference attendees at &lt;a href=&quot;https://www.calacademy.org/&quot;&gt;The California Academy of Sciences.&lt;/a&gt;. This night will be filled with amazing exhibitions, great local foods, and bands. Interested in Tizen application development? Enter the &lt;a href=&quot;https://www.tizen.org/blogs/jabancroft/2012/announcing-tizen-developer-contest-intel&quot;&gt;Tizen Developer Contest&lt;/a&gt; before August 7th.
&lt;hr/&gt;
&lt;h1&gt;For more information, visit Tizen Website &lt;a href=&quot; https://www.tizen.org/&quot;&gt;Tizen&lt;/a&gt;.&lt;/h1&gt;&lt;br /&gt;
Here you can see the Website.
&lt;iframe height=&quot;525&quot; src=&quot; https://www.tizen.org/&quot; width=&quot;525&quot;&gt;
&lt;/iframe&gt;
&lt;br /&gt;
It should show everything you want to know about Tizen.&lt;br /&gt;
&lt;/section&gt;
&lt;div class=&quot;g-plusone&quot; data-size=&quot;tall&quot; ... &gt;&lt;/div&gt;
&lt;center&gt;&lt;a href=&quot;http://www.ineedhits.com/free-tools/submitfree.aspx?source=FTSFbutton&quot;&gt;&lt;img src=&quot;http://www.ineedhits.com/images/trackingbuttons/SFbutton.gif?ref=1591250&quot; border=&quot;0&quot; height=&quot;32&quot; width=&quot;90&quot; alt=&quot;Submit your website to 20 Search Engines - FREE with ineedhits!&quot;&gt;&lt;/a&gt;&lt;/center&gt;
&lt;iframe src=&quot;http://www.appsgeyser.com/social_widget/social_widget.php?width=300&amp;height=160&amp;apkName=Web Expert&amp;simpleVersion=no&quot; width=&quot;310&quot; height=&quot;180&quot; vspace=&quot;0&quot; hspace=&quot;0&quot; frameborder=&quot;no&quot; scrolling=&quot;no&quot; seamless=&quot;&quot; allowtransparency=&quot;true&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/1716154673980015775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2012/09/tizen-open-source-standards-based.html#comment-form' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1716154673980015775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1716154673980015775'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2012/09/tizen-open-source-standards-based.html' title='Tizen- An open source, standards-based software platform'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpM6Tshldqo4WFpMCgxbGkRRUW76_pFWk5bRAMJRF7Mub-n8dtiP5c9X__UVo-WO3-P1Fnri0n58HdfVRNznoDm3U96wgtn9EtuKl5A3KPetgV3Ei0WWhW1BClx0AvvblBVbUlXMh3Sxk/s72-c/tizen-logo-white-mascot.png" height="72" width="72"/><thr:total>14</thr:total><georss:featurename>Bangalore, Karnataka, India</georss:featurename><georss:point>12.9715987 77.5945627</georss:point><georss:box>12.724026199999999 77.2787057 13.2191712 77.910419699999991</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2668244871531886674.post-1493935975835534241</id><published>2012-09-04T06:34:00.000-07:00</published><updated>2012-10-18T07:38:59.603-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>The Go Programming Language</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a alt=&quot;Go image&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpFXT-u9dYCwxr3OJa12HhVK3mmHrxJYjEfzevttunpRnbhC2C_iWlDgW6NitaZBpoJcHh2VVw9MKVb2hKhXhZLqh3T-F-hci2EH6IeDx5Gzw4rMCZ6aznE_pmH_rJokJ2XjmJei_W86Q/s1600/bumper480x270.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpFXT-u9dYCwxr3OJa12HhVK3mmHrxJYjEfzevttunpRnbhC2C_iWlDgW6NitaZBpoJcHh2VVw9MKVb2hKhXhZLqh3T-F-hci2EH6IeDx5Gzw4rMCZ6aznE_pmH_rJokJ2XjmJei_W86Q/s320/bumper480x270.png&quot; width=&quot;520&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;section&gt;
&lt;h1 align=&quot;left&quot;&gt;
&lt;b&gt;The Go Programming Language&lt;/b&gt;&lt;/h1&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
Go is an open source programming environment that makes it easy to build simple, reliable, and efficient software.&lt;/blockquote&gt;
&lt;blockquote&gt;
The Go programming language is an open source project to make programmers more productive.&lt;/blockquote&gt;
Go is outgoing, crisp, clean, and competent. Its concurrency mechanism make it easy to write down programs that obtain the most out of multicore and networked machines, at the same time as its novel type system enable flexible and modular program structure. Go compiles fast to machine code nevertheless has the ease of garbage collection and the control of run-time expression. It&#39;s a fast, statically typed, compiled language that feels similar to a dynamically typed, interpreted language.Go is an open source project with a BSD-style license. There are two official Go compiler toolchains: the gc Go compiler and the gccgo compiler that is part of the GNU C Compiler (GCC).The gc compiler is the more established and well-tested of the two.The gc compiler supports the subsequent operating systems and architectures. Please make sure your system meets these necessities before proceeding. If your OS or architecture is not on the list, it&#39;s possible that gccgo might support your setup; see Setting up and using gccgo for details.&lt;br /&gt;

&lt;style type=&quot;text/css&quot;&gt;
table{
width: 590px;
border-1;
}
th, td{
border: #19c1f6;
}
th{
background-color: #19c1f6;
color: #fff;
}
&lt;/style&gt;

&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operating system&lt;/th&gt;
&lt;th&gt;Architectures&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;FreeBSD 7 or later&lt;/td&gt;
&lt;td&gt;amd64, 386&lt;/td&gt;
&lt;td&gt;Debian GNU/kFreeBSD not supported&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Linux 2.6.23 or later with glibc&lt;/td&gt;
&lt;td&gt;amd64, 386, arm&lt;/td&gt;
&lt;td&gt;CentOS/RHEL 5.x not supported; no binary distribution for ARM yet&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mac OS X 10.6/10.7&lt;/td&gt;
&lt;td&gt;amd64, 386&lt;/td&gt;
&lt;td&gt;use the gcc† that comes with Xcode&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Windows 2000 or later&lt;/td&gt;
&lt;td&gt;amd64, 386&lt;/td&gt;
&lt;td&gt;use mingw gcc†; cygwin or msys is not needed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr /&gt;
The commands are: &lt;/b&gt;&lt;/h4&gt;
&lt;details&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;build&lt;/th&gt;
&lt;th&gt;compile packages and dependencies&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;clean&lt;/th&gt;
&lt;th&gt;remove object files&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;doc&lt;/th&gt;
&lt;th&gt;run godoc on package sources&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;env&lt;/th&gt;
&lt;th&gt;print Go environment information&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;fix&lt;/th&gt;         
&lt;th&gt;run go tool fix on packages&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th&gt;fmt&lt;/th&gt;         
&lt;th&gt;run gofmt on package sources&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;get&lt;/th&gt;         
&lt;th&gt;download and install packages and dependencies&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;install&lt;/th&gt;     
&lt;th&gt;compile and install packages and dependencies&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;list&lt;/th&gt;        
&lt;th&gt;list packages&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;run&lt;/th&gt;         
&lt;th&gt;compile and run Go program&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;test&lt;/th&gt;        
&lt;th&gt;test packages&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;tool&lt;/th&gt;        
&lt;th&gt;run specified go tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;version&lt;/th&gt;     
&lt;th&gt;print Go version&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;vet&lt;/th&gt;         
&lt;th&gt;run go tool vet on packages&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;&lt;/table&gt;&lt;/details&gt;
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr /&gt;
Effective Go&lt;/b&gt;&lt;/h4&gt;
&lt;details&gt;Go is a latest language. Even though it borrows ideas from existing languages, it has extraordinary properties that make efficient Go programs different in nature from programs written in its relatives. A simple translation of a C++ or Java program into Go is doubtful to produce a satisfactory result—Java programs are written in Java, not Go. On the other hand, thinking about the problem from a Go viewpoint could construct a successful but quite different program. In other words, to write Go well, it&#39;s important to appreciate its properties and idioms. It&#39;s also significant to know the recognized convention for programming in Go, such as naming, formatting, program construction, and so on, so that programs you write will be simple for other Go programmers to recognize.&lt;br /&gt;&lt;/details&gt;
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr /&gt;
What is the purpose of the project? &lt;/b&gt;&lt;/h4&gt;
&lt;details&gt;No major systems language has emerged in over a decade, but over that time the computing landscape has changed tremendously. There are several trends:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Computers are enormously quicker but software development is not faster.&lt;/li&gt;
&lt;li&gt;Dependency management is a big part of software development today but the &quot;header files&quot; of languages in the C tradition are antithetical to clean dependency analysis—and fast compilation.&lt;/li&gt;
&lt;li&gt;There is a growing rebellion against cumbersome type systems like those of Java and C++, pushing people towards dynamically typed languages such as Python and JavaScript.&lt;/li&gt;
&lt;li&gt;Some fundamental concepts such as garbage collection and parallel computation are not well supported by popular systems languages.&lt;/li&gt;
&lt;li&gt;The emergence of multicore computers has generated worry and confusion.&lt;/li&gt;
&lt;/ul&gt;
We believe it&#39;s worth trying again with a new language, a concurrent, garbage-collected language with fast compilation. Regarding the points above:&lt;br/&gt;
&lt;ul&gt;
&lt;li&gt;It is possible to compile a large Go program in a few seconds on a single computer.&lt;/li&gt;
&lt;li&gt;Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries.&lt;/li&gt;
&lt;li&gt;Go&#39;s type system has no hierarchy, so no time is spent defining the relationships between types. Also, although Go has static types the language attempts to make types feel lighter weight than in typical OO languages.&lt;/li&gt;
&lt;li&gt;Go is fully garbage-collected and provides fundamental support for concurrent execution and communication.&lt;/li&gt;
&lt;li&gt;By its design, Go proposes an approach for the construction of system software on multicore machines.&lt;/li&gt;
&lt;/ul&gt;&lt;/details&gt;
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr /&gt;
History of the Project&lt;/b&gt;&lt;/h4&gt;
&lt;details&gt;Robert Griesemer, Rob Pike and Ken Thompson started sketching the goals for a new language on the white board on September 21, 2007. Within a few days the goals had settled into a plan to do something and a fair idea of what it would be. Design continued part-time in parallel with unrelated work. By January 2008, Ken had started work on a compiler with which to explore ideas; it generated C code as its output. By mid-year the language had become a full-time project and had settled enough to attempt a production compiler. In May 2008, Ian Taylor independently started on a GCC front end for Go using the draft specification. Russ Cox joined in late 2008 and helped move the language and libraries from prototype to reality.
Go became a public open source project on November 10, 2009. Many people from the community have contributed ideas, discussions, and code.&lt;br /&gt;&lt;/details&gt;
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr /&gt;
Go&#39;s ancestors&lt;/b&gt;&lt;/h4&gt;
&lt;details&gt;Go is mostly in the C family (basic syntax), with significant input from the Pascal/Modula/Oberon family (declarations, packages), plus some ideas from languages inspired by Tony Hoare&#39;s CSP, such as Newsqueak and Limbo (concurrency). However, it is a new language across the board. In every respect the language was designed by thinking about what programmers do and how to make programming, at least the kind of programming we do, more effective, which means more fun.There are now several Go programs deployed in production inside Google. A public example is the server behind http://golang.org. It&#39;s just the godoc document server running in a production configuration on Google App Engine.&lt;br /&gt;
&lt;/details&gt;
&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr /&gt;
Is Go an object-oriented language? &lt;/b&gt;&lt;/h4&gt;
Yes and no. Although Go has types and methods and allows an object-oriented style of programming, there is no type hierarchy. The concept of “interface” in Go provides a different approach that we believe is easy to use and in some ways more general. There are also ways to embed types in other types to provide something analogous—but not identical—to subclassing. Moreover, methods in Go are more general than in C++ or Java: they can be defined for any sort of data, even built-in types such as plain, “unboxed” integers. They are not restricted to structs (classes).Also, the lack of type hierarchy makes “objects” in Go feel much more lightweight than in languages such as C++ or Java.&lt;br /&gt;

&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr /&gt;
How are libraries documented? &lt;/b&gt;&lt;/h4&gt;
&lt;details&gt;There is a program, godoc, written in Go, that extracts package documentation from the source code. It can be used on the command line or on the web. An instance is running at http://golang.org/pkg/. In fact, godoc implements the full site at http://golang.org/.&lt;br /&gt;&lt;/details&gt;

&lt;h4 align=&quot;left&quot;&gt;
&lt;b&gt;&lt;hr /&gt;
Hello World in Go&lt;/b&gt;&lt;/h4&gt;
&lt;pre&gt;package main
import &quot;fmt&quot;
func main() {
            fmt.Println(&quot;Hello, World!&quot;)
}
&lt;/pre&gt;
&lt;hr /&gt;
&lt;h1&gt;
Go Language Website&lt;/h1&gt;&lt;details&gt;
http://golang.org/&lt;br /&gt;

Here you can see the Website.
&lt;iframe height=&quot;525&quot; src=&quot;http://golang.org/&quot; width=&quot;525&quot;&gt;
&lt;/iframe&gt;
It should show everything you want to know about Go Lang.&lt;br /&gt;
&lt;br /&gt;
&lt;label for=&quot;Rating field&quot;&gt;Information Rating&lt;/label&gt;
&lt;select name=&quot;Rating&quot; Id=&quot;Rating_field&quot;&gt;
&lt;option&gt;10&lt;/option&gt;
&lt;/select&gt;
&lt;/section&gt;
&lt;iframe src=&quot;http://www.appsgeyser.com/social_widget/social_widget.php?width=300&amp;height=160&amp;apkName=Web Expert&amp;simpleVersion=no&quot; width=&quot;310&quot; height=&quot;180&quot; vspace=&quot;0&quot; hspace=&quot;0&quot; frameborder=&quot;no&quot; scrolling=&quot;no&quot; seamless=&quot;&quot; allowtransparency=&quot;true&quot;&gt;&lt;/iframe&gt;
&lt;/details&gt;</content><link rel='replies' type='application/atom+xml' href='http://vikaswebgyan.blogspot.com/feeds/1493935975835534241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vikaswebgyan.blogspot.com/2012/09/the-go-programming-language.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1493935975835534241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2668244871531886674/posts/default/1493935975835534241'/><link rel='alternate' type='text/html' href='http://vikaswebgyan.blogspot.com/2012/09/the-go-programming-language.html' title='The Go Programming Language'/><author><name>bjp4haryana</name><uri>http://www.blogger.com/profile/01789250445503096738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpFXT-u9dYCwxr3OJa12HhVK3mmHrxJYjEfzevttunpRnbhC2C_iWlDgW6NitaZBpoJcHh2VVw9MKVb2hKhXhZLqh3T-F-hci2EH6IeDx5Gzw4rMCZ6aznE_pmH_rJokJ2XjmJei_W86Q/s72-c/bumper480x270.png" height="72" width="72"/><thr:total>11</thr:total><georss:featurename>Bangalore, Karnataka, India</georss:featurename><georss:point>12.9715987 77.5945627</georss:point><georss:box>12.724026199999999 77.2787057 13.2191712 77.910419699999991</georss:box></entry></feed>