<?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: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-21499889</id><updated>2012-02-16T14:07:52.907-08:00</updated><category term='homework'/><category term='prolog'/><title type='text'>Programming Languages</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>88</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-21499889.post-5215044063153444304</id><published>2008-07-03T11:30:00.001-07:00</published><updated>2008-07-03T11:30:37.917-07:00</updated><title type='text'></title><content type='html'>&lt;table width="100%" border="0" cellpadding="6" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td id="_528510_1" class="bLight" valign="top" width="42" align="left"&gt;      &lt;br /&gt;&lt;/td&gt;           &lt;td class="bLight" width="*" align="left"&gt;         &lt;span class="fnt3"&gt;&lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?content_id=_528510_1&amp;amp;course_id=_118104_1&amp;amp;render_type=DEFAULT"&gt;&lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Calculator Project&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;In VBA, make a form, and make a calculator, with a testbox and a series of buttons for addition, subtraction, multiplication, division, and equal.&lt;!--BB ASSIGNMENT INTERNALS: SKIP REST--&gt;&lt;br /&gt;&gt;&gt; &lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?course_id=_118104_1&amp;amp;content_id=_528510_1"&gt;View/Complete Assignment: Calculator Project&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;       &lt;/td&gt;              &lt;td class="bLight" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_528509_1" class="bWhite" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/assignment_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bWhite" width="*" align="left"&gt;         &lt;span class="fnt3"&gt;&lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?content_id=_528509_1&amp;amp;course_id=_118104_1&amp;amp;render_type=DEFAULT"&gt;&lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Prolog Homework 3&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;Trace through the conc procedure, appending a list of four elements to another list of four elements.&lt;br /&gt;&lt;br /&gt;Write the following prolog procedures, on lists.&lt;br /&gt;&lt;br /&gt;1. subst(A,B,C,D) where list D is list C with element A substituted for all occurrences of element B.&lt;br /&gt;2. equal(X,Y) if X and Y are the same set.&lt;br /&gt;&lt;br /&gt;Also, read thru the following:&lt;br /&gt;&lt;a href="http://www.ling.helsinki.fi/kit/2004k/ctl272/Bangor/clbook_30.html"&gt;http://www.ling.helsinki.fi/kit/2004k/ctl272/Bangor/clbook_30.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;and do copy and try out the examples.&lt;!--BB ASSIGNMENT INTERNALS: SKIP REST--&gt;&lt;br /&gt;&gt;&gt; &lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?course_id=_118104_1&amp;amp;content_id=_528509_1"&gt;View/Complete Assignment: Prolog Homework 3&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;       &lt;/td&gt;              &lt;td class="bWhite" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_528508_1" class="bLight" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/assignment_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bLight" width="*" align="left"&gt;         &lt;span class="fnt3"&gt;&lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?content_id=_528508_1&amp;amp;course_id=_118104_1&amp;amp;render_type=DEFAULT"&gt;&lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Prolog Homework 2&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;&lt;ol&gt;&lt;li&gt;Try to write Prolog rules corresponding to each of the following. &lt;ol&gt;&lt;li&gt;Every farmer owns a donkey. &lt;/li&gt;&lt;li&gt;Every farmer who owns a donkey beats it. &lt;/li&gt;&lt;li&gt;If Pedro owns a donkey, he beats it. &lt;/li&gt;&lt;li&gt;If Pedro is a farmer, he owns a donkey. &lt;/li&gt;&lt;li&gt;If Pedro is a donkey-owning farmer then he beats his donkey. &lt;/li&gt;&lt;li&gt;If Pedro is a donkey-owning farmer then he probably beats his donkey. &lt;/li&gt;&lt;li&gt;Donkeys have a hard time. &lt;/li&gt;&lt;/ol&gt; &lt;/li&gt;&lt;li&gt;The infix predicate &lt;code&gt;=/2&lt;/code&gt; takes two arguments and tries to unify them. We can use this to experiment with Prolog's pattern  matching; for example:  &lt;blockquote&gt;&lt;pre&gt;| ?- X = [a,b].&lt;br /&gt;X = [a,b] ?&lt;br /&gt;yes&lt;br /&gt;&lt;br /&gt;| ?- [X] = [a, b].&lt;br /&gt;no&lt;br /&gt;&lt;br /&gt;| ?- X = a, X = Y.&lt;br /&gt;X = a,&lt;br /&gt;Y = a ?&lt;br /&gt;yes&lt;br /&gt;&lt;/pre&gt; &lt;/blockquote&gt; So, Prolog will tell us whether the terms on either side of the  &lt;code&gt;=&lt;/code&gt; unify, and if they do, it will provide us with the bindings for any variables that appear. &lt;p&gt;For each of the following: &lt;/p&gt;&lt;ul&gt;&lt;li&gt;specify whether the query submitted to Prolog succeeds or fails; and &lt;/li&gt;&lt;li&gt;if it succeeds, specify what is assigned to the variables by the unification;  &lt;/li&gt;&lt;li&gt;if it fails, explain why. &lt;/li&gt;&lt;/ul&gt; &lt;ol&gt;&lt;li&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;| ?- X = fred.&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- jane = fred.&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- X = fred, X = Y.&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- X = happy(jim).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- X = Y.&lt;/code&gt;  &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- 2 + 1 = 3.&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- f(X,a) = f(a,X).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- fred = fred.&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- likes(jane, X) = likes(X, jim).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- f(X,Y)=f(P,P).&lt;/code&gt;&lt;/li&gt;&lt;/ol&gt; &lt;/li&gt;&lt;li&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;| ?- A = b(c).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- a = b(c).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- a(b,C) = a(C,b).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- a(b,C) = a(C,d).&lt;/code&gt;  &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- A = B.&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- A = b(C).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- 3 = 6/2.&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- a(b,c) = a(b,c).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- a(B,C) = a(D,D).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- member(a,L) = member(E,[b,c,d]).&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;| ?- A = b(A).&lt;/code&gt;&lt;/li&gt;&lt;/ol&gt; &lt;/li&gt;&lt;/ol&gt; &lt;/li&gt;&lt;li&gt;Write the &lt;code&gt;ancestor/2&lt;/code&gt; predicate to a file, and add about ten facts along the lines of &lt;code&gt;parent(anna,belinda)&lt;/code&gt;,  &lt;code&gt;parent(belinda,celia)&lt;/code&gt; etc. Then call &lt;tt&gt;ancestor(anna,X)&lt;/tt&gt;. Use &lt;code&gt;;&lt;/code&gt; to see all solutions, viewing the execution of the goal with trace.  &lt;/li&gt;&lt;li&gt;We can use the successor notation for addition to show an example of the interaction between unification and recursion. This example may appear a bit complex first, if you are not used to mathematical theory, but in fact it just shows how simple the ideas really are. &lt;p&gt;The numbers 0, 1, 2, 3, 4...are defined by a set of axioms called the Peano axioms.  The definition of the numbers themselves are based on two concepts: &lt;/p&gt;&lt;ul&gt;&lt;li&gt;a STARTING POINT, which we call zero and write as 0;  and  &lt;/li&gt;&lt;li&gt;the concept of BEING THE NEXT NUMBER, which we will  represent as s(K). &lt;/li&gt;&lt;/ul&gt; In this notation, 0 is 0, 1 is s(0), 2 is s(s(0)), 3 is s(s(s(0))), and so on.  Note that although s is a function, there is no notion of it being evaluated.  &lt;p&gt;Using this representation, we can write a procedure which formalises the definition of addition: &lt;/p&gt;&lt;blockquote&gt;&lt;pre&gt;% succ_plus/3&lt;br /&gt;% the definition of addition according to the Peano axioms&lt;br /&gt;% succ_plus(X,Y,Z) corresponds to X + Y = Z&lt;br /&gt;% X,Y,Z are all given in successor notation&lt;br /&gt;&lt;br /&gt;succ_plus(0,X,X).&lt;br /&gt;succ_plus(s(X),Y,s(Z)) :-&lt;br /&gt;succ_plus(X,Y,Z).&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;/blockquote&gt;  Let's say that we want to add 3 and 2. 3 is the successor of the successor of the successor of 0 (s(s(s(0)))) and 2 is the successor of the successor of 0 (s(s(0))). To follow the execution of the goal, we use trace as usual: &lt;blockquote&gt;&lt;pre&gt;| ?- trace,succ_plus(s(s(s(0))),s(s(0)),X).&lt;br /&gt;{The debugger will first creep -- showing everything (trace)}&lt;br /&gt;1 1 Call: succ_plus(s(s(s(0))),s(s(0)),_128) ?&lt;br /&gt;2 2 Call: succ_plus(s(s(0)),s(s(0)),_325) ?&lt;br /&gt;3 3 Call: succ_plus(s(0),s(s(0)),_445) ?&lt;br /&gt;4 4 Call: succ_plus(0,s(s(0)),_561) ?&lt;br /&gt;4 4 Exit: succ_plus(0,s(s(0)),s(s(0))) ?&lt;br /&gt;3 3 Exit: succ_plus(s(0),s(s(0)),s(s(s(0)))) ?&lt;br /&gt;2 2 Exit: succ_plus(s(s(0)),s(s(0)),s(s(s(s(0))))) ?&lt;br /&gt;1 1 Exit: succ_plus(s(s(s(0))),s(s(0)),s(s(s(s(s(0)))))) ?&lt;br /&gt;&lt;br /&gt;X = s(s(s(s(s(0))))) ?&lt;br /&gt;&lt;br /&gt;yes&lt;br /&gt;?-&lt;br /&gt;&lt;/pre&gt; &lt;/blockquote&gt; Whenever the second clause of &lt;code&gt;addition/3&lt;/code&gt; is used (i.e. every time the first term is not equal to 0) &lt;code&gt;X&lt;/code&gt; matches the interior of a structure. For instance, in the first call, &lt;code&gt;s(X)&lt;/code&gt; and &lt;code&gt;s(s(s(0)))&lt;/code&gt; are unified, giving the substitution &lt;code&gt;X = s(s(0))&lt;/code&gt;.  The recursive clause is used until &lt;tt&gt;X&lt;/tt&gt; is matched to 0--then we use the base case, and the third term is unified with the second term. As we step back through the recursive clause, &lt;tt&gt;s(...)&lt;/tt&gt; is added on to the third term once for every &lt;tt&gt;s(...)&lt;/tt&gt; we had to strip off to reach the base case.   &lt;ol&gt;&lt;li&gt;Try the program out with a few different numbers, until you  understand how it works.  &lt;/li&gt;&lt;li&gt;Write a procedure for subtraction. This will only work when the  first number is equal or greater to the second--why?&lt;!--BB ASSIGNMENT INTERNALS: SKIP REST--&gt;&lt;br /&gt;&gt;&gt; &lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?course_id=_118104_1&amp;amp;content_id=_528508_1"&gt;View/Complete Assignment: Prolog Homework 2&lt;/a&gt;&lt;br /&gt;      &lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/span&gt;&lt;/td&gt;              &lt;td class="bLight" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_528507_1" class="bWhite" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/assignment_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bWhite" width="*" align="left"&gt;         &lt;span class="fnt3"&gt;&lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?content_id=_528507_1&amp;amp;course_id=_118104_1&amp;amp;render_type=DEFAULT"&gt;&lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Prolog Homework 1&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;Download and install SW-I Prolog.  &lt;p&gt; Trace through the sam likes example. &lt;/p&gt;&lt;p&gt; Then: &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;ol&gt;&lt;li&gt;Create files with the facts and rules discussed in this chapter. Try out various queries. &lt;/li&gt;&lt;li&gt;Represent the following sentences as Prolog facts.  &lt;ol&gt;&lt;li&gt;Bill is tall. &lt;/li&gt;&lt;li&gt;Bill is a teacher. &lt;/li&gt;&lt;li&gt;Bill sings. &lt;/li&gt;&lt;li&gt;Bill likes ice-cream.  &lt;/li&gt;&lt;li&gt;Mary hates ice-cream.  &lt;/li&gt;&lt;li&gt;Today is Friday. &lt;/li&gt;&lt;li&gt;Jane hit Bill. &lt;/li&gt;&lt;li&gt;Jane hit Bill with a cricket bat.  &lt;/li&gt;&lt;li&gt;Belinda bought a sweater. &lt;/li&gt;&lt;li&gt;Belinda bought Jim a sweater. &lt;/li&gt;&lt;li&gt;Belinda bought Jim a sweater at Jenner's. &lt;/li&gt;&lt;li&gt;Belinda bought Jim a sweater for fifty pounds at Jenner's. &lt;/li&gt;&lt;li&gt;Belinda is married to John. &lt;/li&gt;&lt;li&gt;John is Belinda's husband. &lt;/li&gt;&lt;li&gt;John and Belinda are married.   &lt;/li&gt;&lt;/ol&gt; &lt;/li&gt;&lt;li&gt;Construct a file called &lt;code&gt;family.pl&lt;/code&gt; containing the following Prolog clauses.  &lt;blockquote&gt;&lt;pre&gt;% parent(Parent,Offspring)&lt;br /&gt;parent(mary,thomas).&lt;br /&gt;parent(mary,jane).&lt;br /&gt;parent(william,thomas).&lt;br /&gt;parent(william,jane).&lt;br /&gt;parent(thomas,lee).&lt;br /&gt;parent(thomas,sandy).&lt;br /&gt;&lt;br /&gt;% female(Female).&lt;br /&gt;female(mary).&lt;br /&gt;female(jane).&lt;br /&gt;female(sandy).&lt;br /&gt;&lt;br /&gt;% male(Male).&lt;br /&gt;male(thomas).&lt;br /&gt;male(william).&lt;br /&gt;male(lee).&lt;br /&gt;&lt;/pre&gt; &lt;/blockquote&gt; Load the contents of the &lt;tt&gt;family&lt;/tt&gt; file into the Prolog interpreter. &lt;ul&gt;&lt;li&gt;Display the contents of the database by using &lt;code&gt;listing/0&lt;/code&gt;. Don't forget the full stop. &lt;/li&gt;&lt;li&gt;Display parts of the contents by using the predicate &lt;code&gt;listing/1&lt;/code&gt; whose argument should be the name of a predicate.  For instance typing &lt;code&gt;listing(male)&lt;/code&gt; will display all facts whose predicate is &lt;code&gt;male&lt;/code&gt; regardless of arity.  &lt;/li&gt;&lt;li&gt;Look at the following queries.  Try to work out what the interpreter will reply first, then try them out. Check if there is more than one solution using &lt;code&gt;;&lt;/code&gt; if applicable.  &lt;blockquote&gt;&lt;code&gt;| ?- parent(mary,thomas).&lt;/code&gt;&lt;br /&gt;&lt;code&gt;| ?- parent(thomas,lee).&lt;/code&gt;&lt;br /&gt;&lt;code&gt;| ?- parent(thomas,mary).&lt;/code&gt;&lt;br /&gt;&lt;code&gt;| ?- male(william).&lt;/code&gt;&lt;br /&gt;&lt;code&gt;| ?- parent(thomas,Who).&lt;/code&gt;&lt;br /&gt;&lt;code&gt;| ?- parent(Parent,sandy).&lt;/code&gt;&lt;br /&gt;&lt;code&gt;| ?- parent(X,Y).&lt;/code&gt;  &lt;/blockquote&gt; &lt;/li&gt;&lt;li&gt;What queries would you use to find out the following?  &lt;ul&gt;&lt;li&gt;Is Mary the parent of Thomas and Jane? &lt;/li&gt;&lt;li&gt;Do Jane and Thomas have the same parent?  &lt;/li&gt;&lt;li&gt;Does Sandy have a sister? &lt;/li&gt;&lt;li&gt;Who is Thomas's mother? &lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;li&gt;Establish a database with parent and gender facts for your own family.  Write rules for commonly used family terms, such as sister, brother, mother, father, grandparent, grandfather, cousin, aunt, half-brother, etc. Try out the program, making sure that it gives the correct answers.  Use trace to make sure you understand the different answers.&lt;!--BB ASSIGNMENT INTERNALS: SKIP REST--&gt;&lt;br /&gt;&gt;&gt; &lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?course_id=_118104_1&amp;amp;content_id=_528507_1"&gt;View/Complete Assignment: Prolog Homework 1&lt;/a&gt;&lt;br /&gt;      &lt;/li&gt;&lt;/ol&gt;&lt;/span&gt;&lt;/td&gt;              &lt;td class="bWhite" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_486245_1" class="bLight" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/assignment_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bLight" width="*" align="left"&gt;         &lt;span class="fnt3"&gt;&lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?content_id=_486245_1&amp;amp;course_id=_118104_1&amp;amp;render_type=DEFAULT"&gt;&lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Homework #11: Dynamic Variables&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;Read this article at Microsoft Research about "&lt;a href="http://research.microsoft.com/research/pubs/view.aspx?tr_id=411"&gt;Dynamic Variables&lt;/a&gt;." Do not read the Appendix to the article just yet, only the main body of the article.&lt;br /&gt;&lt;br /&gt;Answer the following questions:&lt;br /&gt;1) List two purposes for which they envision using these dynamically scoped variables?&lt;br /&gt;2) Choose one of those two, and motivate it. That is, show what the code would look like when not using dynamic variables, and then what it would look like with dynamic variables.&lt;br /&gt;3) Briefly describe the "simple" and the "novel" implementations.&lt;!--BB ASSIGNMENT INTERNALS: SKIP REST--&gt;&lt;br /&gt;&gt;&gt; &lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?course_id=_118104_1&amp;amp;content_id=_486245_1"&gt;View/Complete Assignment: Homework #11: Dynamic Variables&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;       &lt;/td&gt;              &lt;td class="bLight" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_484641_1" class="bWhite" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/assignment_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bWhite" width="*" align="left"&gt;         &lt;span class="fnt3"&gt;&lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?content_id=_484641_1&amp;amp;course_id=_118104_1&amp;amp;render_type=DEFAULT"&gt;&lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Static Scoping&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;Read this article. Give four reasons why nesting in Ada programs is for the birds. What is the authors' suggestion?  Also, read this article about regular expressions in Word, and try the find and replace example in the article. http://office.microsoft.com/en-us/help/HA010873051033.aspx&lt;!--BB ASSIGNMENT INTERNALS: SKIP REST--&gt;&lt;br /&gt;&gt;&gt; &lt;a href="http://bb.touro.edu/webapps/blackboard/assignments/student/do_assignment.jsp?course_id=_118104_1&amp;amp;content_id=_484641_1"&gt;View/Complete Assignment: Static Scoping&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;       &lt;/td&gt;              &lt;td class="bWhite" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_483185_1" class="bLight" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/document_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bLight" width="*" align="left"&gt;         &lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;HW #8&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;Using VBA for Excel, implement the first FSA from assignment #5. On the spreadsheet, include a formal description of the FSA. This includes the transition function delta. Rather than using Gotos, keep a variable which maintains the present state, and look up the appropriate transition to the next state, based on the present state and the input, from that lookup table on the Excel worksheet.&lt;br /&gt;&lt;br /&gt;&lt;embed type="video/quicktime" src="http://media.revver.com/qt;sharer=135474/672260.mov" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect" cache="False" autoplay="False" width="480" height="376"&gt;&lt;/embed&gt;&lt;/span&gt;       &lt;/td&gt;              &lt;td class="bLight" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_483184_1" class="bWhite" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/document_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bWhite" width="*" align="left"&gt;         &lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;HW #7&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;Using VBA for Excel, implement the first FSA from assignment #5. Read the input string from cell B1. Print "accept" or "reject" in C1. Print the sequence of states in cell A4 and down (A5, A6, etc). Use gotos and goto labels to represent the states. Use the MID function to extract letters sequentially from the input string.&lt;br /&gt;&lt;br /&gt;&lt;embed type="video/quicktime" src="http://media.revver.com/qt;sharer=135474/668779.mov" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect" cache="False" autoplay="False" width="480" height="376"&gt;&lt;/embed&gt;&lt;/span&gt;       &lt;/td&gt;              &lt;td class="bWhite" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_478942_1" class="bLight" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/document_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bLight" width="*" align="left"&gt;         &lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Assignment 6: FSAs&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://bb.touro.edu/@@fd0a12f5b37362f327f76c413958f986/courses/1/MCO-251--AB-SP-08-UG/content/_478942_1/FSA.doc"&gt;FSA.doc&lt;/a&gt;&lt;span style="font-family:Arial,Helvetica,sans-serif;font-size:78%;"&gt; (38 Kb) &lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;Answer the questions in the attached Microsoft Word document about two FSMs.&lt;br /&gt;&lt;br /&gt;Due Feb 11, 2008&lt;/span&gt;       &lt;/td&gt;              &lt;td class="bLight" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_478939_1" class="bWhite" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/document_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bWhite" width="*" align="left"&gt;         &lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Assignment 5&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;Download G95 (sidebar) and install it on your computer. Name the files *.f90 to be able to use FORTRAN 90 syntax. If you name it *.f, you will have annoying restrictions, such as the first 6 characters on a line being reserved. Read through the beginning of the tutorial, here:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.cisl.ucar.edu/tcg/consweb/Fortran90/F90Tutorial/tutorial.html"&gt;http://www.cisl.ucar.edu/tcg/consweb/Fortran90/F90Tutorial/tutorial.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Specifically, start with "Exercises and Examples," and do Exercise 2.1&lt;br /&gt;&lt;br /&gt;Due Feb 11, 2008&lt;/span&gt;       &lt;/td&gt;              &lt;td class="bWhite" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_475689_1" class="bLight" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/document_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bLight" width="*" align="left"&gt;         &lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Assignment #3, 4&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;#3: Due this Wednesday, Feb 6&lt;br /&gt;In Visual Basic for Applications for Excel, create a macro that puts the numbers 1 through 13 in cells A1 through A13. If possible, do so using the functionality in which you can drag to extend an existing pattern of numbers. Copy the text of the VBA macro which was created, and submit that.&lt;br /&gt;&lt;br /&gt;#4: Due next Monday, Feb 11&lt;br /&gt;Write two UDFs (User Defined Functions), with meaningful names of your own choosing. The first should take in X and Y and return X times Y. The second should take in X and return X factorial.&lt;/span&gt;       &lt;/td&gt;              &lt;td class="bLight" valign="top" width="10%" align="right" nowrap="1"&gt;               &lt;br /&gt;&lt;/td&gt;        &lt;/tr&gt;                     &lt;tr&gt;                    &lt;td id="_470343_1" class="bWhite" valign="top" width="42" align="left"&gt;         &lt;img alt="Item" src="http://bb.touro.edu/images/ci/sets/set02/document_on.gif" /&gt;       &lt;/td&gt;           &lt;td class="bWhite" width="*" align="left"&gt;         &lt;span class="label"&gt;&lt;span style="color:#000000;"&gt;Assignment #1, #2&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="fnt0"&gt;1. Give a short evaluation (a few sentences) of Stroustrup's paper on &lt;a href="http://www.research.att.com/%7Ebs/whitespace98.pdf"&gt;Generalized Operator Overloading for C++ 2000 &lt;/a&gt;in terms of readability and writability.&lt;br /&gt;&lt;br /&gt;Due approximately Monday, Feb 4.&lt;br /&gt;&lt;br /&gt;2. Take some programming language you know and discuss its positive and negative aspects in terms readability, writability, and reliability. (Two or three paragraphs.)&lt;br /&gt;&lt;br /&gt;Due approximately Monday, Feb 6.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-5215044063153444304?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/5215044063153444304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=5215044063153444304' title='44 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/5215044063153444304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/5215044063153444304'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/07/calculator-project-in-vba-make-form-and.html' title=''/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>44</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-5985654224695399975</id><published>2008-05-26T14:43:00.000-07:00</published><updated>2008-05-26T14:55:02.528-07:00</updated><title type='text'>subst in Prolog, pt i</title><content type='html'>The assignment:&lt;br /&gt;"Write &lt;span class="fnt0"&gt;&lt;span style="font-family: courier new;"&gt;subst(A,B,C,D)&lt;/span&gt; where list D is list C with element A substituted for all occurrences of element B."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The first case we want to handle is the base case. That is, if we have the empty list, it does not matter &lt;span style="font-weight: bold;"&gt;what&lt;/span&gt; A and B are, because there is nothing to replace. Therefore:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;subst(A, B, [ ], [ ]).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;Or, &lt;/span&gt;because we are using neither A nor B, we can write:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;subst(_, _, &lt;/span&gt;&lt;span style="font-family: courier new;"&gt;[ ]&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;, [ ]).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The alternative is that we are &lt;span style="font-weight: bold;"&gt;not&lt;/span&gt; dealing with an empty list. In such a situation, we want to define subst recursively, such that we yank out the first element -- the head -- if it is B, and replace it with A. Unless of course the head is &lt;span style="font-weight: bold;"&gt;not&lt;/span&gt; element B, in which case we want to just leave it alone -- that is, put the head &lt;span style="font-weight: bold;"&gt;back&lt;/span&gt; on the list.&lt;br /&gt;&lt;br /&gt;The way we pull apart such a list is as [H | T], where H is the head and T is the tail.&lt;br /&gt;&lt;br /&gt;More on this later, but hopefully this gets you on the right track. It does not have to work exactly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-5985654224695399975?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/5985654224695399975/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=5985654224695399975' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/5985654224695399975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/5985654224695399975'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/05/subst-in-prolog-pt-i.html' title='subst in Prolog, pt i'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-8680880864593449731</id><published>2008-05-14T14:41:00.000-07:00</published><updated>2008-05-14T14:42:08.577-07:00</updated><title type='text'></title><content type='html'>8, 9, 10, 13, 15, 16&lt;br /&gt;&lt;br /&gt;ch 8 -- control structures p 324 and on&lt;br /&gt;if-fi&lt;br /&gt;do&lt;br /&gt;&lt;br /&gt;od&lt;br /&gt;&lt;br /&gt;ch 9, ch 10: parameter passing&lt;br /&gt;skip 380-387&lt;br /&gt;focus on coroutines, on page 391&lt;br /&gt;&lt;br /&gt;in ch 10, statis links, dynamic links&lt;br /&gt;&lt;br /&gt;skip ch 11, 12, 14&lt;br /&gt;&lt;br /&gt;do chapter 13&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-8680880864593449731?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/8680880864593449731/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=8680880864593449731' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8680880864593449731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8680880864593449731'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/05/8-9-10-13-15-16-ch-8-control-structures.html' title=''/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-7475946482941454572</id><published>2008-05-14T10:54:00.001-07:00</published><updated>2008-05-14T10:54:51.309-07:00</updated><title type='text'></title><content type='html'>http://docs.google.com/Doc?id=ajbqhgmq9qdz_110cscw9cc7&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-7475946482941454572?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/7475946482941454572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=7475946482941454572' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/7475946482941454572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/7475946482941454572'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/05/httpdocs.html' title=''/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-1801105655971683613</id><published>2008-05-12T12:55:00.000-07:00</published><updated>2008-05-12T12:56:05.760-07:00</updated><title type='text'>Common Lisp Tutorial</title><content type='html'>http://www.notam02.no/internt/cm-sys/cm-2.2/doc/clt.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-1801105655971683613?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/1801105655971683613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=1801105655971683613' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/1801105655971683613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/1801105655971683613'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/05/common-lisp-tutorial.html' title='Common Lisp Tutorial'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-8961319053286731711</id><published>2008-05-08T14:24:00.001-07:00</published><updated>2008-05-08T14:24:52.044-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='prolog'/><title type='text'>Not Equal In Prolog</title><content type='html'>After consulting with this &lt;a href="http://www.poplog.org/docs/popdocs/pop11/teach/prolog"&gt;website&lt;/a&gt;, actually connected with pop11. :)&lt;br /&gt;&lt;br /&gt;The following interaction from SWI-Prolog when consulting j.pl. Use similar code to make sure sally is not her own sibling.&lt;br /&gt;&lt;br /&gt;% c:/j.pl compiled 0.00 sec, -292 bytes&lt;br /&gt;11 ?- listing.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;myneq(A, B) :-&lt;br /&gt;       A\=B.&lt;br /&gt;&lt;br /&gt;Yes&lt;br /&gt;12 ?- myneq(a, a).&lt;br /&gt;&lt;br /&gt;No&lt;br /&gt;13 ?- myneq(a, b).&lt;br /&gt;&lt;br /&gt;Yes&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-8961319053286731711?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/8961319053286731711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=8961319053286731711' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8961319053286731711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8961319053286731711'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/05/not-equal-in-prolog.html' title='Not Equal In Prolog'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-9218582439039027470</id><published>2008-04-28T10:18:00.000-07:00</published><updated>2008-04-28T12:36:07.361-07:00</updated><title type='text'>Download PopLog, a Free Lisp Interpreter</title><content type='html'>&lt;a href="http://www.cs.bham.ac.uk/research/projects/poplog/freepoplog.html#pcwinversion"&gt;Here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;After installing, modify the shortcut to have a +clisp after the +startup. Try out the examples from the Wikipedia page on Lisp,&lt;br /&gt;&lt;br /&gt;http://en.wikipedia.org/wiki/Lisp_%28programming_language%29&lt;br /&gt;&lt;br /&gt;aside from any Lisp homework I may assign.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-9218582439039027470?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/9218582439039027470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=9218582439039027470' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/9218582439039027470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/9218582439039027470'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/04/download-poplog-free-prolog-interpreter.html' title='Download PopLog, a Free Lisp Interpreter'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-1706420314162580411</id><published>2008-04-04T12:06:00.000-07:00</published><updated>2008-04-04T12:07:32.327-07:00</updated><title type='text'>Video Solutions for HW 7 and 8</title><content type='html'>Available &lt;a href="http://208.120.86.205/proglang/"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-1706420314162580411?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/1706420314162580411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=1706420314162580411' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/1706420314162580411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/1706420314162580411'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/04/video-solutions-for-hw-7-and-8.html' title='Video Solutions for HW 7 and 8'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-6169244411489297027</id><published>2008-04-02T09:44:00.000-07:00</published><updated>2008-04-02T12:54:09.126-07:00</updated><title type='text'>Prolog</title><content type='html'>SW-I Prolog is a Prolog that works.&lt;br /&gt;&lt;br /&gt;http://www.swi-prolog.org/&lt;br /&gt;&lt;br /&gt;we will work through the examples here:&lt;br /&gt;http://www.ling.helsinki.fi/kit/2004k/ctl272/Bangor/clbook.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-6169244411489297027?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/6169244411489297027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=6169244411489297027' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6169244411489297027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6169244411489297027'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/04/prolog.html' title='Prolog'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-133787599022825602</id><published>2008-03-19T13:04:00.000-07:00</published><updated>2008-03-19T13:05:10.297-07:00</updated><title type='text'>All About Gotos</title><content type='html'>Read this article from Knuth, "&lt;a href="http://www.google.com/search?q=%22Structured+programming+with+go+to+statements.%22&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a"&gt;Structured programming with go to statements&lt;/a&gt;"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-133787599022825602?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/133787599022825602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=133787599022825602' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/133787599022825602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/133787599022825602'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/03/all-about-gotos.html' title='All About Gotos'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-7429065540718229336</id><published>2008-03-14T11:24:00.001-07:00</published><updated>2008-03-14T13:53:53.470-07:00</updated><title type='text'>Homework: Implement a CFG</title><content type='html'>You can watch the video detailing the assignment here:&lt;br /&gt;&lt;a href="http://www.girsology.com/proglang/"&gt;http://www.girsology.com/proglang/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And as soon as Revver approves the video, I will embed the video in this post as well.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Update&lt;/span&gt;: Here it is:&lt;br /&gt;&lt;script src="http://flash.revver.com/player/1.0/player.js?mediaId:743611;affiliateId:135474;backColor:#000000;frontColor:#ffffff;gradColor:#000000;width:480;height:392;" type="text/javascript"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-7429065540718229336?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/7429065540718229336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=7429065540718229336' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/7429065540718229336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/7429065540718229336'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/03/homework-implement-cfg.html' title='Homework: Implement a CFG'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-9050855211347248115</id><published>2008-03-05T19:46:00.001-08:00</published><updated>2008-03-05T19:46:49.958-08:00</updated><title type='text'>class notes for today</title><content type='html'>&lt;p&gt;type&lt;br /&gt;colors ( red, blue, green, yellow, orage, white, black);&lt;/p&gt; &lt;p&gt;colorset = set of colors;&lt;/p&gt; &lt;p&gt;var&lt;br /&gt;set1, set2 : colorset;&lt;/p&gt; &lt;p&gt;set1 := [ red, blue, yellow ];&lt;br /&gt;set2 := set1;&lt;br /&gt;set2 := [black, blue ];&lt;/p&gt; &lt;p&gt;if (ch = 'c' or ch = 'r' or ch = 'y')&lt;/p&gt; &lt;p&gt;if (ch in ['c', 'r', 'y'])&lt;/p&gt; &lt;p&gt;if (c in colorset)&lt;/p&gt; &lt;p&gt;as bitset&lt;/p&gt; &lt;p&gt;['a' ... 'p']&lt;/p&gt; &lt;p&gt;foo()&lt;br /&gt;{&lt;br /&gt; int * p, *y;&lt;br /&gt; p = &amp;f;&lt;br /&gt; p = y;&lt;/p&gt; &lt;p&gt;cout  *p;&lt;/p&gt; &lt;p&gt;cout  p;&lt;br /&gt;p = y;&lt;br /&gt;*p = *y;&lt;br /&gt;p =: y;&lt;br /&gt;p =: f;&lt;/p&gt; &lt;p&gt;&lt;br /&gt;int * p = new int [100];&lt;/p&gt; &lt;p&gt;p = new int [100];&lt;/p&gt; &lt;p&gt;*(p + 7);&lt;br /&gt;p[7];&lt;br /&gt;cout  7[p];&lt;br /&gt;*(7 + p);&lt;/p&gt; &lt;p&gt;int &amp;amp;r = t;&lt;/p&gt; &lt;p&gt;r&lt;br /&gt;*r&lt;/p&gt; &lt;p&gt;}&lt;/p&gt; &lt;p&gt;&lt;br /&gt;Tombstone&lt;br /&gt;lock and key&lt;/p&gt; &lt;p&gt;int *y;&lt;br /&gt;foo()&lt;br /&gt;{&lt;br /&gt;Int *p;&lt;br /&gt;p = new int;&lt;br /&gt;y = p;&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;eager approach&lt;br /&gt;lazy approach&lt;/p&gt; &lt;p&gt;refernce counting&lt;br /&gt;garbage collection&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-9050855211347248115?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/9050855211347248115/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=9050855211347248115' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/9050855211347248115'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/9050855211347248115'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/03/class-notes-for-today.html' title='class notes for today'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-8671348884629029640</id><published>2008-03-05T13:06:00.000-08:00</published><updated>2008-03-05T13:08:17.962-08:00</updated><title type='text'>The Three-Register Garbage Recycler, or Nodes for Free, by David Wise</title><content type='html'>"&lt;a href="http://citeseer.ist.psu.edu/wise98threeregister.html"&gt;The Three-Register Garbage &lt;span style="font-weight: bold;"&gt;Recycler&lt;/span&gt;, or Nodes for Free&lt;/a&gt;," by David Wise. Use the links to the image.&lt;br /&gt;&lt;br /&gt;Questions to follow, or perhaps I will ask someone to present.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-8671348884629029640?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/8671348884629029640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=8671348884629029640' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8671348884629029640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8671348884629029640'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/03/three-register-garbage-recycler-or.html' title='The Three-Register Garbage Recycler, or Nodes for Free, by David Wise'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-4380132584688835441</id><published>2008-03-05T12:58:00.000-08:00</published><updated>2008-03-05T13:01:36.153-08:00</updated><title type='text'>Read this paper on Distributed Cyclic Reference Counting</title><content type='html'>Read this paper on "&lt;a href="http://citeseer.ist.psu.edu/dehne94distributed.html"&gt;Distributed Cyclic Reference Counting&lt;/a&gt;" by &lt;span class="m"&gt;   Frank Dehne, Rafael D. Lins.&lt;br /&gt;&lt;br /&gt;Questions on the paper to follow. Or perhaps I will ask someone to summarize the paper.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-4380132584688835441?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/4380132584688835441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=4380132584688835441' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/4380132584688835441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/4380132584688835441'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/03/read-this-paper-on-distributed-cyclic.html' title='Read this paper on Distributed Cyclic Reference Counting'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-2118068184413185367</id><published>2008-03-03T14:41:00.000-08:00</published><updated>2008-03-03T14:43:04.163-08:00</updated><title type='text'>Some class notes</title><content type='html'>1 4 6 8 5 32 0 -1&lt;br /&gt;1 4 6 8 5 3 2 0 -1&lt;br /&gt;1 8 2 4 5 0 6 3 -1&lt;br /&gt;int list[10];cout list[k];&lt;br /&gt;address(list[k]) = address(list[1]) + (k-lowerbound)*el_size= address(list[1])- lowerbound*el_size + k*el_size&lt;br /&gt;descriptor for arrays_________arrayelem typeindex type# of dimensionsindex upper boundindex lower boundaddress&lt;br /&gt;// using ] in place of greater than because of html%salaries = ("Cedric" =] 75000, "Perry" =]56000);$salaries{"Perry"} = 70000;$s = "Josh";$salaries{$s} = 8000;if exists $salaries{"Shelly"}delete $salaries{"Perry"};%salaries = ();&lt;br /&gt;01 EMPLOYEE-RECORD 02 EMPLOYEE-NAME  05 FIRST  PICTURE IS X(20)  05 MID  PICTURE IS X(20)  05 LAST  PICTURE IS X(20) 02 HOURLY-RATE  PICTURE IS 99V99&lt;br /&gt;01 employer-record 02 employer-name  05 FIRST  PICTURE IS X(20)  05 LAST  PICTURE IS X(20)  05 SSN  PICTURE IS X(20)&lt;br /&gt;FIRST OF EMPLOYEE-NAME OF EMPLOYEE-RECORD&lt;br /&gt;FIRST OF EMPLOYEE-RECORD&lt;br /&gt;STRUCT A{ STRUCT B {  INT X;  INT Y; } J; CHAR Z; } H;&lt;br /&gt;H.J.X&lt;br /&gt;class a{ int i; char * p; string g; a() { p = new char [60]; ~a() { delete [] p; }};&lt;br /&gt;a b, c;&lt;br /&gt;b = c;&lt;br /&gt;b.g = c.g;&lt;br /&gt;move corresponding employer-record to employee-record&lt;br /&gt;dynamic variables as discussed in the papermain(){ int x, y; int z; set z : int = x -4 in {  foo();   bar(); } bar();}&lt;br /&gt;foo(){ int a, b; use z : int in {  cout  z;&lt;br /&gt; }}&lt;br /&gt;bar(){ int q; set z : int = q -4 in {  foo();  }}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-2118068184413185367?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/2118068184413185367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=2118068184413185367' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/2118068184413185367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/2118068184413185367'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/03/some-class-notes.html' title='Some class notes'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-503626284901020803</id><published>2008-02-27T17:24:00.001-08:00</published><updated>2008-02-27T17:53:04.214-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='homework'/><title type='text'>Homework #11: Variables With Dynamic Scope</title><content type='html'>Read this article at Microsoft Research about "&lt;a href="http://research.microsoft.com/research/pubs/view.aspx?tr_id=411"&gt;Dynamic Variables&lt;/a&gt;." Do not read the Appendix to the article just yet, only the main body of the article.&lt;br /&gt;&lt;br /&gt;Answer the following questions:&lt;br /&gt;1) List two purposes for which they envision using these dynamically scoped variables?&lt;br /&gt;2) Choose one of those two, and motivate it. That is, show what the code would look like when not using dynamic variables, and then what it would look like with dynamic variables.&lt;br /&gt;3) Briefly describe the "simple" and the "novel" implementations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-503626284901020803?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/503626284901020803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=503626284901020803' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/503626284901020803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/503626284901020803'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/homework-11-variables-with-dynamic.html' title='Homework #11: Variables With Dynamic Scope'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-6842973037416211599</id><published>2008-02-25T20:05:00.000-08:00</published><updated>2008-02-25T21:18:40.910-08:00</updated><title type='text'>Homework #10</title><content type='html'>1. Read &lt;a href="http://office.microsoft.com/en-us/help/HA010873051033.aspx"&gt;this article about regular expressions in Word&lt;/a&gt;, and try the find and replace example in the article.&lt;br /&gt;&lt;br /&gt;2. Read the Wolfe article posted on blackboard, "Nesting In Ada Programs Is For The Birds," and answer the questions: &lt;span class="fnt0"&gt;Give four reasons why nesting in Ada programs is for the birds. What is the authors' suggestion?&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-6842973037416211599?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/6842973037416211599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=6842973037416211599' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6842973037416211599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6842973037416211599'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/homework-10.html' title='Homework #10'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-589578067428905682</id><published>2008-02-25T14:46:00.000-08:00</published><updated>2008-02-25T14:48:19.223-08:00</updated><title type='text'>class notes from today</title><content type='html'>some prolog:&lt;br /&gt;&lt;br /&gt;father (terach, avraham).&lt;br /&gt;father (avraham, yitzchak).&lt;br /&gt;father (avraham, yishmael).&lt;br /&gt;&lt;br /&gt;brother (A, B) :- father(C, A), father (C, B).&lt;br /&gt;&lt;br /&gt;?- brother (yitzchak, yishmael)&lt;br /&gt;True&lt;br /&gt;&lt;br /&gt;?- brother (yitzchak, Z)&lt;br /&gt;yishmael&lt;br /&gt;&lt;br /&gt;floating point:&lt;br /&gt;_______________&lt;br /&gt;sign bit&lt;br /&gt;exponent&lt;br /&gt;fraction&lt;br /&gt;&lt;br /&gt;decimal&lt;br /&gt;_____________&lt;br /&gt;part before decimal pt.&lt;br /&gt;part after decimal pt.&lt;br /&gt;1060 = 10.60&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;integers&lt;br /&gt;______________&lt;br /&gt;sign magnitude notation&lt;br /&gt;two's complement&lt;br /&gt;one's complement&lt;br /&gt;&lt;br /&gt;descriptors for:&lt;br /&gt;&lt;br /&gt;static length string&lt;br /&gt;&lt;br /&gt;--------------&lt;br /&gt; string       &lt;br /&gt; length       &lt;br /&gt; address      &lt;br /&gt;_________________&lt;br /&gt;&lt;br /&gt;limited dynamic length string&lt;br /&gt;&lt;br /&gt;_-________________________&lt;br /&gt;  limited dynamic string&lt;br /&gt; maximum length  &lt;br /&gt; current length  &lt;br /&gt; address  &lt;br /&gt;___________________________&lt;br /&gt;&lt;br /&gt;enum temperature { hot, cold, freezing };&lt;br /&gt;&lt;br /&gt;enum proximity { near = 6, cold = 7, freezing =8};&lt;br /&gt;proximity::cold&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-589578067428905682?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/589578067428905682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=589578067428905682' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/589578067428905682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/589578067428905682'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/class-notes-from-today.html' title='class notes from today'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-8722208904866866028</id><published>2008-02-14T05:09:00.001-08:00</published><updated>2008-02-14T05:09:50.835-08:00</updated><title type='text'>Some Class Notes</title><content type='html'>int x[6];&lt;br /&gt;&lt;br /&gt;int n;&lt;br /&gt;cin &amp;gt;&amp;gt; n;&lt;br /&gt;int x[n];&lt;br /&gt;&lt;br /&gt;int * x = new int [n];&lt;br /&gt;Backus-Naur Form&lt;br /&gt;BNF&lt;br /&gt;CFG - Context Free Grammar&lt;br /&gt;&lt;br /&gt;Josh&lt;br /&gt;josh&lt;br /&gt;&lt;br /&gt;int int;&lt;br /&gt;&lt;br /&gt;REAL APPLE;&lt;br /&gt;INTEGER REAL;&lt;br /&gt;REAL INTEGER;&lt;br /&gt;&lt;br /&gt;int shakespeare;&lt;br /&gt;shakespencil = 60;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;FSA which recognize regular languages&lt;br /&gt;NFA is equivalent to an FSA&lt;br /&gt;&lt;br /&gt;regular langs are closed on the Operations of union, concatenation,&lt;br /&gt;and kleene star&lt;br /&gt;&lt;br /&gt;E is the input alphabet&lt;br /&gt;G is the output alphabet&lt;br /&gt;&lt;br /&gt;PDA = Push Down Automaton&lt;br /&gt;can recognize CFLanguages,&lt;br /&gt;which can be described with CFG, BNF&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-8722208904866866028?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/8722208904866866028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=8722208904866866028' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8722208904866866028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8722208904866866028'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/some-class-notes.html' title='Some Class Notes'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-2389463475279011802</id><published>2008-02-13T17:49:00.000-08:00</published><updated>2008-02-13T17:54:08.727-08:00</updated><title type='text'>Getting Fortran to Run</title><content type='html'>I am still working on getting FORTRAN installed in the labs, for G95. In the meantime, on your own personal machines, you can try installing the &lt;a href="http://www.download.com/Silverfrost-FTN95/3000-2069_4-10491439.html"&gt;Silverfrost FTN95 compiler&lt;/a&gt;. It is free for personal use, but has an annoying screen before running any of your programs. And it integrates with the Visual Studio 2005 IDE, with makes it much easier to test out your programs. And it color codes keywords, and lets you step through the code, and so on. I tried it, and it worked with no headaches setting it up.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-2389463475279011802?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/2389463475279011802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=2389463475279011802' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/2389463475279011802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/2389463475279011802'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/getting-fortran-to-run.html' title='Getting Fortran to Run'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-2306458575526149923</id><published>2008-02-12T07:04:00.000-08:00</published><updated>2008-02-24T19:05:46.131-08:00</updated><title type='text'>HW #8, with video intro</title><content type='html'>Not to be confused with homework #7.&lt;br /&gt;&lt;br /&gt;#8:&lt;br /&gt;Using VBA for Excel, implement the first FSA from assignment #5. On the spreadsheet, include a formal description of the FSA. This includes the transition function delta. Rather than using Gotos, keep a variable which maintains the present state, and look up the appropriate transition to the next state, based on the present state and the input, from that lookup table on the Excel worksheet.&lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://media.revver.com/qt;sharer=135474;download/672260.mov"&gt;download the video here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;embed type="video/quicktime" src="http://media.revver.com/qt;sharer=135474/672260.mov" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect" cache="False" autoplay="False" height="376" width="480"&gt;&lt;/embed&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-2306458575526149923?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/2306458575526149923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=2306458575526149923' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/2306458575526149923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/2306458575526149923'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/hw-8-with-video-intro.html' title='HW #8, with video intro'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-6240933607387494410</id><published>2008-02-11T14:41:00.000-08:00</published><updated>2008-02-11T14:42:28.791-08:00</updated><title type='text'>Class Notes</title><content type='html'>LISP&lt;br /&gt;(A B C D)&lt;br /&gt;(A (B C) D)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Three operations closed on regular languages&lt;br /&gt;Union&lt;br /&gt;Concatenation&lt;br /&gt;Kleene star&lt;br /&gt;Kleene plus&lt;br /&gt;&lt;br /&gt;A = { boy, girl}&lt;br /&gt;B = {bad, good}&lt;br /&gt;&lt;br /&gt;A.B {boybad, girlbad, boygood, girlgood}&lt;br /&gt;&lt;br /&gt;C = {boy}&lt;br /&gt;A* = { epsilon, boy, boyboy, boyboyboy, girl, girlboy, boygirl, girlgirlgirl, girlgirlboy&lt;br /&gt;&lt;br /&gt;C* = { w^n | n &amp;gt;= 0, w is an element in C}&lt;br /&gt;&lt;br /&gt;ab*a(a|b)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;((a|b|c).a)+&lt;br /&gt;((a|b|c).a). ((a|b|c).a)*&lt;br /&gt;&lt;br /&gt;1 + 2&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-6240933607387494410?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/6240933607387494410/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=6240933607387494410' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6240933607387494410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6240933607387494410'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/class-notes.html' title='Class Notes'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-8140374698680853463</id><published>2008-02-10T21:17:00.000-08:00</published><updated>2008-02-24T19:06:43.688-08:00</updated><title type='text'>HW #9: More Fortran</title><content type='html'>Due Feb 13.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.cisl.ucar.edu/tcg/consweb/Fortran90/F90Tutorial/tutorial.html"&gt;In the tutorial&lt;/a&gt;, work through hands-on-exercise 2.2 and 2.3. For the former, you might find this video of some help.&lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://media.revver.com/qt;sharer=135474;download/670522.mov"&gt;download the video here&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;embed type="video/quicktime" src="http://media.revver.com/qt;sharer=135474/670522.mov" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect" cache="False" autoplay="False" height="376" width="480"&gt;&lt;/embed&gt;&lt;br /&gt;&lt;br /&gt;The purpose of exercise 2.2 is to give you some experience reading a real Fortran program and understanding it to the level of being able to make some simple modifications. In exercise 2.3, we are introduced to internal functions, which are limitations of the scope of functions to within the program. This will help you apply what you read, to modify program 2.2 further. And more than that, it will give you practice in writing functions, and understanding in how they take in their parameters and how they give back their return value. Part of the assignment is also to give me the meaning of "intent" in this context. Google is your friend in this regard.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-8140374698680853463?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/8140374698680853463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=8140374698680853463' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8140374698680853463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8140374698680853463'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/hw-9-more-fortran.html' title='HW #9: More Fortran'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-3270909008684299890</id><published>2008-02-10T17:09:00.000-08:00</published><updated>2008-02-24T19:07:38.386-08:00</updated><title type='text'>Homework #7, 8</title><content type='html'>We continue with the Excel VBA assignments, and will be implementing various finite state automata (FSA). To be announced, discussed in class on Monday.&lt;br /&gt;&lt;br /&gt;#7: Due Wednesday, Feb 13&lt;br /&gt;Using VBA for Excel, implement the first FSA from assignment #5. Read the input string from cell B1. Print "accept" or "reject" in C1. Print the sequence of states in cell A4 and down (A5, A6, etc). Use gotos and goto labels to represent the states. Use the MID function to extract letters sequentially from the input string.&lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://media.revver.com/qt;sharer=135474;download/668779.mov"&gt;download the video here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;embed type="video/quicktime" src="http://media.revver.com/qt;sharer=135474/668779.mov" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect" cache="False" autoplay="False" height="376" width="480"&gt;&lt;/embed&gt;&lt;br /&gt;&lt;br /&gt;#8: Due Monday, Feb 18&lt;br /&gt;Using VBA for Excel, implement the first FSA from assignment #5. On the spreadsheet, include a formal description of the FSA. This includes the transition function delta. Rather than using Gotos, keep a variable which maintains the present state, and look up the appropriate transition to the next state, based on the present state and the input, from that lookup table on the Excel worksheet.&lt;br /&gt;&lt;br /&gt;Video to come.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-3270909008684299890?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/3270909008684299890/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=3270909008684299890' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/3270909008684299890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/3270909008684299890'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/homework-7-8.html' title='Homework #7, 8'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-6735269801751692183</id><published>2008-02-07T16:28:00.000-08:00</published><updated>2008-02-24T19:08:36.487-08:00</updated><title type='text'>Homework #6 Solution</title><content type='html'>Here is a walkthrough of installing the G95 FORTRAN compiler and getting the Hello World program up and running.&lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://media.revver.com/qt;sharer=135474;download/662839.mov"&gt;download the video here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;embed type="video/quicktime" src="http://media.revver.com/qt;sharer=135474/662839.mov" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect" cache="False" autoplay="False" height="376" width="480"&gt;&lt;/embed&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-6735269801751692183?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/6735269801751692183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=6735269801751692183' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6735269801751692183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6735269801751692183'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/homework-6-solution.html' title='Homework #6 Solution'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-7072584267073983855</id><published>2008-02-06T19:19:00.001-08:00</published><updated>2008-02-06T19:19:53.245-08:00</updated><title type='text'>Homework #5</title><content type='html'>In the Sipser book, and up on Blackboard. Look at the FSAs and answer the questions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-7072584267073983855?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/7072584267073983855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=7072584267073983855' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/7072584267073983855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/7072584267073983855'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/homework-5.html' title='Homework #5'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-8916284563290742306</id><published>2008-02-06T19:14:00.000-08:00</published><updated>2008-02-24T19:09:57.264-08:00</updated><title type='text'>Homework #3 Solution</title><content type='html'>&lt;embed type="video/quicktime" src="http://media.revver.com/qt;sharer=135474/659632.mov" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect" cache="False" autoplay="False" height="376" width="480"&gt;&lt;/embed&gt;&lt;br /&gt;&lt;br /&gt;See the assignment definition &lt;a href="http://programminglanguages.blogspot.com/2008/02/homeworks-3-4.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://media.revver.com/qt;sharer=135474;download/659632.mov"&gt;download the video here.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-8916284563290742306?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/8916284563290742306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=8916284563290742306' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8916284563290742306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8916284563290742306'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/homework-3-solution.html' title='Homework #3 Solution'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-4732881238356313479</id><published>2008-02-06T14:44:00.000-08:00</published><updated>2008-02-06T17:27:10.251-08:00</updated><title type='text'>Some formal definitions from class about FSA</title><content type='html'>A finite automoton is a 5-tuple (Q, E, delta, q0, F)&lt;br /&gt;(We are using E for Sigma)&lt;br /&gt;&lt;br /&gt;1. Q is a set of states&lt;br /&gt;2. E is set called the alphabet&lt;br /&gt;3. delta: Q X E -&gt; Q is the transition function&lt;br /&gt;4. q0 an element in Q is the start state&lt;br /&gt;5. F subset of Q is the set of accept states&lt;br /&gt;&lt;br /&gt;If A is the set of all strings accepted by FSM M, then Machine M recognizes A; could say accepts A. A is the language of machine M.&lt;br /&gt;&lt;br /&gt;Also, we finished chapter 2's coverage of the FORTRANs, in the Concepts of Programming Languages book.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-4732881238356313479?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/4732881238356313479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=4732881238356313479' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/4732881238356313479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/4732881238356313479'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/some-formal-definitions-from-class.html' title='Some formal definitions from class about FSA'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-952852855908247230</id><published>2008-02-06T13:51:00.000-08:00</published><updated>2008-02-06T19:14:09.804-08:00</updated><title type='text'>FORTRAN Assignment 1 (HW Assignment 6)</title><content type='html'>Download G95 (sidebar) and install it on your computer. Name the files *.f90 to be able to use FORTRAN 90 syntax. If you name it *.f, you will have annoying restrictions, such as the first 6 characters on a line being reserved. Read through the &lt;a href="http://www.cisl.ucar.edu/tcg/consweb/Fortran90/F90Tutorial/tutorial.html"&gt;beginning of the tutorial, here&lt;/a&gt;. Specifically, start with Exercises and Examples, and do Exercise 2.1&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-952852855908247230?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/952852855908247230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=952852855908247230' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/952852855908247230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/952852855908247230'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/fortran-assignment-1.html' title='FORTRAN Assignment 1 (HW Assignment 6)'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-8445196501784654894</id><published>2008-02-04T15:00:00.000-08:00</published><updated>2008-02-04T15:04:21.606-08:00</updated><title type='text'>Homeworks #3, 4</title><content type='html'>#3: Due this Wednesday, Feb 6&lt;br /&gt;In Visual Basic for Applications for Excel, create a macro that puts the numbers 1 through 13 in cells A1 through A13. If possible, do so using the functionality in which you can drag to extend an existing pattern of numbers. Copy the text of the VBA macro which was created, and submit that.&lt;br /&gt;&lt;br /&gt;#4: Due next Monday, Feb 11&lt;br /&gt;Write two UDFs (User Defined Functions), with meaningful names of your own choosing. The first should take in X and Y and return X times Y. The second should take in X and return X factorial.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-8445196501784654894?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/8445196501784654894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=8445196501784654894' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8445196501784654894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/8445196501784654894'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/homeworks-3-4.html' title='Homeworks #3, 4'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-466983077421480576</id><published>2008-02-03T21:48:00.000-08:00</published><updated>2008-02-04T15:06:55.829-08:00</updated><title type='text'>Class 2</title><content type='html'>First:&lt;br /&gt;From &lt;a href="http://programminglanguages.blogspot.com/2006/01/class-i-preliminaries.html"&gt;class 1&lt;/a&gt;: go over readability, writeability.&lt;br /&gt;&lt;br /&gt;Then:&lt;br /&gt;&lt;a href="http://programminglanguages.blogspot.com/2006/02/class-ii-some-early-history.html"&gt;Class 2&lt;/a&gt; from last time. Go over some of the features of language. Get to the beginning of FORTRAN. Much better reading than presenting, so it is a good reason to just get the book.&lt;br /&gt;&lt;br /&gt;And introduction to a bit of VBA for Excel.&lt;br /&gt;&lt;br /&gt;Then, beginning of other book. What is a Finite State Automaton? An state, a start state, an accept state, a transition, a state transition table. What is the language recognized by a specific FSA?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-466983077421480576?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/466983077421480576/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=466983077421480576' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/466983077421480576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/466983077421480576'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/02/review-from-class-1-go-over-readability.html' title='Class 2'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-7082503418007729037</id><published>2008-01-31T18:29:00.001-08:00</published><updated>2008-01-31T18:30:12.860-08:00</updated><title type='text'>How to drop files into the Digital Dropbox</title><content type='html'>and send them to the instructor.&lt;br /&gt;&lt;br /&gt;&lt;script src="http://flash.revver.com/player/1.0/player.js?mediaId:649250;affiliateId:135474;width:480;height:392" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;I'll go over this in class.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-7082503418007729037?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/7082503418007729037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=7082503418007729037' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/7082503418007729037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/7082503418007729037'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/01/how-to-drop-files-into-digital-dropbox.html' title='How to drop files into the Digital Dropbox'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-593362451918028317</id><published>2008-01-30T19:03:00.000-08:00</published><updated>2008-01-30T19:06:07.417-08:00</updated><title type='text'>Homework #1, #2</title><content type='html'>1. Give a short evaluation (a few sentences) of Stroustrup's paper on &lt;a href="http://www.research.att.com/%7Ebs/whitespace98.pdf"&gt;Generalized Operator Overloading for C++ 2000 &lt;/a&gt;in terms of readability and writability.&lt;br /&gt;&lt;br /&gt;Due approximately Monday, Feb 4.&lt;br /&gt;&lt;br /&gt;2. Take some programming language you know and discuss its positive and negative aspects in terms readability, writability, and reliability. (Two or three paragraphs.)&lt;br /&gt;&lt;br /&gt;Due approximately Monday, Feb 6.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-593362451918028317?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/593362451918028317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=593362451918028317' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/593362451918028317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/593362451918028317'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/01/homework-1-2.html' title='Homework #1, #2'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-4124410933767667122</id><published>2008-01-30T14:43:00.000-08:00</published><updated>2008-01-30T12:31:48.680-08:00</updated><title type='text'>Welcome to the Programming Languages course</title><content type='html'>Here is &lt;a href="http://cs.uccs.edu/%7Erws/"&gt;a link to Robert Sebesta's website&lt;/a&gt;. He is the author of the main book for the class, and on that website he has a bunch of slides, which we may make use of.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.amazon.com/gp/product/images/0201752956/sr=8-1/qid=1200351643/ref=dp_image_0/103-4582428-0631801?ie=UTF8&amp;amp;n=283155&amp;amp;s=books&amp;amp;qid=1200351643&amp;amp;sr=8-1" target="AmazonHelp" onclick="return amz_js_PopWin(this.href,'AmazonHelp','width=700,height=600,resizable=1,scrollbars=1,toolbar=0,status=1');"&gt;&lt;img src="http://ecx.images-amazon.com/images/I/412NQSG2XML._AA240_.jpg" id="prodImage" alt="Concepts of Programming Languages (5th Edition)" border="0" height="240" width="240" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here is a link to the book on Amazon. It is called &lt;a href="http://www.amazon.com/Concepts-Programming-Languages-Robert-Sebesta/dp/0201752956/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1200351643&amp;amp;sr=8-1"&gt;&lt;b class="sans"&gt;Concepts of Programming Languages (5th Edition)&lt;/b&gt;&lt;/a&gt;&lt;span class="sans"&gt;. Please note that we are using the &lt;span style="font-weight: bold;"&gt;5th edition&lt;/span&gt;. It costs $109 new, or actually $2 new and 39 cents used if you follow the link to "used and new," something I would advise.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We will hopefully get Blackboard up and running for this course soon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-4124410933767667122?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/4124410933767667122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=4124410933767667122' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/4124410933767667122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/4124410933767667122'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/01/httpcs.html' title='Welcome to the Programming Languages course'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-6697109450572282896</id><published>2008-01-29T10:50:00.000-08:00</published><updated>2008-01-29T10:51:23.228-08:00</updated><title type='text'>Regular expressions</title><content type='html'>For later.&lt;br /&gt;&lt;br /&gt;Here are some interesting articles on wildcards and regular expression matching. We might cover some of this. Don't worry if you can't understand this just yet.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://office.microsoft.com/en-us/help/HA010873051033.aspx"&gt;Add Power to Word Searches with regular expressions&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;this is somewhat powerful, but it is fairly easy to encounter limitations to its power.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;a href="http://office.microsoft.com/en-us/help/HA010873041033.aspx"&gt;Putting Regular Expressions to Work in Word&lt;/a&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;A follow up article. We might try going through these examples.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;a href="http://www.dailydoseofexcel.com/archives/2005/08/13/pattern-matching/"&gt;Regular Expressions in Excel&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/2k3te2cs%28VS.80%29.aspx"&gt;Regular Expressions in Visual Studio&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-6697109450572282896?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/6697109450572282896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=6697109450572282896' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6697109450572282896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/6697109450572282896'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2008/01/regular-expressions.html' title='Regular expressions'/><author><name>joshwaxman</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='15' src='http://1.bp.blogspot.com/_xWFKiPJDO_I/Si1IDomPqUI/AAAAAAAACb0/B8g2Fk--W48/S220/rablag2.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114855741245824540</id><published>2006-05-25T04:43:00.000-07:00</published><updated>2006-05-26T10:02:11.273-07:00</updated><title type='text'>Review - A Work In Progress</title><content type='html'>Conceptual Summary - In Reverse Order&lt;br /&gt;Here are some concepts to focus on in reviewing.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Exception Handling&lt;/span&gt;:&lt;br /&gt;Dynamic vs static binding of exception handling. How is dynamic more flexible? How is static better?&lt;br /&gt;Scoping and propagation.&lt;br /&gt;How does Java improve over C++'s exception handling? How does the finally clause improve? How about the OO nature of Java? The handling of built in exceptions not explicitly raised by the user?&lt;br /&gt;How can a lang without specific features for exception handling handle errors? what are drawbacks of this approach?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Concurrency&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;What is cooperative, competitive synchronization?&lt;br /&gt;Why do we need them?&lt;br /&gt;How does a binary semaphore help with competitve synchronization?&lt;br /&gt;How does a regular semaphore help with competitve synchronization?&lt;br /&gt;what are the inner workings of wait and release for semaphores?&lt;br /&gt;What is a monitor?&lt;br /&gt;What is message passing? Rendezvous?&lt;br /&gt;How can we use message passing to implement a binary semaphore? A monitor?&lt;br /&gt;What mechanism is used for concurrency in Ada 83? Ada 95? Java?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Interactive Fiction&lt;/span&gt;:&lt;br /&gt;Why is an object oriented language well suited for programming interactive fiction? Why is a natural language based programming language?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Implementing Subprograms&lt;/span&gt;:&lt;br /&gt;FORTRAN 77 with no recursion vs ALGOL and on.&lt;br /&gt;&lt;br /&gt;FORTRAN 77:&lt;br /&gt;How handle activation records, access to nonlocals (but not globals either), transfer of control. Why does this present a problem in terms of recursion?&lt;br /&gt;&lt;br /&gt;ALGOL:&lt;br /&gt;with stacked activation records. how does this allow for recursion?&lt;br /&gt;What does an activation record look like.&lt;br /&gt;What is the difference between the dynamic and static link. Why is a static link chain O(n)? What is the idea behind a display, and how can this minimize lookup?&lt;br /&gt;Where scoping is static, how does a pair (depth, offset) work to identify a nonlocal? Why can this not work for dynamic scoping, and what would we need to store instead?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;LISP&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;How would you write a LISP program to return N + 3?&lt;br /&gt;To get the length of a list?&lt;br /&gt;What is car? cdr? caadar? If I gave you a list, could you tell me caadar of that list?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Guarded Commands&lt;/span&gt;:&lt;br /&gt;The od and fi constructs - how they work. How are guarded commands useful in terms of ensuring program accuracy?&lt;br /&gt;&lt;br /&gt;How are guarded commands useful in concurrency to acheiving nondeterminism?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Subprograms&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;in, out, inout parameters.&lt;br /&gt;what are: pass by value, pass by result, pass by value-result,&lt;br /&gt;pass by reference?&lt;br /&gt;positional parameters vs. keyword parameters. default parameters.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Iterative Statements&lt;/span&gt;&lt;br /&gt;Difference between pretest and posttest,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Control Structures&lt;/span&gt;:&lt;br /&gt;Nothing&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PROLOG&lt;/span&gt;:&lt;br /&gt;Facts, goals, and rules.&lt;br /&gt;the Terach example. How would you write a rule for ancestor?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Data types&lt;/span&gt;:&lt;br /&gt;arrays: static, fixed-stack dynamic, stack-dynamic, heap-dynamic.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Functional Programming Languages&lt;/span&gt;:&lt;br /&gt;What is a higher order function? What is mapcar?&lt;br /&gt;In Haskell, what is an infinite list? Lazy evaluation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114855741245824540?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114855741245824540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114855741245824540' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114855741245824540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114855741245824540'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/review-work-in-progress.html' title='Review - A Work In Progress'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114841340773620459</id><published>2006-05-23T12:43:00.000-07:00</published><updated>2006-05-23T12:43:27.746-07:00</updated><title type='text'>More slides on functional langs</title><content type='html'>http://www.cs.ndsu.nodak.edu/~slator/html/CS372/sebesta-pdf/14.pdf&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114841340773620459?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114841340773620459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114841340773620459' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114841340773620459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114841340773620459'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/more-slides-on-functional-langs.html' title='More slides on functional langs'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114840441425318076</id><published>2006-05-23T10:13:00.000-07:00</published><updated>2006-05-23T10:13:34.266-07:00</updated><title type='text'>Slides for Functional Programming Langs</title><content type='html'>http://www.csee.umbc.edu/331/fall00/nicholas/lectures/fininfp.ppt&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114840441425318076?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114840441425318076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114840441425318076' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114840441425318076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114840441425318076'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/slides-for-functional-programming.html' title='Slides for Functional Programming Langs'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114799083965366157</id><published>2006-05-18T15:20:00.000-07:00</published><updated>2006-05-18T15:20:39.663-07:00</updated><title type='text'>Exception Handling</title><content type='html'>http://www.cs.ndsu.nodak.edu/~slator/html/CS372/sebesta-pdf/13.pdf&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114799083965366157?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114799083965366157/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114799083965366157' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114799083965366157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114799083965366157'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/exception-handling.html' title='Exception Handling'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114772184065695366</id><published>2006-05-15T12:36:00.000-07:00</published><updated>2006-05-15T12:37:20.663-07:00</updated><title type='text'>Read this White Paper</title><content type='html'>by Graham Nelson on Inform and programming in English&lt;br /&gt;http://www.inform-fiction.org/I7Downloads/Documents/WhitePaper.pdf&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114772184065695366?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114772184065695366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114772184065695366' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114772184065695366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114772184065695366'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/read-this-white-paper.html' title='Read this White Paper'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114772180168309444</id><published>2006-05-15T12:33:00.000-07:00</published><updated>2006-05-15T12:36:41.693-07:00</updated><title type='text'>Read this on Java synchronization</title><content type='html'>http://www.ccs.neu.edu/home/kenb/g712/res/tutorial.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114772180168309444?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114772180168309444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114772180168309444' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114772180168309444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114772180168309444'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/read-this-on-java-synchronization.html' title='Read this on Java synchronization'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114719403871383134</id><published>2006-05-09T10:00:00.000-07:00</published><updated>2006-05-09T10:00:38.713-07:00</updated><title type='text'>GNAT for Mac</title><content type='html'>Check it out here:&lt;br /&gt;&lt;br /&gt;http://www.macada.org/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114719403871383134?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114719403871383134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114719403871383134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114719403871383134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114719403871383134'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/gnat-for-mac.html' title='GNAT for Mac'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114719397773032483</id><published>2006-05-09T09:58:00.000-07:00</published><updated>2006-05-09T09:59:37.743-07:00</updated><title type='text'>Instructions on Setting Up Ada for DOS</title><content type='html'>OK, I got a simple compilation working.&lt;br /&gt;Go to this ftp site (open in Firefox or IE)&lt;br /&gt;ftp://ftp.cs.kuleuven.ac.be/pub/Ada-Belgium/mirrors/gnu-ada/3.15p/winnt/&lt;br /&gt;&lt;br /&gt;and download the gnat-3.15p-nt.exe file. running this file will install the ada compiler.&lt;br /&gt;we do not really need an IDE (integrated development environment). we can start with just command line.&lt;br /&gt;it should install to c:\gnat&lt;br /&gt;inside c:\gnat\bin, there are a bunch of executables, but all are runnable from the one program gnat&lt;br /&gt;so type gnat and you will see the options.&lt;br /&gt;copy to that directory ..\examples\hello.ada, so that you need not worry about other directories.&lt;br /&gt;hello.ada is the source program.&lt;br /&gt;&lt;br /&gt;Then:&lt;br /&gt;gnat compile hello.adb&lt;br /&gt;(this will create a file hello.ali)&lt;br /&gt;gnat bind -x hello.ali&lt;br /&gt;(then we need to link)&lt;br /&gt;gnat link hello.ali&lt;br /&gt;(and finally will run the program)&lt;br /&gt;hello&lt;br /&gt;&lt;br /&gt;the output will be:&lt;br /&gt;Hello World. Welcome to GNAT&lt;br /&gt;&lt;br /&gt;similar steps are available for gnat on other platforms&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114719397773032483?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114719397773032483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114719397773032483' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114719397773032483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114719397773032483'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/instructions-on-setting-up-ada-for-dos.html' title='Instructions on Setting Up Ada for DOS'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114677155388662151</id><published>2006-05-04T12:37:00.000-07:00</published><updated>2006-05-04T12:39:13.900-07:00</updated><title type='text'>Further Ada Assignment</title><content type='html'>Work through the examples on &lt;a href="http://linux.disco.unimib.it/%7Eferretti/lp/ada_task.html"&gt;this web site&lt;/a&gt; to familiarize yourself with concurrency in Ada.&lt;br /&gt;&lt;br /&gt;http://linux.disco.unimib.it/~ferretti/lp/ada_task.html&lt;br /&gt;&lt;br /&gt;Also read pgs 292 - 300 in the book, which covers much related info.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114677155388662151?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114677155388662151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114677155388662151' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114677155388662151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114677155388662151'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/further-ada-assignment.html' title='Further Ada Assignment'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114676348934030168</id><published>2006-05-04T10:24:00.000-07:00</published><updated>2006-05-04T10:24:49.340-07:00</updated><title type='text'>Assignment</title><content type='html'>Download &lt;a href="http://www.thefreecountry.com/compilers/ada.shtml"&gt;an Ada compiler&lt;/a&gt;, install it, and write a hello world program.&lt;br /&gt;We are going to write a concurrent program in Ada.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114676348934030168?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114676348934030168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114676348934030168' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114676348934030168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114676348934030168'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/assignment.html' title='Assignment'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114676329770435795</id><published>2006-05-04T10:21:00.000-07:00</published><updated>2006-05-04T10:21:37.713-07:00</updated><title type='text'>Lecture Notes for Concurrency</title><content type='html'>Available as a &lt;a href="http://www-static.cc.gatech.edu/classes/cs3411a_99_winter/lec25.pdf"&gt;pdf here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114676329770435795?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114676329770435795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114676329770435795' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114676329770435795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114676329770435795'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/lecture-notes-for-concurrency.html' title='Lecture Notes for Concurrency'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114676235910764376</id><published>2006-05-04T10:00:00.000-07:00</published><updated>2006-05-04T10:05:59.136-07:00</updated><title type='text'>Definition of Race hazard (condition)</title><content type='html'>at &lt;a href="http://en.wikipedia.org/wiki/Race_condition"&gt;wikipedia&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;A &lt;b&gt;race hazard&lt;/b&gt; (or &lt;b&gt;race condition&lt;/b&gt;) is a &lt;a href="http://en.wikipedia.org/wiki/Flaw" title="Flaw"&gt;flaw&lt;/a&gt; in a &lt;a href="http://en.wikipedia.org/wiki/System" title="System"&gt;system&lt;/a&gt; or process where the output exhibits unexpected critical dependence on the relative &lt;a href="http://en.wikipedia.org/wiki/Timing" title="Timing"&gt;timing&lt;/a&gt; of &lt;a href="http://en.wikipedia.org/wiki/Event" title="Event"&gt;events&lt;/a&gt;. The term originates with the idea of two &lt;a href="http://en.wikipedia.org/wiki/Signal_%28information_theory%29" title="Signal (information theory)"&gt;signals&lt;/a&gt; racing each other to influence the &lt;a href="http://en.wikipedia.org/wiki/Output" title="Output"&gt;output&lt;/a&gt; first.&lt;/p&gt;  &lt;p&gt;Race hazards occur in poorly-designed &lt;a href="http://en.wikipedia.org/wiki/Electronics" title="Electronics"&gt;electronics&lt;/a&gt; systems, especially &lt;a href="http://en.wikipedia.org/wiki/Logic" title="Logic"&gt;logic&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Electrical_network" title="Electrical network"&gt;circuits&lt;/a&gt;, but they may also arise in &lt;a href="http://en.wikipedia.org/wiki/Computer" title="Computer"&gt;computer&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Software" title="Software"&gt;software&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt; &lt;p&gt;...&lt;br /&gt;&lt;/p&gt; &lt;h2&gt;Computing&lt;/h2&gt;  &lt;p&gt;Race hazards may arise in software, especially when communicating between separate processes or threads of execution.&lt;/p&gt;  &lt;p&gt;Here is a simple example:&lt;/p&gt;  &lt;p&gt;Let us assume that two threads T1 and T2 each want to increment the value of a global integer by one.&lt;/p&gt;  &lt;p&gt;If the two threads run simultaneously without locking or synchronization, the outcome of the operation could be wrong&lt;/p&gt;  &lt;ol&gt; &lt;li&gt;Integer i = 0;&lt;/li&gt;&lt;li&gt;T1 reads the value of i into a register : 0&lt;/li&gt;&lt;li&gt;T2 reads the value of i into a register : 0&lt;/li&gt;&lt;li&gt;T1 increments the value of i : 0 + 1 = 1&lt;/li&gt;&lt;li&gt;T2 increments the value of i : 0 + 1 = 1&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;The final value of i is 1 instead of the expected result of 2.&lt;/p&gt;  &lt;p&gt;&lt;br /&gt;For another example, consider the following two tasks, in &lt;a href="http://en.wikipedia.org/wiki/Pseudocode" title="Pseudocode"&gt;pseudocode&lt;/a&gt;:&lt;/p&gt;  &lt;pre&gt;global integer A = 0;&lt;br /&gt;&lt;br /&gt;task Received() &lt;br /&gt;{&lt;br /&gt;   A = A + 1;&lt;br /&gt;   print "RX";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;task Timeout() // Print only the even numbers&lt;br /&gt;{&lt;br /&gt;   if (A is divisible by 2)&lt;br /&gt;   {&lt;br /&gt;       print A;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;task Received is activated whenever an interrupt is received from the serial controller, and increments the value of A.&lt;/p&gt;  &lt;p&gt;task Timeout occurs every second. If A is divisible by 2, it prints A. Output would look something like:&lt;/p&gt;  &lt;pre&gt;0&lt;br /&gt;0&lt;br /&gt;0&lt;br /&gt;RX&lt;br /&gt;RX&lt;br /&gt;2&lt;br /&gt;RX&lt;br /&gt;RX&lt;br /&gt;4&lt;br /&gt;4&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;Now consider this chain of events, which might occur next:&lt;/p&gt;  &lt;ol&gt; &lt;li&gt;timeout occurs, activating task &lt;tt&gt;Timeout&lt;/tt&gt;&lt;/li&gt;&lt;li&gt;task &lt;tt&gt;Timeout&lt;/tt&gt; evaluates &lt;code&gt;A&lt;/code&gt; and finds it is divisible by 2, so elects to execute the "print A" next.&lt;/li&gt;&lt;li&gt;data is received on the serial port, causing an interrupt and a switch to task &lt;tt&gt;Received&lt;/tt&gt;&lt;/li&gt;&lt;li&gt;task &lt;tt&gt;Received&lt;/tt&gt; runs to completion, incrementing A and printing "RX"&lt;/li&gt;&lt;li&gt;control returns to task &lt;tt&gt;Timeout&lt;/tt&gt;&lt;/li&gt;&lt;li&gt;task timeout executes print A, using the current value of A, which is 5.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Mutual_exclusion" title="Mutual exclusion"&gt;Mutexes&lt;/a&gt; are used to address this problem in concurrent programming.&lt;/p&gt;  &lt;p&gt;In filesystems, &lt;a href="http://en.wikipedia.org/wiki/File_lock" title="File lock"&gt;File locking&lt;/a&gt; provides a commonly-used solution. A more cumbersome remedy involves reorganizing the system in such a way that one unique process (running a &lt;a href="http://en.wikipedia.org/wiki/Daemon_%28computer_software%29" title="Daemon (computer software)"&gt;daemon&lt;/a&gt; or the like) has exclusive access to the file, and all other processes that need to access the data in that file do so only via interprocess communication with that one process (which of course requires synchronization at the process level).&lt;/p&gt;  &lt;p&gt;In networking, consider a distributed chat network like &lt;a href="http://en.wikipedia.org/wiki/Internet_relay_chat" title="Internet relay chat"&gt;IRC&lt;/a&gt;, where a user acquires channel-operator privileges in any channel he starts. If two users on different servers, on different ends of the same network, try to start the same-named channel at the same time, each user's respective server will grant channel-operator privileges to each user, since neither server will yet have received the other server's signal that it has allocated that channel. (Note that this problem has been largely &lt;a href="http://en.wikipedia.org/wiki/Internet_relay_chat#Abuse_prevention:_timestamping_vs._nick.2Fchannel_delay_protocol" title="Internet relay chat"&gt;solved&lt;/a&gt; by various IRC server implementations.)&lt;/p&gt;  &lt;p&gt;In this case of a race hazard, the concept of the "shared &lt;a href="http://en.wikipedia.org/wiki/Resource_%28computer_science%29" title="Resource (computer science)"&gt;resource&lt;/a&gt;" covers the state of the network (what channels exist, as well as what users started them and therefore have what privileges), which each server can freely change as long as it signals the other servers on the network about the changes so that they can update their conception of the state of the network. However, the &lt;a href="http://en.wikipedia.org/wiki/Latency_%28engineering%29" title="Latency (engineering)"&gt;latency&lt;/a&gt; across the network makes possible the kind of race condition described. In this case, heading off race conditions by imposing a form of control over access to the shared resource—say, appointing one server to control who holds what privileges—would mean turning the distributed network into a centralized one (at least for that one part of the network operation). Where users find such a solution unacceptable, a pragmatic solution can have the system 1) recognize when a race hazard has occurred; and 2) repair the ill effects.&lt;/p&gt;  &lt;p&gt;A race condition exemplifies an &lt;a href="http://en.wikipedia.org/wiki/Anti-pattern" title="Anti-pattern"&gt;anti-pattern&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;A particularly poignant example of a race condition was one of the problems that plagued the &lt;a href="http://en.wikipedia.org/wiki/Therac-25" title="Therac-25"&gt;Therac-25&lt;/a&gt; (a &lt;a href="http://en.wikipedia.org/wiki/Life-critical_system" title="Life-critical system"&gt;Life-critical system&lt;/a&gt;) accidents. Another example is the Energy Management System used by Ohio-based FirstEnergy Corp., that had a race condition in the alarm subsystem; when three sagging power lines were tripped simultaneously, the condition prevented alerts being raised to the monitoring technicians. This software flaw eventually led to the &lt;a href="http://en.wikipedia.org/wiki/2003_North_America_blackout" title="2003 North America blackout"&gt;North American Blackout of 2003&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114676235910764376?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114676235910764376/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114676235910764376' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114676235910764376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114676235910764376'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/definition-of-race-hazard-condition.html' title='Definition of Race hazard (condition)'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114660598865309276</id><published>2006-05-02T14:39:00.000-07:00</published><updated>2006-05-02T14:39:48.666-07:00</updated><title type='text'>Concurrency</title><content type='html'>Concurrency&lt;br /&gt;&lt;br /&gt;program level&lt;br /&gt;subprogram level&lt;br /&gt;statement level&lt;br /&gt;instruction level&lt;br /&gt;&lt;br /&gt;first computers: general, i, o&lt;br /&gt;early 60's: multiple processors - program level&lt;br /&gt;Now: multi-processor: single instruction multiple data - eg. on vectors&lt;br /&gt;mult instruc mult data: each general processor has own data. can be a distributed system&lt;br /&gt;&lt;br /&gt;physical vs. logical concurrency&lt;br /&gt;thread of control&lt;br /&gt;coroutines - quasi-concurrent, because single thread of control&lt;br /&gt;&lt;br /&gt;physical, logical concurrency - have, or can imagine have, different threads of control&lt;br /&gt;&lt;br /&gt;task: a unit that can be in concurrent execution with other such units&lt;br /&gt;vs. subprogram:&lt;br /&gt;can be implicitly started rather than explicitly called&lt;br /&gt;when task invoked, need not wait for return from that task (asynchronous)&lt;br /&gt;on return, may not necessarily return control to the caller&lt;br /&gt;&lt;br /&gt;Communication w other tasks&lt;br /&gt;shared nonlocal variables&lt;br /&gt;message passing&lt;br /&gt;parameters&lt;br /&gt;if no such communication, called disjoint&lt;br /&gt;often used for simulations, so to coordinate need communication&lt;br /&gt;&lt;br /&gt;Synchronization:&lt;br /&gt;mechanism controlling order of task execution&lt;br /&gt;coop vs competition.&lt;br /&gt;cooperative when A must wait for B, in order for task A to continue sensibly&lt;br /&gt;Competitive: both require same resource which cannot be used simultaneously&lt;br /&gt;if A needs to access shared location x, which B is using, B must wait.&lt;br /&gt;&lt;br /&gt;famous cooperation: producer/consumer problem. from OS&lt;br /&gt;one unit produces, the other consumes.place in, take from a buffer.&lt;br /&gt;cannot take from buffer if empty.&lt;br /&gt;&lt;br /&gt;competitive:&lt;br /&gt;int total = 3;&lt;br /&gt;A: add 1 to total. &lt;br /&gt;B: mult total by 2&lt;br /&gt;&lt;br /&gt;each must fetch, modify&lt;br /&gt;what can happen without syncronization?&lt;br /&gt;3 values can result. 8 (correct),&lt;br /&gt;if A, B fetch before other writes back, --- if A writes first, Total = 6. If B first, total = 4&lt;br /&gt;&lt;br /&gt;mutual exclusion. each must request and then release the resource.&lt;br /&gt;&lt;br /&gt;Also, if more tasks than processors, need a scheduler, which delays execution.&lt;br /&gt;Can time slice. let process execute for X amount of time. OK if all processes have same priority. complications,&lt;br /&gt;as e.g. they wait for i/o, delays for syncronization.&lt;br /&gt;&lt;br /&gt;tasks can be in several states.&lt;br /&gt;1. New - task created, not begun&lt;br /&gt;2. runnable, ready - ready to run but not currently running. given processor time, or was running and was blocked&lt;br /&gt;3. running - currently executing&lt;br /&gt;4. blocked - was running, but interrupted by an event. i/o most common, since most slow.&lt;br /&gt;5. dead - no longer actuve. execution finished or was killed.&lt;br /&gt;&lt;br /&gt;different algorithms for choosing which ready task to make runnable when currently running one is blocked. e.g. priority queue.&lt;br /&gt;&lt;br /&gt;characteristic: liveness - program continues ti execute, leading to its completion.&lt;br /&gt;deadlike can break liveness. how so?&lt;br /&gt;A and B need X and Y to continue, but A has X, B has Y. deadlock avoidance - in lang and program design.&lt;br /&gt;&lt;br /&gt;Language support for concurrency: PL/I, Ada 95, Java.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;to be continued&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114660598865309276?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114660598865309276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114660598865309276' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114660598865309276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114660598865309276'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/05/concurrency.html' title='Concurrency'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114599352102758258</id><published>2006-04-25T12:31:00.000-07:00</published><updated>2006-04-25T12:32:01.040-07:00</updated><title type='text'>Common Blocks in Fortran 77</title><content type='html'>http://www.nationalfacility.apac.edu.au/training/FortranAdvanced/slides/slides.017.html&lt;br /&gt;&lt;br /&gt;&lt;p&gt;  Common blocks are a Fortran 77 construct, providing areas of shared storage between different subroutines. eg.  &lt;/p&gt; &lt;blockquote&gt;&lt;pre&gt;program main&lt;br /&gt;   integer :: a, b&lt;br /&gt;   real :: c&lt;br /&gt;   common /d/ a, b, c&lt;br /&gt; ...&lt;br /&gt;end program main&lt;br /&gt;&lt;br /&gt;subroutine foo()&lt;br /&gt;   integer :: a, b&lt;br /&gt;   real :: c&lt;br /&gt;   common /d/ a, b, c&lt;br /&gt; ...&lt;br /&gt;end subroutine foo&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;  the common storage is called &lt;code&gt;d&lt;/code&gt; and contains the integers &lt;code&gt;a, b&lt;/code&gt; and the real &lt;code&gt;c&lt;/code&gt;.  Setting these variables in one routine changes it in all.  Common blocks are now replaced by modules in Fortran 90.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114599352102758258?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114599352102758258/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114599352102758258' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114599352102758258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114599352102758258'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/04/common-blocks-in-fortran-77.html' title='Common Blocks in Fortran 77'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114599031028788120</id><published>2006-04-25T11:38:00.000-07:00</published><updated>2006-04-25T11:38:30.300-07:00</updated><title type='text'>Implementing Subprograms</title><content type='html'>&lt;a href="http://logos.cs.uic.edu/476/notes/overheads/ch9impsubprog.pdf"&gt;Here&lt;/a&gt;:&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114599031028788120?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114599031028788120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114599031028788120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114599031028788120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114599031028788120'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/04/implementing-subprograms.html' title='Implementing Subprograms'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114435599313306372</id><published>2006-04-06T13:39:00.000-07:00</published><updated>2006-04-06T13:39:55.393-07:00</updated><title type='text'>A Lisp link</title><content type='html'>&lt;a href="http://lib.store.yahoo.net/lib/paulgraham/jmc.lisp"&gt;Here&lt;/a&gt;:&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114435599313306372?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114435599313306372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114435599313306372' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114435599313306372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114435599313306372'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/04/lisp-link.html' title='A Lisp link'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114416791210781169</id><published>2006-04-04T09:21:00.000-07:00</published><updated>2006-04-04T09:25:12.126-07:00</updated><title type='text'>Lisp Interepters</title><content type='html'>&lt;a href="http://www.thefreecountry.com/compilers/commonlisp.shtml"&gt;Here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I'm going to try out UfaSoft's one.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114416791210781169?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114416791210781169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114416791210781169' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114416791210781169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114416791210781169'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/04/lisp-interepters.html' title='Lisp Interepters'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114410119880225175</id><published>2006-04-03T14:51:00.000-07:00</published><updated>2006-04-03T14:53:18.813-07:00</updated><title type='text'>LISP - reading assignment and homework</title><content type='html'>Read chapter 9 in the book until page 318, or at least read pgs 317-318, and do exercise 9-2 questions 1 and 3.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114410119880225175?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114410119880225175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114410119880225175' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114410119880225175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114410119880225175'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/04/lisp-reading-assignment-and-homework.html' title='LISP - reading assignment and homework'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114375966088750503</id><published>2006-03-30T15:00:00.000-08:00</published><updated>2006-03-30T15:01:00.886-08:00</updated><title type='text'>Guarded Commands</title><content type='html'>See &lt;a href="http://www.answers.com/topic/guarded-commands"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114375966088750503?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114375966088750503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114375966088750503' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114375966088750503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114375966088750503'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/03/guarded-commands.html' title='Guarded Commands'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114375934442311857</id><published>2006-03-30T14:55:00.000-08:00</published><updated>2006-03-30T14:55:44.446-08:00</updated><title type='text'>Subprograms</title><content type='html'>Access the pdf &lt;a href="http://logos.cs.uic.edu/476/notes/overheads/ch8subprograms.pdf"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114375934442311857?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114375934442311857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114375934442311857' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114375934442311857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114375934442311857'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/03/subprograms.html' title='Subprograms'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114356893852351545</id><published>2006-03-28T09:54:00.000-08:00</published><updated>2006-03-28T12:39:42.973-08:00</updated><title type='text'>Iterative Statements</title><content type='html'>FORTRAN I: do was posttest.&lt;br /&gt;DO label var = init, terminal, stepsize&lt;br /&gt;stepsize defaults to 1&lt;br /&gt;unsigned int constants or simple positive int variables&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN 90&lt;/span&gt;: DO statement is pretest. fortran 77: allows loop var to be int, real, double.&lt;br /&gt;loops can be expressions, with neg and pos values. eval at &lt;span style="font-weight: bold;"&gt;beginning&lt;/span&gt; of DO to arrive at an &lt;span style="font-weight: bold;"&gt;iteration count&lt;/span&gt;. It is this value, not the loop parameters, that control the loop. so one could change them.&lt;br /&gt;&lt;br /&gt;no multiple entry, yes multiple exits.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ALGOL 60&lt;/span&gt;: a case in flexibility&lt;br /&gt;[for_stmt] -) for var := [list_element] {, [list_element]} do [statement]&lt;br /&gt;[list_element] -) [expression]&lt;br /&gt;| [expression] step [expression] until [expression]&lt;br /&gt;| [expression] while [Boolean_expr]&lt;br /&gt;&lt;br /&gt;See this website: http://logos.cs.uic.edu/476/notes/overheads/ch7controlstructures.pdf&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Pascal For Statement&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;for &lt;/span&gt;&lt;/span&gt;var = init (to | downto) final do statement&lt;br /&gt;&lt;br /&gt;it grows or shrinks in steps of 1. loop var cannot be changed in the body.&lt;br /&gt;after loop, loop var undefined. loop var is an ordinal, with scope of the loop.&lt;br /&gt;&lt;br /&gt;init and final checked at the start, and not after, and so may be changed in the loop.&lt;br /&gt;why do this? efficiency, reliability?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ada For statement&lt;br /&gt;for variable in [reverse] discrete_range loop&lt;br /&gt;...&lt;br /&gt;end loop&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;font&gt;and note that loop var has loop scope, will mask variables with wider scope.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C, C++:&lt;br /&gt;&lt;/span&gt;We know this.&lt;br /&gt;for (int i = 9; i &lt; style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;font&gt;any of the elements in the for may be missing.&lt;br /&gt;scope until end of function.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Logically Controlled Loops&lt;/span&gt; (rather than counting loops)&lt;br /&gt;posttest, pretest?&lt;br /&gt;should it be special form of a counting loop?&lt;br /&gt;&lt;br /&gt;examples of pretest, posttest in C++, Java.&lt;br /&gt;do while vs. while.&lt;br /&gt;&lt;br /&gt;how would we implement them (=operational semantics)&lt;br /&gt;&lt;br /&gt;FORTRAN 90: has neither.&lt;br /&gt;Ada: pretest, no posttest. why?&lt;br /&gt;Perl: while and until.&lt;br /&gt;how so? see here: http://vergil.chemistry.gatech.edu/resources/programming/perl-tutorial/control.html&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;font&gt;&lt;font&gt;&lt;li&gt;&lt;pre&gt;  while ($food &lt; $stomach_ache) {    $plop++;    $fizz--;    $oh_what_a_relief_it_is *= 5;  } &lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Like the &lt;code&gt;unless&lt;/code&gt; statement above, it is easier to        say "until something is true" (Schwartz 61). Thus, Perl provides       the &lt;code&gt;until&lt;/code&gt; statement: &lt;pre&gt;  until ($x &gt; 6) {&lt;br /&gt;  print "$x is the number!\n";&lt;br /&gt;  $x++;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Like C, Perl lets you do &lt;code&gt;do, while&lt;/code&gt; loops, but       Perl also adds &lt;code&gt;do, until&lt;/code&gt; loops: &lt;pre&gt;  # do while example&lt;br /&gt;do {&lt;br /&gt;  $junk++;&lt;br /&gt;} while ($junk &lt; aok =" @array_hooray[$x];"&gt;&lt;/li&gt;&lt;/span&gt;&lt;/span&gt;&lt;/ul&gt;&lt;font&gt;&lt;font&gt;&lt;br /&gt;&lt;font&gt;&lt;font&gt;and of course the for loop.&lt;br /&gt;might as well talk about Perl conditionals here as well:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;li&gt;&lt;code&gt;if&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt; statements are used as        conditionals as in any other language. For example: &lt;pre&gt;  if ($cow &lt; $sheep) {    print "baaah....\n";  } else {    print "moo....\n";  } &lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;unless&lt;/code&gt; statement is specific to Perl, in       which you want to always just evaluate the false part instead of       doing something when not true. For example: &lt;pre&gt;  unless ($age &lt;&gt;&lt;/li&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/ul&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;Pascal has a repeat...until statement, which is the reverse of C's do...while, same as Perl's do...until.&lt;br /&gt;&lt;br /&gt;Think about it - when we have break statements, they are the reverse of a standard while conditional. repeat...until maintains that.&lt;br /&gt;&lt;br /&gt;Post-tests not freq used. dangerous because loop always executed at least once, and programmer might forget this. put after loop body helps make this a bit clearer.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font&gt;&lt;font&gt;&lt;br /&gt;to be continued...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114356893852351545?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114356893852351545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114356893852351545' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114356893852351545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114356893852351545'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/03/iterative-statements.html' title='Iterative Statements'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114314320398355622</id><published>2006-03-23T11:43:00.000-08:00</published><updated>2006-03-23T15:36:08.843-08:00</updated><title type='text'>Control Structures</title><content type='html'>Control Statement = control statement + statement(s) it controls&lt;br /&gt;control execution path&lt;br /&gt;without, all have are assignments and evaluating expressions.&lt;br /&gt;two types: selection (among multiple execution paths) and repeated execution.&lt;br /&gt;basically, &lt;span style="font-weight: bold;"&gt;if &lt;/span&gt;and &lt;span style="font-weight: bold;"&gt;while.&lt;/span&gt; but can add more = greater writability, but programmers only learn subset of lang.&lt;br /&gt;&lt;br /&gt;how many statements do you allow in the control statement?&lt;br /&gt;one or many. blocks. otherwise, restricted to single statement, or use of a goto. control structures can replace goto.&lt;br /&gt;&lt;br /&gt;another q: can we enter into the middle of control structures (multiple entries) - langs differ. in terms of whether can exit multiply, not such a distinction since generally safe to do that - but there is a design philosophy.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Selection&lt;/span&gt;&lt;br /&gt;generally 2 way vs. n way selectors (1 way "degenerate" form of the two way. fortran's 3 way selector).&lt;br /&gt;&lt;br /&gt;design issue: what type of expression controls the selector? can we select more than a single statement? do we handle nested selection?&lt;br /&gt;&lt;br /&gt;Two way: Logical If:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN IV&lt;/span&gt;&lt;br /&gt;IF (BOOL expression) statement&lt;br /&gt;simple, inflexible. how do you get multiple statments? with goto circumventing.&lt;br /&gt;&lt;br /&gt;IF (FLAG .NE. 1) GO TO 20&lt;br /&gt;I = 1&lt;br /&gt;J = 1&lt;br /&gt;20 CONTINUE&lt;br /&gt;&lt;br /&gt;but points off for lack of readability.&lt;br /&gt;&lt;br /&gt;How about multiple entry? Yes. How?&lt;br /&gt;&lt;br /&gt;ALGOL 60 and on (=Java, FORTRAN 90): two-way selector:&lt;br /&gt;if (bool expr) then&lt;br /&gt;statement&lt;br /&gt;else&lt;br /&gt;statement&lt;br /&gt;&lt;br /&gt;only one or the other is executed.&lt;br /&gt;&lt;br /&gt;and either of these can be compound, in which case it is the then clause and else clause, rather than statement.&lt;br /&gt;&lt;br /&gt;how do we generate the degenerate 1-way if? how do we generate the two-way?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Nesting Selectors&lt;/span&gt;&lt;br /&gt;Ambiguity.&lt;br /&gt;if (a == 1)&lt;br /&gt;if (b == 2)&lt;br /&gt;result = 5;&lt;br /&gt;else&lt;br /&gt;result = 1;&lt;br /&gt;&lt;br /&gt;Python: semantic interpretation based on indentation. other languages, no.&lt;br /&gt;&lt;br /&gt;In Java, most other imperative langs - match most recent, so must indent the else.&lt;br /&gt;by a rule, rather than in the syntax. but will the programmer know?&lt;br /&gt;&lt;br /&gt;ALGOL 60 - by Syntax rather than by fiat (rule).&lt;br /&gt;no if nested in another if. must nest in a begin/end clause.&lt;br /&gt;&lt;br /&gt;How would we then write the code to get each interp? (Use {} as a shorthand.) Can get either effect in Java, but to match first if rather than second, must use {}.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Perl&lt;/span&gt;: then and else clauses must &lt;span style="font-weight: bold;"&gt;always&lt;/span&gt; be compound.&lt;br /&gt;&lt;br /&gt;in C++, Java, the introduction of the else clause, or else by compounds, {}, marked the end of the statement or compound, and where this was a single statement with no immediate else, was ambiguity. And difference between marker of end of clause, if it is a compound of single statement.&lt;br /&gt;&lt;br /&gt;In Ada, VB6, have end if;&lt;br /&gt;how does this help?&lt;br /&gt;&lt;br /&gt;Because "end if" closes the nested if, shows which one it matches. how do we write each in Ada?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Multiple Selection&lt;/span&gt;&lt;br /&gt;generalization of 2-way, and can implement 2-way as multiple.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;design issues&lt;br /&gt;&lt;/span&gt;&lt;font&gt;do we allow compound statements, type of expression (2 way selector needed only 2 vals), can we select more than one statement/compound? what if does not eval to one of specified vals?&lt;br /&gt;&lt;br /&gt;FORTRAN I - the three-way selector: IF(X) 10, 20, 30&lt;br /&gt;&lt;br /&gt;and here can go really anywhere - need not even immediately follow if, or each other. user responsible for gotos, and can omit with compiler not detecting.&lt;br /&gt;Also in FORTRAN I&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;computed&lt;/span&gt;:&lt;br /&gt;GO TO (label1, label2, labeln) expression&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;assigned&lt;/span&gt;:&lt;br /&gt;GO TO var_or_const&lt;br /&gt;&lt;br /&gt;C.A.R. Hoare, in ALGOL-W (1966)&lt;br /&gt;&lt;br /&gt;case int_expression of&lt;br /&gt;begin&lt;br /&gt;statement1;&lt;br /&gt;...&lt;br /&gt;statementn;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;and could be compounds.&lt;br /&gt;&lt;br /&gt;Pascal similar, except&lt;br /&gt;statement_i becomes:&lt;br /&gt;constant_list_i: statement_i;&lt;br /&gt;&lt;br /&gt;yet we cannot say goto caselabel in Pascal.&lt;br /&gt;&lt;br /&gt;later Pascals: an else clause, = to default&lt;br /&gt;no fallthru.&lt;br /&gt;&lt;br /&gt;in C#:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;pre class="code"&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;      switch(n) &lt;br /&gt;{   &lt;br /&gt;   case 1:&lt;br /&gt;      cost += 25;&lt;br /&gt;      break;            &lt;br /&gt;   case 2:      &lt;br /&gt;      cost += 25;&lt;br /&gt;      goto case 1;     &lt;br /&gt;   case 3:      &lt;br /&gt;      cost += 50;&lt;br /&gt;      goto case 1;   &lt;br /&gt;   default:      &lt;br /&gt;      Console.WriteLine("Invalid selection. Please select 1, 2, or 3.");      &lt;br /&gt;      break;&lt;br /&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;and they will not allow you to omit a break of a goto.&lt;br /&gt;&lt;br /&gt;does not disallow multiple entry. and has fallthru. unless use break, which basically is a restricted goto.&lt;br /&gt;but what if forget the break and get unwanted fallthru?&lt;br /&gt;&lt;br /&gt;reliability vs. flexibility.&lt;br /&gt;&lt;br /&gt;&lt;font&gt;In &lt;span style="font-weight: bold;"&gt;Ada&lt;/span&gt;, allow ranges: 10..15, as well as 5 | 6 | 19, and have an others clause&lt;br /&gt;&lt;br /&gt;this is good for basing on single value at the top. but sometimes, based on various boolean conditions. must use nested ifs. &lt;span style="font-weight: bold;"&gt;poor readability&lt;/span&gt;. some langs (FORTRAN 90, Ada, Perl) give way around this.&lt;br /&gt;&lt;br /&gt;elsif vs a bunch of nestings and endifs&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Iterative statements&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;execute statment 0, 1, more times&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;all prog langs.&lt;br /&gt;sometimes by iterative constructs, sometimes by recursion.&lt;br /&gt;&lt;br /&gt;at first, directly related to arrays. why? that was the problem domain.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;design questions&lt;/span&gt;: how iteration controlled, where in the loop is the control mechanism?&lt;br /&gt;&lt;br /&gt;body, pretest, posttest.&lt;br /&gt;&lt;br /&gt;counter-controlled loops: inital, terminal values of loop var, + step size.&lt;br /&gt;logically controlled loops more general, but not necessarily more commonly used. could be more complex to implement that counter-controlled.&lt;br /&gt;often supported by machine architecture. sometimes lang features outlive machine architecture  (Fortran's 3 way if)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;more design qs&lt;/span&gt;:&lt;br /&gt;type, scope of loop var. what value does it have at termination, can we change loop vars in the loop (what are effects of this?), are loop params eval once, or for every iteration (let us say the terminal condition changes)&lt;br /&gt;&lt;br /&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;FORTRAN I: do was posttest.&lt;br /&gt;DO label var = init, terminal, stepsize&lt;br /&gt;stepsize defaults to 1&lt;br /&gt;unsigned int constants or simple positive int variables&lt;br /&gt;&lt;br /&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;FORTRAN 90: DO statement is pretest. fortran 77: allows loop var to be int, real, double&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114314320398355622?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114314320398355622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114314320398355622' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114314320398355622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114314320398355622'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/03/control-structures.html' title='Control Structures'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114254081094471567</id><published>2006-03-16T12:20:00.000-08:00</published><updated>2006-03-16T15:06:05.236-08:00</updated><title type='text'>Expressions, Assignment Statements</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Overloaded Operators&lt;/span&gt;:&lt;br /&gt;operator used for more than one purpose. writability vs. reliability. is this so? depends on how use it.&lt;br /&gt;&lt;br /&gt;op overloading in C++. give me an example (&lt;&lt;, &gt;&gt;, +).&lt;br /&gt;&lt;br /&gt;by language def, by user.&lt;br /&gt;&lt;br /&gt;APL and SNOBOL have binary, unary versions of almost all operators, leads to confusion.&lt;br /&gt;&lt;br /&gt;C++: &amp; operator, as address of and bitwise and.&lt;br /&gt;unrelated functions. similarly, * operator.&lt;br /&gt;&lt;br /&gt;general problem of reusing symbols. comments, references, etc.&lt;br /&gt;a /*p&lt;br /&gt;&lt;br /&gt;unary, binary -.&lt;br /&gt;&lt;br /&gt;"distinct symbols increase readability." is this so? + for string appending.&lt;br /&gt;when used correctly, aids in readability.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;add&lt;/span&gt;(matmul(A, B), matmul(C, D)&lt;br /&gt;vs.&lt;br /&gt;A * B + C * D&lt;br /&gt;on the other hand, need know types of both operands to know meaning of operator.&lt;br /&gt;&lt;br /&gt;example from Pascal, vs. C++: find sum of bunch of ints.&lt;br /&gt;avg := sum / count;&lt;br /&gt;avg = sum / count;&lt;br /&gt;&lt;br /&gt;in Pascal, / specifies float result of division between two ints. VB as well, / vs &lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Type conversion&lt;/span&gt;&lt;br /&gt;Narrowing vs. Widening conversion. widening generally safer.&lt;br /&gt;&lt;br /&gt;mixed mode expressions = op has operands of different types. &lt;span style="font-weight: bold;"&gt;coercion&lt;/span&gt; to appropriate type where operator not defined on that type. also, there are explicit conversions via typecasting.&lt;br /&gt;&lt;br /&gt;Diff langs disagree on whether to do coercion.&lt;br /&gt;&lt;br /&gt;int a, b, c; float d;&lt;br /&gt;a = b * d; // as an error for b * c&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;case in flexibility vs. efficiency:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PL/I &lt;/span&gt;- string can be combined with an int. string is scanned for numeric value, and if a decimal point, assumed to be a float, and coerce other operand to float. Coercion, and choice of coercion, at run time.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;reduce flexibility in favor of reliability&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ada&lt;/span&gt;:&lt;br /&gt;cannot mix int and float in arithmetic expression except for **, exponent.&lt;br /&gt;&lt;br /&gt;most others, no such restrictions.&lt;br /&gt;&lt;br /&gt;Java (byte, short), C++ (short, char). operators such as + first convert to int, and then convert back on assignment, even though both operands of the same type.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Explicit type conversion&lt;br /&gt;Ada:&lt;br /&gt;&lt;/span&gt;AVG := FLOAT(SUM) / FLOAT(COUNT)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C&lt;/span&gt;:&lt;br /&gt;(int) angle&lt;br /&gt;also C++'s function-like casting&lt;br /&gt;&lt;br /&gt;errors can result from coercions. divide by zero when divide by a float.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Relational, Boolean Expressions&lt;/span&gt;&lt;br /&gt;for the most part, similar. sometimes slight differences. FORTRAN used .EQ. and .NE. because symbols not on punch cards.&lt;br /&gt;Ada uses = for comparison. /= for not equal.&lt;br /&gt;&lt;br /&gt;relational given lower precedence than arithmetic, so that can say&lt;br /&gt;a + b &gt; c + d&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Boolean expressions&lt;/span&gt;:&lt;br /&gt;In &lt;span style="font-weight: bold;"&gt;Ada&lt;/span&gt;:&lt;br /&gt;**, abs, &lt;span style="font-weight: bold;"&gt;not&lt;/span&gt;&lt;br /&gt;*, /, mod, rem&lt;br /&gt;unary +, -&lt;br /&gt;etc.&lt;br /&gt;&lt;br /&gt;lowest:&lt;br /&gt;and, or, xor, and then, or else&lt;br /&gt;&lt;br /&gt;these ops non-associative. A &gt; B and A &lt; k =" 0"&gt; b &gt; c.&lt;br /&gt;Python handles this &lt;a href="http://groups.google.com/group/comp.lang.python/browse_frm/thread/bf83c19df04b3a1b/a7c98822ba6c539a?lnk=st&amp;q=python+less+than+operator+between&amp;amp;rnum=12#a7c98822ba6c539a"&gt;interestingly&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span class="fixed_width"  style="font-family:Courier,Monospaced;"&gt;    x &lt;&gt; z&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span class="fixed_width"  style="font-family:Courier,Monospaced;"&gt;    This is interpreted by &lt;b style="color: black; background-color: rgb(255, 255, 102);"&gt;Python&lt;/b&gt; as::&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="fixed_width"  style="font-family:Courier,Monospaced;"&gt;        if x &lt;&gt; z:&lt;br /&gt;            return y &gt; z   # 1 for plain comparisons&lt;br /&gt;         else:&lt;br /&gt;            return y &gt; z   # 0 for plain comparisons&lt;br /&gt;       else:&lt;br /&gt;         return x &lt;&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="fixed_width"  style="font-family:Courier,Monospaced;"&gt;    Note that this requires testing the truth value of the result of&lt;br /&gt;   comparisons, with potential "shortcutting" of the right-side&lt;br /&gt;   comparison testings.  In other words, the truth-value of the&lt;br /&gt;   result of a comparison determines the result of a chained&lt;br /&gt;   operation.&lt;/span&gt;&lt;/p&gt;Which brings us to &lt;span style="font-weight: bold;"&gt;Short-circuiting&lt;/span&gt;.&lt;br /&gt;When know answer already, can ignore rest.&lt;br /&gt;(13 * a) * (b / 13 - 1)&lt;br /&gt;what if a is 0? But not easily detected. By boolean, already considering truth value.&lt;br /&gt;(a &gt;= 0) and (b &lt; style="font-weight: bold;"&gt;speed&lt;/span&gt;.&lt;br /&gt;can use this shortcircuiting to your advantage.&lt;br /&gt;if (index in range &lt;span style="font-weight: bold;"&gt;and&lt;/span&gt; a[index] &gt; 9)&lt;br /&gt;so as to prevent an error.&lt;br /&gt;&lt;br /&gt;on the other hand, sometimes will not expect that it is shortcircuiting, so issue of reliability. calling a function, incrementing a variable.&lt;br /&gt;&lt;br /&gt;how decide: &lt;span style="font-weight: bold;"&gt;FORTRAN 77&lt;/span&gt;: up to lang implementor, if part is a func which assigns to a nonlocal variable, that nonlocal becomes "undefined"&lt;br /&gt;difficulty in detecting these side-effects of functions.&lt;br /&gt;&lt;br /&gt;In &lt;span style="font-weight: bold;"&gt;Ada&lt;/span&gt;: and then, or else does short-circuiting.&lt;br /&gt;&lt;br /&gt;In C++: &amp;&amp;amp;, || do short-circuit. If wish to avoid short-circuit, force 1 and 0 results and use bitwise operators.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Assignment&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;A = B&lt;br /&gt;&lt;br /&gt;what about A = B = C?&lt;br /&gt;depends. in C, yes.  In PL/I, Basic, Visual Basic, = also does comparison, so would assign truth value of B = C to A.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ALGOL 60: &lt;/span&gt;:= for assignment.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Mult targets:&lt;br /&gt;PL/I&lt;/span&gt;: Sum, Total = 0.&lt;br /&gt;other langs, e.g., C, do not.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conditional targets&lt;/span&gt;&lt;br /&gt;?: to give an lval rather than an rval, in C++.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Compound Assignment&lt;/span&gt;&lt;br /&gt;a = a + b&lt;br /&gt;a += b&lt;br /&gt;&lt;br /&gt;C, C++, Java.&lt;br /&gt;interesting feature of C# that defines these for you.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Unary Assignment&lt;br /&gt;&lt;/span&gt;in C, C++, Java, etc. ++a.&lt;br /&gt;when apply two unary ops, one on left side, one on right, works right to left:&lt;br /&gt;- (count ++) even without parens&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Assignment has an expression value&lt;/span&gt;&lt;br /&gt;in C.&lt;br /&gt;while ((ch = getchar() != EOF)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Mixed mode assignment&lt;br /&gt;&lt;/span&gt;Do the source, target need be same type? FORTRAN, C, C++: coercion.&lt;br /&gt;Pascal: depends - int to real, but not real to int.&lt;br /&gt;Ada, Modula2 - nope.&lt;br /&gt;&lt;br /&gt;Java: differs from C++ - only if widening results. increases reliability.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114254081094471567?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114254081094471567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114254081094471567' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114254081094471567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114254081094471567'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/03/expressions-assignment-statements.html' title='Expressions, Assignment Statements'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114176013201824183</id><published>2006-03-07T11:23:00.000-08:00</published><updated>2006-03-07T14:04:39.630-08:00</updated><title type='text'>Data Types - III</title><content type='html'>Associative Arrays&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Perl&lt;/span&gt;:&lt;br /&gt;%ages = ("Josh" =&gt; 10, "John" = 32);&lt;br /&gt;$ages{"Josh"} = 29;&lt;br /&gt;// and assignment will create an element&lt;br /&gt;delete $ages{"John"};&lt;br /&gt;// or the entire hash:&lt;br /&gt;@salaries = ();&lt;br /&gt;&lt;br /&gt;Here is a &lt;a href="http://www.cs.mcgill.ca/%7Eabatko/computers/programming/perl/howto/hash/"&gt;Perl tutorial on hashes&lt;/a&gt;. Read through it. keys and values operator/collections.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;    for my $key ( keys %hash ) {&lt;br /&gt;my $value = $hash{$key};&lt;br /&gt;print "$key =&gt; $value\n";&lt;br /&gt;}&lt;/pre&gt;exists keyword, or else will create the element.&lt;br /&gt;if (exists $ages{"Peter"} ) ...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Possible Implementation&lt;/span&gt;: Read &lt;a href="http://www.perl.com/lpt/a/2002/10/01/hashes.html"&gt;this website&lt;/a&gt; about implementation of Perl hashes. Linked Lists - but then O(N). Could turn each string into unique index, and use array, but then very sparse. Can use a hash function. Handle collisions how? Better hash function, or else &lt;span style="font-weight: bold;"&gt;chaining&lt;/span&gt;. (Alternatively, red-black trees.) Read article for more info.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C++&lt;/span&gt;: Map, multimap. C#: Dictionary, etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Record&lt;/span&gt;:&lt;br /&gt;Heterogeneous data structure.&lt;br /&gt;First, COBOL. (Not in early Fortrans.) C's struct. C++'s class. Java has class, not struct. C# has both, but with different meanings (struct is treated as a primitive, unboxed).&lt;br /&gt;&lt;br /&gt;COBOL:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;01 EMPLOYEE-RECORD.&lt;br /&gt;02   EMPLOYEE-NAME.&lt;br /&gt;05   FIRST    PICTURE IS X(20).&lt;br /&gt;05   MIDDLE   PICTURE IS X(10).&lt;br /&gt;05   LAST     PICTURE IS X(20).&lt;br /&gt;02   HOURLY-RATE   PICTURE IS 99V99.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Pascal, Ada, use &lt;span style="font-weight: bold;"&gt;record&lt;/span&gt; nesting rather than relative numbers.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;EMPLOYEE-RECORD :&lt;br /&gt;record&lt;br /&gt;EMPLOYEE-NAME :&lt;br /&gt;  record&lt;br /&gt;    FIRST    : STRING(1..20);&lt;br /&gt;    MIDDLE   : STRING(1..10);&lt;br /&gt;    LAST     : STRING(1..20);.&lt;br /&gt;  end record;&lt;br /&gt;HOURLY-RATE   : FLOAT;&lt;br /&gt;end record;&lt;br /&gt;&lt;/pre&gt;Referring to subelements:&lt;br /&gt;COBOL: MIDDLE OF EMPLOYEE-NAME OF EMPLOYEE-RECORD&lt;br /&gt;Others langs: dot, or -&gt; for pointers to structs. Fortran: %&lt;br /&gt;&lt;br /&gt;elliptical names - as long as unambiguous, can omit middle stuff.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;with&lt;/span&gt; in Pascal, VB6. Can do this in C++ using references.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Record Ops&lt;/span&gt;&lt;br /&gt;Assignment. types must be same. Ada: comparison for =, &lt;&gt;, initialization with literals.&lt;br /&gt;&lt;br /&gt;COBOL: &lt;span style="font-weight: bold;"&gt;MOVE CORRESPONDING&lt;/span&gt;&lt;br /&gt;if subfields have same name, copy it.&lt;br /&gt;&lt;br /&gt;Implementation. adjacent memory, and field names associated with offset. descriptor has, for each field: Name, type, offset.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Unions&lt;/span&gt;&lt;br /&gt;type that stores diff type values at diff times.&lt;br /&gt;Q: Should we provide type-checking for current type, dynamically? Should unions be embedded in records?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;free unions&lt;/span&gt; give programmer complete control, no type checking.&lt;br /&gt;Pascal's unions, Ada's unions: have a &lt;span style="font-weight: bold;"&gt;tag&lt;/span&gt; or &lt;span style="font-weight: bold;"&gt;discriminant&lt;/span&gt; that tells current type.&lt;br /&gt;more about this, but can read up on it. Ada adds &lt;span style="font-weight: bold;"&gt;constrained union&lt;/span&gt; such that in declaration, can restrict to one specific type, and thus do static type-checking.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Eval&lt;/span&gt;: flexibility vs. reliability.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Implementation&lt;/span&gt;:&lt;br /&gt;Use same address for all members of union. enough storage for the largest.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Sets&lt;/span&gt;&lt;br /&gt;C++ has &lt;set&gt; but not exactly the same.&lt;br /&gt;Until then, Pascal alone among imperative langs. max size implementation dependent, often &lt; style="font-weight: bold;"&gt;type colors = {red, green, blue};&lt;br /&gt;colorset = set of colors.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;var &lt;/span&gt;set1, set2 : colorset;&lt;br /&gt;&lt;br /&gt;set1 := [red, blue];&lt;br /&gt;&lt;br /&gt;if ch &lt;span style="font-weight: bold;"&gt;in&lt;/span&gt; ['a', 'e', 'i', 'o', 'u'] ...&lt;br /&gt;&lt;br /&gt;Check out &lt;a href="http://isetlw.muc.edu/isetlw/default.asp"&gt;ISETLW&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Eval&lt;/span&gt;&lt;br /&gt;Ada, based on Pascal, but did not provide sets. rather, added membership op on enums.&lt;br /&gt;&lt;br /&gt;other langs, use arrays and implement ops. unweildy, less efficient.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Impl&lt;/span&gt;&lt;br /&gt;stored as bit strings. 0 if present, 1 if not present.&lt;br /&gt;&lt;br /&gt;(C++ has a bitset.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Pointers&lt;/span&gt;&lt;br /&gt;We know about pointers, dereferencing, assignment to local, off heap, etc.&lt;br /&gt;&lt;br /&gt;some problems with pointers:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;dangling pointers&lt;/span&gt; - points to deallocated heap variable. and what if that memory claimed by s/t else?&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;lost heap-dynamic&lt;/span&gt; variable - lost in terms of no longer accessible. memory leak, vs. garbage collection.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Pascal&lt;/span&gt;: create new vars with &lt;span style="font-weight: bold;"&gt;new&lt;/span&gt; and elim with &lt;span style="font-weight: bold;"&gt;dispose&lt;/span&gt;, which sets all pointers pointing at this object to &lt;span style="font-weight: bold;"&gt;nil&lt;/span&gt;. implementation dependent.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ada&lt;/span&gt;: access types. auto dealloc when ptr goes out of scope. elims problems caused by reliance on explicit dealloc. though gives deliberately unweildy alternate method.&lt;br /&gt;&lt;br /&gt;C++, Java: ref types.&lt;br /&gt;&lt;br /&gt;Handling dangling ptrs:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;tombstones&lt;/span&gt;. ptrs only point to tombstones. tombstone points to actual memory. when deallocate, tombstone remains and is set to nil. costly in time and space. storage never reclaimed. no prog lang uses.&lt;br /&gt;&lt;br /&gt;garbage collection vs. reference counters: lazy, eager approach.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;reference counters&lt;/span&gt; - keep track how many things pointing to this, when ref count reaches zero, can be reclaimed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;garbage collection&lt;/span&gt; - when run out of space, or can explicitly invoke. how do we know when something not pointed to? keep track of each ptr. named ptrs, and following named ptrs as far as they go.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Next&lt;/span&gt;: Expressions, Assignment Statements&lt;br /&gt;unary, binary, ternary ops.&lt;br /&gt;usually Infix.&lt;br /&gt;&lt;br /&gt;a + b * c&lt;br /&gt;&lt;br /&gt;right to left, left to right, or operator precedence.&lt;br /&gt;&lt;br /&gt;associativity to left, to right: a - b + c - d&lt;br /&gt;&lt;br /&gt;use of parentheses.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;side effects&lt;/span&gt; -what else happens as a result.&lt;br /&gt;a + fun(a)&lt;br /&gt;functional side-effects&lt;br /&gt;FORTRAN only allows (=legal) if function does not change value. but s/t hard to determine, based on pointers, globals.&lt;br /&gt;&lt;br /&gt;operator side-effects&lt;br /&gt;b = a++ + a++;&lt;br /&gt;reference point, e.g. assigning twice between two reference points.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;to be continued...&lt;/set&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114176013201824183?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114176013201824183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114176013201824183' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114176013201824183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114176013201824183'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/03/data-types-iii.html' title='Data Types - III'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114174748278114917</id><published>2006-03-07T07:56:00.000-08:00</published><updated>2006-03-07T14:11:46.573-08:00</updated><title type='text'>More Prolog</title><content type='html'>Here are some Prolog programs (written in Strawberry Prolog) and their output:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;program&lt;/span&gt;&lt;br /&gt;father(avraham, yitzchak).&lt;br /&gt;father(yitzchak, yaakov).&lt;br /&gt;&lt;br /&gt;ancestor(X, Y) :- father(X,Y).&lt;br /&gt;ancestor(X, Y) :- father(X,Z), ancestor(Z, Y).&lt;br /&gt;&lt;br /&gt;?- father(yitzchak, X), write(X), write("\n").&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Output:&lt;/span&gt;&lt;br /&gt;Compiling the file:&lt;br /&gt;c:\father&lt;br /&gt;0 errors, 0 warnings.&lt;br /&gt;&lt;br /&gt;yaakov&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;program&lt;/span&gt;&lt;br /&gt;add1(X, Y) :- Y is X + 1.&lt;br /&gt;&lt;br /&gt;?- add1(4, 5).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;output&lt;/span&gt;&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;program&lt;/span&gt;&lt;br /&gt;add1(X, Y) :- Y is X + 1.&lt;br /&gt;&lt;br /&gt;?- add1(4, 6).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;output&lt;br /&gt;&lt;/span&gt;No.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;program&lt;/span&gt;&lt;br /&gt;add1(X, Y) :- Y is X + 1.&lt;br /&gt;&lt;br /&gt;?- add1(4, X), write(X), write("\n").&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;output&lt;/span&gt;&lt;br /&gt;5&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;program&lt;/span&gt;&lt;br /&gt;add(X, Y, Z) :- Z is X + Y.&lt;br /&gt;&lt;br /&gt;?- add(4, 5, X), write(X), write("\n").&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;output&lt;/span&gt;&lt;br /&gt;9&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;program&lt;/span&gt;&lt;br /&gt;add(X, Y, Z) :- Z is X + Y.&lt;br /&gt;&lt;br /&gt;?- add(4, "hello", X), write(X), write("\n").&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;output&lt;/span&gt;&lt;br /&gt;4hello&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;program&lt;br /&gt;&lt;/span&gt;add(X, Y, Z) :- Z is X + Y.&lt;br /&gt;&lt;br /&gt;?- add(4, Y, X), write(X), write("\n").&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;output&lt;/span&gt;&lt;br /&gt;Compiling the file:&lt;br /&gt;c:\father&lt;br /&gt;0 errors, 0 warnings.&lt;br /&gt;&lt;br /&gt;Runtime Error at step 3:&lt;br /&gt;The argument 2 of "+"&lt;br /&gt;is "var" but has to be "str" or "int" or "float".&lt;br /&gt;&lt;br /&gt;No.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;program&lt;/span&gt;&lt;br /&gt;add(X, Y, Z) :- Z is X + Y.&lt;br /&gt;&lt;br /&gt;?- add(4, 5, 9), write(X), write("\n").&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;output&lt;br /&gt;&lt;/span&gt;_9&lt;br /&gt;Yes.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;program&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;font&gt;father(avraham, yitzchak).&lt;br /&gt;father(yitzchak, yaakov).&lt;br /&gt;&lt;br /&gt;ancestor(X, Y) :- father(X,Y).&lt;br /&gt;ancestor(X, Y) :- father(X,Z), ancestor(Z, Y).&lt;br /&gt;&lt;br /&gt;?- ancestor(avraham, X), write(X), write("\n").&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;output (selecting Run, then Next Answer)&lt;br /&gt;&lt;/span&gt;Compiling the file:&lt;br /&gt;C:\father&lt;br /&gt;0 errors, 0 warnings.&lt;br /&gt;&lt;br /&gt;yitzchak&lt;br /&gt;Yes.&lt;br /&gt;yaakov&lt;br /&gt;Yes.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;program&lt;/span&gt;&lt;br /&gt;abs(X, Y) :- X = Y, X &gt;= 0.&lt;br /&gt;&lt;br /&gt;?- abs(4, T), write(T), nl.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;output&lt;/span&gt;&lt;font&gt;&lt;br /&gt;4&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;program&lt;/span&gt;&lt;br /&gt;abs(X, Y) :- X = Y, X &gt;= 0.&lt;br /&gt;&lt;br /&gt;?- abs(-4, T), write(T), nl.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;output&lt;/span&gt;&lt;br /&gt;No.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;program&lt;/span&gt;&lt;br /&gt;abs(X, Y) :- Y = X, X &gt;= 0.&lt;br /&gt;abs(X, Y) :- Y = 0 - X.&lt;br /&gt;&lt;br /&gt;?- abs(-4, T), write(T), nl.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;output&lt;/span&gt;&lt;br /&gt;4&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;program&lt;/span&gt;:&lt;br /&gt;append([], L, L).&lt;br /&gt;append([H | T] , L2, [H | L3] ) :- append(T, L2, L3).&lt;br /&gt;&lt;br /&gt;1) empty list + L = L&lt;br /&gt;2) recursion step&lt;br /&gt;&lt;font&gt;appending a list [H | T] to any list L2 produces the list [H | L3], on condition that L3 is formed by appending T to L2.&lt;br /&gt;&lt;br /&gt;try out an example.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114174748278114917?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114174748278114917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114174748278114917' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114174748278114917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114174748278114917'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/03/more-prolog.html' title='More Prolog'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114121609261056303</id><published>2006-03-01T04:24:00.000-08:00</published><updated>2006-03-01T04:28:12.610-08:00</updated><title type='text'>Prolog Compilers, Interpreters</title><content type='html'>There is one that actually runs in your browser window if you have a Java-enabled browser. Click &lt;a href="http://goanna.cs.rmit.edu.au/%7Ewinikoff/wp/"&gt;here&lt;/a&gt;, scroll down to "the distribution," and click on the button labelled "Start W-Prolog" to start the prolog interpreter Applet.&lt;br /&gt;&lt;br /&gt;Copy the text of the facts and rules from the previous  post, and run a query to see if terach is the father of yishmael.&lt;br /&gt;&lt;br /&gt;There are some free compilers and interpreters &lt;a href="http://www.thefreecountry.com/compilers/prolog.shtml"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114121609261056303?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114121609261056303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114121609261056303' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114121609261056303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114121609261056303'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/03/prolog-compilers-interpreters.html' title='Prolog Compilers, Interpreters'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114121544846175300</id><published>2006-03-01T04:04:00.000-08:00</published><updated>2006-03-01T04:24:48.586-08:00</updated><title type='text'>Prolog - I</title><content type='html'>Facts, rules, and goals.&lt;br /&gt;&lt;br /&gt;father(terach, avraham).&lt;br /&gt;father(avraham, yitzchak).&lt;br /&gt;father(avraham, yishmael).&lt;br /&gt;&lt;br /&gt;ancestor(X, Y) :- father(X, Y).&lt;br /&gt;ancestor(X, Y) :- father(X, Z), ancestor(Z, Y).&lt;br /&gt;&lt;br /&gt;try this out. how would you write a brother rule?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114121544846175300?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114121544846175300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114121544846175300' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114121544846175300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114121544846175300'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/03/prolog-i.html' title='Prolog - I'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114116336565103172</id><published>2006-02-28T12:57:00.000-08:00</published><updated>2006-02-28T14:36:09.716-08:00</updated><title type='text'>Data Types 2</title><content type='html'>Array = homogenous collection&lt;br /&gt;q: what types for subscripts, do we rangecheck, are ranges bound, array alloc when, how many subscripts (1,2), initialization, are slices allowed?&lt;br /&gt;FORTRAN:&lt;br /&gt;SUM = SUM + B(I)&lt;br /&gt;same () as functions so needs keep track. why? no other chars avail. Ada as well - because both are mappings of parameters to values. Pascal, C++, Java = []&lt;br /&gt;&lt;br /&gt;obvious point: element type vs. subscript type. most often subrange of int. Pascal, Ada: Bool, char, enum.&lt;br /&gt;&lt;br /&gt;subrange checking: Pascal, Ada, Java. Not C++, FORTRAN - out of bound errors. speed vs. reliability.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Binding &lt;/span&gt;of subscript &lt;span style="font-weight: bold;"&gt;type&lt;/span&gt; statically bound (usually) but value range can s/t vary dynamically.&lt;br /&gt;&lt;br /&gt;lower bound: 0, 1, set by user.&lt;br /&gt;&lt;br /&gt;4 cat, based on binding to subscript range and binding to storage.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;static array - &lt;/span&gt;both ranges and binding to storage at compile time. no dynamic alloc dealloc. FORTRAN 77.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;fixed stack-dynamic&lt;/span&gt; - subscripts bound statically, storage bound off the stack - C, Pascal.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;stack-dynamic&lt;/span&gt; - same as above but subscript bound dynamically as well. but then remain fixed for lifetime of var. Ada:&lt;br /&gt;GET (LIST_LEN)&lt;br /&gt;declare&lt;br /&gt;LIST : array (1..LIST_LEN) of INTEGER&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;end&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;heap-dynamic&lt;/span&gt; - same, but can change many times during lifetime. FORTRAN 90:&lt;br /&gt;INTEGER, ALLOCATABLE, ARRAY (:, :) :: MAT&lt;br /&gt;ALLOCATE (MAT(10, NUMBER_OF_COLUMNS)&lt;br /&gt;DEALLOCATE(MAT)&lt;br /&gt;same idea in C, C++ using pointers.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Number of Subscripts&lt;/span&gt;&lt;br /&gt;saw in fortran assignment that could use mult indices. original fortran restricted to 3. The ZERO-ONE-INFINITE principle. Let programmer bear the cost if he wants. FORTRAN IV it became 7. Modern - unlimited.&lt;br /&gt;&lt;br /&gt;Array init: FORTRAN has it in the form of a DATA statement:&lt;br /&gt;DATA MYVAR / 8, 9, 10/&lt;br /&gt;in C, init of arrays, of strings, of arrays of strings. In Java.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ada: &lt;/span&gt;&lt;br /&gt;LIST : array (1..5) of INTEGER := (1, 4, 6, 8, 10)&lt;br /&gt;LIST : array (1..5) of INTEGER := (1 =&gt; 3, 4 =&gt; 9, others =&gt;0)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;array ops &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;to be continued...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114116336565103172?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114116336565103172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114116336565103172' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114116336565103172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114116336565103172'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/data-types-2.html' title='Data Types 2'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114072475509842933</id><published>2006-02-23T11:55:00.000-08:00</published><updated>2006-02-23T11:59:15.120-08:00</updated><title type='text'>Class Notes - Data Types - 1</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Lifetime&lt;/span&gt;&lt;br /&gt;Not same as scope. Example – subprogram in C where exists but hidden. Static in C.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Symbolic constants&lt;/span&gt;&lt;br /&gt;Why? Readability. Reliability. Ease of changing the program. We saw in the program where can be useful. Two types – lvalues and rvalues. Const vs. #define.&lt;br /&gt;Pascal - simple, Modula-2: complex expressions. manifest constants –simple due to static binding of values.&lt;br /&gt;C++, Java, Ada: constants based on variables – bound at runtime&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Initializing Variables&lt;/span&gt;&lt;br /&gt;We know C++. int x = 6; FORTRAN has DATA statement&lt;br /&gt;REAL PI&lt;br /&gt;INTEGER SUM&lt;br /&gt;DATA SUM /0/, PI /3.14/&lt;br /&gt;Some langs do not have init statements. Just do assignment. Pascal.&lt;br /&gt;When is this initialization done? Static vs. auto in C.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ALGOL 60&lt;/span&gt;&lt;br /&gt;First, ALGOL 58, designed by international committee. 3 goals: close to standard mathematical notation; use to describe computing processes in publications; able to translate to machine code. JOVIAL, MAD, NELIAC. In general, taken to be guidelines for developing langs. IBM interested in promoting FORTRAN.&lt;br /&gt;ALGOL 60, Peter Naur described using BNF, which while elegant, was not well understood back then.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Contributions&lt;/span&gt;: many langs based on this. Example: pascal, ALGOL 68, Ada, C++, PL/I, Java. Was only accepted way of describing algorithms. Influenced machine architecture to implement the concepts. &lt;span style="font-weight: bold;"&gt;Advances&lt;/span&gt;: block structure; pass by value and &lt;span style="font-weight: bold;"&gt;pass by name&lt;/span&gt;. recursive procs. Stack dynamic arrays. (now they have them in C, I think). But lacked standard IO = difficulty porting. People already using FORTRAN.&lt;br /&gt;&lt;br /&gt;I posted before an initial ALGOL reading – 95 – 121. A summary of material covered there – Algol 58, use of BNF (with further discussion in next chapter), Algol 60. Blocks. Though ALGOL has static scoping, a discussion of dynamic scoping. Pg 118. generalized arrays by allowing lower bounds, dynamic arrays. Pg 119 – strong typing. Look thru the code.&lt;br /&gt;&lt;br /&gt;Now 121-140. A lot of what we discussed.  Pass by name, value.  Recursive procedures. Introduction of for loop with step – very general. The switch.&lt;br /&gt;&lt;br /&gt;months&lt;br /&gt;For days := 31, 28, 31, 30, 31, 31, 31, 30, 31, 30 do&lt;br /&gt;For days := 31, if (mod(year, 4) = 0 then 29, else 28, 31, 30, 31, 31, 31, 30, 31, 30&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Homework&lt;/span&gt;: Print Oscillating sum&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Homework&lt;/span&gt;: Set up Prolog&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Data types&lt;/span&gt;:&lt;br /&gt;Early on, model linked list, binary tree, with arrays. Think. How would do it?&lt;br /&gt;COBOL – allowed specification of precision, structured data type for records. PL/I – extended precision to ints and floats. ALGOL 68: primitives and structure-defining ops. (examples of ops – in C: {}, (), *, []) User defined data types – able to associate name w/ data type. Abstract data types – use of a type differs from internal representation and ops available on type&lt;br /&gt;Homogeneous (array) vs. heterogenous (record).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Primitives&lt;/span&gt; – not based on other types. Ints reflect storage in hardware. Others – in software.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Numerics&lt;/span&gt; – integers: signed (one’s complement, two’s complement), unsigned, short, int, long. Floats: 1 sign bit, 8 bit exponent, 23 bit fraction = 32. Double: 1/11/52 = 64.&lt;br /&gt;Decimal: use byte or nibble per digit. Decimal point does not float. Boolean types. As bit, byte, int. Char type: ASCII, Unicode (2 byte).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;String Types&lt;/span&gt;: might be built in or built upon array of char. Do we allow array ops on it. Should they be static or dynamic length?&lt;br /&gt;Not primitive: C++, Pascal, Ada.&lt;br /&gt;In Ada: array of char, can reference a single char. Various ops built in.&lt;br /&gt;substr: name1(2:4)&lt;br /&gt;&amp; for concatenation. As in VB6.&lt;br /&gt;C++: ignoring the stl. After all, literal strings are arrays of char, null terminated. Built in library functions – strcpy, strcat, etc.&lt;br /&gt;FORTRAN 70+: they are primitives. Have assignment, relational ops, concatenation, substring.&lt;br /&gt;Java: primitive type. String class: holds constant strings. StringBuffer. Why this is really annoying. String comparisons in Java.&lt;br /&gt;SNOBOL4, Perl, Javascript: pattern matching string op. many other langs: as functions.&lt;br /&gt;In SNOBOL4, patterns can be assigned to variables.&lt;br /&gt;LETTER = ‘abcdefghijklmnopqrstuvwxyz’&lt;br /&gt;WORDPATTERN = BREAK(LETTER) SPAN(LETTER) . WORD&lt;br /&gt;Means skip until find a letter, then span letters, then assign (the .)  to the variable WORD&lt;br /&gt;TEXT WORDPATTERN&lt;br /&gt;Perl: Based on regular expressions. /[A-Za-z][ [A-Za-z]+/        /\d+\. ?\d* | \.\d+/&lt;br /&gt;&lt;br /&gt;static vs. dynamic string lengths&lt;br /&gt;FORTRAN 90:&lt;br /&gt;CHARACTER (LEN = 15) A, B&lt;br /&gt;Always full, empty chars are blank.&lt;br /&gt;C, C++: limited dynamic. Except for STL&lt;br /&gt;SNOBOL4, JavaScript, Perl: dynamic&lt;br /&gt;Talk about benefits, drawbacks of each scheme&lt;br /&gt;&lt;br /&gt;Implementation&lt;br /&gt;Static: at compile time: name of type, the length, the address&lt;br /&gt;Limited dynamic: store capacity, current length. (though C++ needs this not)&lt;br /&gt;No need for dynamic allocation.&lt;br /&gt;Dynamic: as linked list, but have many pointers. Dense list. But what if space afterwards is claimed – must realloc and copy. We can use a mixture of the two approaches.&lt;br /&gt;&lt;br /&gt;User-defined Ordinals.&lt;br /&gt;enum. C, Ada&lt;br /&gt;Design: In Pascal, a given enum val (e.g. January) not allowed to be used in more than a single enum, cannot be input or output, but can be assigned, compared, used in for loop.&lt;br /&gt;Some languages allow overloading of these literals, but then need to specify type:&lt;br /&gt;e.g. type letters is (‘A’, ‘B’, ‘C’, ‘D’ ….&lt;br /&gt;type vowels is (‘A’, ‘E’, ‘I’, ‘O’, ‘U’)&lt;br /&gt;for letter in ‘A’ ,,. ‘U’ loop&lt;br /&gt;for letter in vowels(‘A’) ,,. Vowels(‘U’) loop&lt;br /&gt;&lt;br /&gt;Ada’s BOOLEAN and CHARACTER are predefined enums&lt;br /&gt;&lt;br /&gt;Ops: pred, successor, position. Pascal: pred(blue) is red. Ada, as attributes: Letter’Pred(‘B’) is ‘A’&lt;br /&gt;&lt;br /&gt;Improves readability, reliability&lt;br /&gt;&lt;br /&gt;Subrange types – continuous subsequence of an ordinal&lt;br /&gt;Pascal:&lt;br /&gt;type&lt;br /&gt;uppercase = ‘A’ .. ‘Z’;&lt;br /&gt;index = 1 .. 100;&lt;br /&gt;&lt;br /&gt;In Ada, called subtypes. Assuming already defined an enum:&lt;br /&gt;Subtype WEEKDAYS is DAYS range Mon .. Fri&lt;br /&gt;Subtype INDEX is INTEGER range 1 .. 100&lt;br /&gt;&lt;br /&gt;Ada allows assignment from parent to subtype unless it is not defined, so might assign Tuesday but not Sunday.&lt;br /&gt;Recall that diff from Ada’s type, where cannot assign from parent to derived type.&lt;br /&gt;&lt;br /&gt;Implementation: As parent types, but with range checking for each assignment.&lt;br /&gt;&lt;br /&gt;Array Types&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114072475509842933?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114072475509842933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114072475509842933' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114072475509842933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114072475509842933'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/class-notes-data-types-1.html' title='Class Notes - Data Types - 1'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114058678581952667</id><published>2006-02-21T21:23:00.000-08:00</published><updated>2006-03-17T07:53:48.083-08:00</updated><title type='text'>Syllabus - work in progress</title><content type='html'>Work in progress - to be refined, added to, etc.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Preliminaries&lt;/li&gt;&lt;ol&gt;&lt;li&gt;why study programming languages, programming domains, criteria to evaluate languages, influences on language design, language categories, design trade-off.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Some History&lt;/li&gt;&lt;ol&gt;&lt;li&gt;pseudocodes, FORTRAN, ALGOL. discuss other languages later, as they come up.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Syntax&lt;br /&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;describing syntax, lexemes, tokens, language recognizers and generators, BNF and CFGs, EBNF, parse trees, ambiguity, precedence, associativity, regular expressions, FSA, NFSAs, PDAs.&lt;/li&gt;&lt;li&gt;Lexical analysis, parsing, lex and yacc.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Names, Bindings, Type Checking, Scopes, Lifetime. static and dynamic&lt;/li&gt;&lt;li&gt;Data Types&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Primitives, strings, user-defined ordinals, arrays, associative arrays, records, unions,  sets, pointers. Also, some discussion of &lt;span style="font-weight: bold;"&gt;ALGOL&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Expressions and Assignment statements&lt;/li&gt;&lt;ol&gt;&lt;li&gt;arithmetics expressions, overloaded operators, type conversions, relational/boolean expressions, short circuit evaluation, assignment statements, mixed-mode assignment. More ALGOL.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Control Structures&lt;/li&gt;&lt;ol&gt;&lt;li&gt;compound statements, selection statements, iterative statements, unconditional branching, guarded commands&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Subprograms&lt;/li&gt;&lt;ol&gt;&lt;li&gt;design issues, local referencing environments, parameter passing methods, overloaded subprograms, generic subprograms, separate and independent compilation, design issues for functions, accessing nonlocal environments, user-defined overloaded operators, coroutines.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Implementing subprograms&lt;/li&gt;&lt;ol&gt;&lt;li&gt;General semantics of calls and returns, implementing: FORTRAN subprograms, ALGOL subprograms, blocks, dynamic scoping, parameters that are subprogram names.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Encapsulation, OOP - we will probably skip since we already know this fairly well.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Concurrency - perhaps&lt;/li&gt;&lt;li&gt;Exception handling  - perhaps if have time at the end, since will cover this elsewhere&lt;br /&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;in PL/I, in Ada, in C++, in Java&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Functional Programming - we will do &lt;span style="font-weight: bold;"&gt;LISP&lt;/span&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Mathematical functions, fundamentals of functional programming langs, LISP, Scheme, Common LISP, ML, Haskell, Applications of, comparison between functional and imperative languages&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Logic Programming Languages - &lt;span style="font-weight: bold;"&gt;Prolog&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Predicate Calculus, Proving Theorems, Logic Programming, Intro to Prolog, applications of&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114058678581952667?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114058678581952667/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114058678581952667' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114058678581952667'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114058678581952667'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/syllabus-work-in-progress.html' title='Syllabus - work in progress'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114055148655622994</id><published>2006-02-21T17:14:00.000-08:00</published><updated>2006-02-21T14:23:24.936-08:00</updated><title type='text'>Bindings And Scope</title><content type='html'>&lt;span style="font-weight: bold;"&gt;3. Variables&lt;br /&gt;&lt;/span&gt;Replace absolute address with symbols. A tuple: (name, address, value, type, lifetime, scope).&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;address&lt;/span&gt;: can have many instantiations of same name at different addresses. via functions, different scope, recursion. &lt;span style="font-weight: bold;"&gt;vs.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;alias&lt;/span&gt; - many names for one address. EQUIVALENCE in Fortran. Pascal and Ada's variant record structure.  C's union. C's pointers, C++'s references.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;type &lt;/span&gt;- defines value range and ops can perform. unsigned short int.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;value - &lt;/span&gt;contents of mem cell.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. Binding&lt;br /&gt;&lt;/span&gt;Association between attrib and entity, or between op and symbol. &lt;span style="font-weight: bold;"&gt;&lt;br /&gt;binding time&lt;/span&gt; = when binding takes place.&lt;br /&gt;int count; ... count = count + 5;&lt;br /&gt;Bindings and binding times:&lt;br /&gt;set of poss types for count: lang design time&lt;br /&gt;type of count: compile time&lt;br /&gt;poss values for count: compiler design time&lt;br /&gt;count's value: execution time&lt;br /&gt;meanings of +: lang definition time&lt;br /&gt;meaning of + in this statement: compile time&lt;br /&gt;internal representation of 5: compiler design time&lt;br /&gt;&lt;br /&gt;binding attribs to vars: &lt;span style="font-weight: bold;"&gt;static &lt;/span&gt;= before runtime. vs. &lt;span style="font-weight: bold;"&gt;dynamic&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Type Binding&lt;/span&gt;. &lt;span style="font-weight: bold;"&gt;static &lt;/span&gt;w/ or w/o explicit declarations. Modern: Perl, ML - no explicit. VB6 optional. Fortran, PL/I, Basic: implicit. we spoke about Fortran's convention, and about unreliability. C: declarations vs definitions. &lt;span style="font-weight: bold;"&gt;dynamic&lt;/span&gt;: not bound by declaration, but at assignment, and can be reassigned. =flexibility. func can deal with data of any type. C++ needs know type of the data. Consider swap in C.&lt;br /&gt;Jscript: list = [1.4, 4.5] and can reassign to a scalar.&lt;br /&gt;lack of reliability due to typos generating new vars, or if assignment should not work, will.&lt;br /&gt;usually interpreted rather than compiled because hard to implement dynamic type changes in machine code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Type inference&lt;/span&gt;: ML can infer type.&lt;br /&gt;fun circum(r) = 3.14 * r * r;&lt;br /&gt;fun square(x) : int = x * x; //int specifies return type&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:130%;"&gt;Storage Bindings/Lifetimes&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;allocation/deallocation. lifetime= time var bound to a specific address.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;static vars&lt;/span&gt; - throughout program execution. retain history, speed 'cause no alloc/dealloc. no recursion, waste of space.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;stack-dynamic&lt;/span&gt; - allocated when declaration statement reached. could either be when enter func (Ada) or when reach that pos (Java). Allows recursion, sharing of space.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;explicit heap-dynamic&lt;/span&gt; - using new and delete&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;implicit heap-dynamic&lt;/span&gt; - Perl, Javascript arrays and strings. as a result of assignment.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Type-Checking&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;For both operations and functions. Type checking: make sure operands are of compatible types. compatible = legal for operator or can be implicitly converted (=coersion). &lt;span style="font-weight: bold;"&gt;type error&lt;/span&gt; - where cannot apply operator to operand.&lt;br /&gt;&lt;br /&gt;depends on bindings of vars to types. if static, can do type checking statically. if dynamic, must be done at runtime = dynamic type checking. better to detect earlier. tradeoff of reliability with flexibility. What about variants, unions? Must maintain current type, if do actually check.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Strong Typing&lt;/span&gt;&lt;br /&gt;Structured programming in 70's --&gt; strong typing. each name has single type, defined statically = known at compile time. For variant records: type errors are always detected.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Pascal&lt;/span&gt;: almost strongly typed. allows type tag omission in variants.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ada &lt;/span&gt;as well: variants dynamically checked. But can specify UNCHECKED_CONVERSION function. oiwerful, useful for using pointers as ints for user-defined storage allocation/deallocation. &lt;span style="font-weight: bold;"&gt;Modula-3&lt;/span&gt;: LOOPHOLE&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C, C++&lt;/span&gt;: not. functions where parameters not type-checked. Namely, the "..." How do you think printf works?&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ML&lt;/span&gt;: Strong: types all statically known, from declarations of inference.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Java&lt;/span&gt;: Strongly typed. Can do explicit conversion, resulting in type error, but no implicit conversion. at least in assignment. still some implicit coversion, in terms of evaluating expressions. int + float. string + int. "hello" + i + j.&lt;br /&gt;more coercion --&gt; less reliability.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Type Compatibility&lt;/span&gt;&lt;br /&gt;in terms of assignment, most often. &lt;span style="font-weight: bold;"&gt;name type compatibility&lt;/span&gt; = only if have same names.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;structure type compatibility - &lt;/span&gt;if structures are the same.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;Consider the &lt;span style="font-weight: bold;"&gt;enum&lt;/span&gt; in C. Can we assign it to an int of v.v.?&lt;br /&gt;When pass vars to funcs. if we define locally, who is to say that types are the same? Original Pascal - define it globally.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;flexibility vs. difficulty implementing. compiler compare name, or compare each element type. What if have same structure in terms of data types but diff field names? Diff subscript ranges (0...9) vs (1..10)? Two enums with same num of components?&lt;br /&gt;&lt;br /&gt;type celsuis = real;&lt;br /&gt;type fahrenheit = real;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Pascal &lt;/span&gt;did not initally specify, which led to diff implementations. ISO Pascal - mixed: declaration equivalence - if define one type name = another type.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ada&lt;/span&gt;: derived type vs subtype. &lt;span style="font-weight: bold;"&gt;derived&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;type celsuis is new FLOAT;&lt;br /&gt;type fahrenheit is new FLOAT;&lt;br /&gt;&lt;br /&gt;cannot assign to each other, to and fro FLOATS, except literals.&lt;br /&gt;subtype is compatible with parent:&lt;br /&gt;subtype SMALL_TYPE is INTEGER [range 0 .. 99];&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C&lt;/span&gt;: structural equivalence.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C++&lt;/span&gt;: name equivalence. &lt;span style="font-weight: bold;"&gt;typedef&lt;/span&gt; does not introduce new type, but acts as a macro.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ada&lt;/span&gt;: need no type names&lt;br /&gt;C, D : array (1 .. 10) of INTEGER; is incompatible&lt;br /&gt;type: LIST_10 is array (1 .. 10) of INTEGER;&lt;br /&gt;C, D: LIST_10;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Scope&lt;br /&gt;&lt;/span&gt;scope = range in which is visible, ie can be referenced in a statement. locals vs. globals.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ALGOL 60&lt;/span&gt;: static scope. this is what we are used to. in C: globals seen in functions. within functions, nested ifs, blocks, etc. However, also nested procedures. static parent and ancestors.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;procedure big;&lt;br /&gt;var x : integer;&lt;br /&gt;procedure sub1;&lt;br /&gt;begin { sub1 }&lt;br /&gt;...x...&lt;br /&gt;end; {sub1}&lt;br /&gt;procedure sub2;&lt;br /&gt;var x : integer;&lt;br /&gt;begin { sub2 }&lt;br /&gt;...x...&lt;br /&gt;end; {sub2}&lt;br /&gt;begin { big }&lt;br /&gt;...x...&lt;br /&gt;end; {big}&lt;br /&gt;&lt;/pre&gt;Also, have narrower scop hiding wider scope. Scope resolution op in C++. C++ doesn't allow nested funcs, but do allow globals.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Blocks&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Again, ALGOL 60.&lt;br /&gt;In Ada:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;declare&lt;/span&gt; TEMP : integer&lt;br /&gt;begin&lt;br /&gt;TEMP := FIRST&lt;br /&gt;FIRST := SECOND&lt;br /&gt;SECOND := FIRST&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;C, Java: {}. for's changing scope.&lt;br /&gt;&lt;br /&gt;Dynamic Scope&lt;br /&gt;APL, SNOBOL4, early lisp&lt;br /&gt;problems: cannot determine attributes statically.&lt;br /&gt;1) less reliable, since subprograms, even far off textually, can modify local vars.&lt;br /&gt;2) cannot do static type checking&lt;br /&gt;3) akin to Spaghetti code.&lt;br /&gt;4) speed issues - much slower to access&lt;br /&gt;benefits: no need to pass vars, bec implicitly visible&lt;br /&gt;But static is more readable and faster. perhaps later discuss implementation of each.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114055148655622994?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114055148655622994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114055148655622994' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114055148655622994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114055148655622994'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/bindings-and-scope.html' title='Bindings And Scope'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114055434491199399</id><published>2006-02-21T12:30:00.000-08:00</published><updated>2006-02-21T12:44:00.146-08:00</updated><title type='text'>Reading in ALGOL, Compiling in ALGOL</title><content type='html'>We are about ready to move on to the next programming language: ALGOL.&lt;br /&gt;&lt;br /&gt;Here is a page with some &lt;a href="http://www.thefreecountry.com/compilers/algol.shtml"&gt;free ALGOL compilers and interpreters&lt;/a&gt;. Try installing one and see if the following "hello world" code will run:&lt;br /&gt;&lt;pre&gt;&lt;a name="Algol-60"&gt;'BEGIN'&lt;br /&gt; 'COMMENT' Hello World in Algol 60;&lt;br /&gt;  OUTPUT(4,'(''('Hello World!')',/')')&lt;br /&gt;'END'&lt;/a&gt;&lt;/pre&gt;Or in ALGOL 68:&lt;br /&gt;&lt;pre&gt;&lt;a name="Algol-68"&gt;( # Hello World in Algol 68 # print(("Hello World!",newline)))&lt;br /&gt;&lt;/a&gt;&lt;/pre&gt;In the book, read from pg. 95-121.&lt;br /&gt;&lt;br /&gt;Here is a &lt;a href="http://en.wikipedia.org/wiki/ALGOL_programming_language"&gt;Wikipedia article on ALGOL&lt;/a&gt;:&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114055434491199399?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114055434491199399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114055434491199399' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114055434491199399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114055434491199399'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/reading-in-algol-compiling-in-algol.html' title='Reading in ALGOL, Compiling in ALGOL'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114054663192466326</id><published>2006-02-21T10:06:00.000-08:00</published><updated>2006-02-21T11:05:04.990-08:00</updated><title type='text'>Analysis of a FORTRAN Matrix Program - III</title><content type='html'>The code, as a reminder:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;! program to calculate whether a graph is strongly connected&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;! it calculates this my using matrix multiplication on the&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;! adjacency matrix representing the graph&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;PROGRAM matrix&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;" &gt;INTEGER :: length&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;" &gt;PARAMETER (length = 4)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;INTEGER :: a,b, c, m(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;" &gt;length,length&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;), copy(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);font-family:courier new;" &gt;length,length&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;), total, d, e, f&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;m(1, :) = (/ 1, 0, 1, 0/)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;m(2, :) = (/ 1, 0, 0, 0/)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;m(3, :) = (/ 1, 1, 0, 1/)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;m(4, :) = (/ 0, 0, 1, 0/)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;!initialize a copy of m so that we may calculate N^2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;copy = m&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DO a = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DO b = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;total = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DO c = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;total = m(a,c) * copy(c,b) + total&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;IF (total &gt; 0) THEN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;m(a,b) = 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ELSE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;m(a,b) = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;END IF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DO f = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;PRINT *, m(f,1:4)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DO e = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;total = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DO d = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;IF( m(d,e) .EQ. 1 .AND. m(e,d) .EQ. 1 ) total = total + 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;IF ( total == 8 ) THEN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;PRINT *, 'Strongly Connected At: ', e&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ELSE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;PRINT *, 'Not Strongly Connected At: ', e&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;END IF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;END PROGRAM matrix&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Now, while the example I used in class had only 1s and 0s in the result, in reality we may have higher numbers. &lt;span style="font-weight: bold;"&gt;This is fine&lt;/span&gt;. A zero in position (i,j) means that there is no path from i to j, but a number greater than zero, such as 1 or 3 or 8, means that there &lt;span style="font-weight: bold;"&gt;is&lt;/span&gt; a path. So we need not check specifically for a nonzero and set the result to 1.&lt;br /&gt;&lt;br /&gt;One we know this, we may use the built-in &lt;span style="font-weight: bold;"&gt;matmul&lt;/span&gt; function that I suggested you use, rather than doing the matrix multiplication by hand. Doing matmul it by hand is certainly still good programming exercise, but if we have this function built in, it may just be incredibly optimized. Further, it saves programmer work. Further, it makes the code smaller and thus more readable and less error-prone.&lt;br /&gt;&lt;br /&gt;There was actually a bug in this code, which I should comment upon before proceeding:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;DO a = 1, length&lt;br /&gt;DO b = 1, length&lt;br /&gt;    total = 0&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        ! the following code calculates a single dotproduct&lt;/span&gt;&lt;br /&gt;    DO c = 1, length&lt;br /&gt;        total = m(a,c) * copy(c,b) + total&lt;br /&gt;    END DO&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        ! and here we assign the result to m&lt;/span&gt;&lt;br /&gt;    IF (total &gt; 0) THEN&lt;br /&gt;        m(a,b) = 1&lt;br /&gt;    ELSE&lt;br /&gt;        m(a,b) = 0&lt;br /&gt;    END IF&lt;br /&gt;END DO&lt;br /&gt;END DO&lt;br /&gt;&lt;/pre&gt;The problem is twofold. Firstly, we are only doing a single matrix multiplication in this entire code - calculating M^2 rather than M^4.  Secondly, we are not even calculating M^2 correctly! This is because we are modifying M in the middle of the multiplication! M(1,1) is being set, and then that value is being used to compute M(1,2), M(1,3), M(1,4), and M(2,1), M(3,1), and M(4,1). We could solve this by making a &lt;span style="font-weight: bold;"&gt;third &lt;/span&gt;matrix, result, and assigning to that matrix, and then stating m = result at the end. But let us skip this entire step and just use the built in &lt;span style="font-weight: bold;"&gt;matmul &lt;/span&gt;function. We no longer need the &lt;span style="font-weight: bold;"&gt;copy &lt;/span&gt;matrix for this purpose, but I will leave it in in case we need it for some other purpose. I will change the code, commenting out the previous code so we can see what changed. I will still only calculate M^2. We will deal with M^4 and the associated problem later.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;! program to calculate whether a graph is strongly connected&lt;br /&gt;! it calculates this my using matrix multiplication on the&lt;br /&gt;! adjacency matrix representing the graph&lt;br /&gt;PROGRAM matrix&lt;br /&gt;&lt;br /&gt;INTEGER :: length&lt;br /&gt;PARAMETER (length = 4)&lt;br /&gt;INTEGER :: a,b, c, m(length,length), copy(length,length), total, d, e, f&lt;br /&gt;&lt;br /&gt;m(1, :) = (/ 1, 0, 1, 0/)&lt;br /&gt;m(2, :) = (/ 1, 0, 0, 0/)&lt;br /&gt;m(3, :) = (/ 1, 1, 0, 1/)&lt;br /&gt;m(4, :) = (/ 0, 0, 1, 0/)&lt;br /&gt;&lt;br /&gt;!initialize a copy of m so that we may calculate N^2&lt;br /&gt;copy = m&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!DO a = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! DO b = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!  total = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!  DO c = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!   total = m(a,c) * copy(c,b) + total&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!  END DO&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!  IF (total &gt; 0) THEN&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!   m(a,b) = 1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!  ELSE&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!   m(a,b) = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!  END IF&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! END DO&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!END DO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! calculate M^2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;m = matmul(m, m)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;DO f = 1, length&lt;br /&gt;PRINT *, m(f,1:4)&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;DO e = 1, length&lt;br /&gt;total = 0&lt;br /&gt;DO d = 1, length&lt;br /&gt;IF( m(d,e) .EQ. 1 .AND. m(e,d) .EQ. 1 ) total = total + 2&lt;br /&gt;END DO&lt;br /&gt;IF ( total == 8 ) THEN&lt;br /&gt;PRINT *, 'Strongly Connected At: ', e&lt;br /&gt;ELSE&lt;br /&gt;PRINT *, 'Not Strongly Connected At: ', e&lt;br /&gt;END IF&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;END PROGRAM matrix&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114054663192466326?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114054663192466326/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114054663192466326' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114054663192466326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114054663192466326'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/analysis-of-fortran-matrix-program-iii.html' title='Analysis of a FORTRAN Matrix Program - III'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114054487669839567</id><published>2006-02-21T09:45:00.000-08:00</published><updated>2006-02-21T10:01:16.746-08:00</updated><title type='text'>Analysis of a FORTRAN Matrix Program - II</title><content type='html'>The program already has a nice feature. It defines length to be 4 and then uses length throughout in the loops. That way, if we want to change the program to handle a 5 X 5 matrix, we can just change the declaration of our matrices to 5 X 5, and length to = 5, and the program will run. Using symbols instead of literals in this way makes the program mode readily adaptable.&lt;br /&gt;&lt;br /&gt;The program, again:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! program to calculate whether a graph is strongly connected&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! it calculates this my using matrix multiplication on the&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! adjacency matrix representing the graph&lt;/span&gt;&lt;br /&gt;PROGRAM matrix&lt;br /&gt;&lt;br /&gt;INTEGER :: a,b, c, m(4,4), copy(4,4), total, length = 4, d, e, f&lt;br /&gt;&lt;br /&gt;m(1, :) = (/ 1, 0, 1, 0/)&lt;br /&gt;m(2, :) = (/ 1, 0, 0, 0/)&lt;br /&gt;m(3, :) = (/ 1, 1, 0, 1/)&lt;br /&gt;m(4, :) = (/ 0, 0, 1, 0/)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! copy(1, :) = (/ 1, 0, 1, 0/)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! copy(2, :) = (/ 1, 0, 0, 0/)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! copy(3, :) = (/ 1, 1, 0, 1/)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! copy(4, :) = (/ 0, 0, 1, 0/)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!initialize a copy of m so that we may calculate N^2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;copy = m&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;DO a = 1, length&lt;br /&gt;   DO b = 1, length&lt;br /&gt;       total = 0&lt;br /&gt;       DO c = 1, length&lt;br /&gt;   total = m(a,c) * copy(c,b) + total&lt;br /&gt;       END DO&lt;br /&gt;   IF (total &gt; 0)  THEN&lt;br /&gt;       m(a,b) = 1&lt;br /&gt;   ELSE&lt;br /&gt;       m(a,b) = 0&lt;br /&gt;   END IF&lt;br /&gt;   END DO&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;DO f = 1, length&lt;br /&gt;  PRINT *, m(f,1:4)&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;DO e = 1, length&lt;br /&gt;   total = 0&lt;br /&gt;   DO d = 1, length&lt;br /&gt;       IF( m(d,e) .EQ. 1 .AND.  m(e,d) .EQ. 1 ) total = total + 2&lt;br /&gt;   END DO&lt;br /&gt;   IF ( total == 8 ) THEN&lt;br /&gt;   PRINT *, 'Strongly Connected At: ', e&lt;br /&gt;   ELSE&lt;br /&gt;   PRINT *, 'Not Strongly Connected At: ', e&lt;br /&gt;   END IF&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;END PROGRAM matrix&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;However, as implemented, there are two things I would change. Firstly, length is declared as a variable. This means that somewhere in the program, I might change it by accident. It would be better to declare it a constant. But how do we do this in FORTRAN? The answer, we declare its data type and then set its value with a PARAMETER statement.&lt;br /&gt;&lt;br /&gt;Another thing I would change: the declaration of our matrices m and copy use a literal 4. When modifying the program, I would not only have to change the definition of length but my matrix definitions as well. Instead, let us use our new constant to define the matrix size. We will also remove the old code that was commented out:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;! program to calculate whether a graph is strongly connected&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;! it calculates this my using matrix multiplication on the&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;! adjacency matrix representing the graph&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;PROGRAM matrix&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0); font-family: courier new;"&gt;INTEGER :: length&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0); font-family: courier new;"&gt;PARAMETER (length = 4)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;INTEGER :: a,b, c, m(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0); font-family: courier new;"&gt;length,length&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;), copy(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0); font-family: courier new;"&gt;length,length&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;), total, d, e, f&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;m(1, :) = (/ 1, 0, 1, 0/)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;m(2, :) = (/ 1, 0, 0, 0/)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;m(3, :) = (/ 1, 1, 0, 1/)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;m(4, :) = (/ 0, 0, 1, 0/)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;!initialize a copy of m so that we may calculate N^2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;copy = m&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;DO a = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;DO b = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;total = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;DO c = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;total = m(a,c) * copy(c,b) + total&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;IF (total &gt; 0) THEN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;m(a,b) = 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ELSE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;m(a,b) = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;END IF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;DO f = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;PRINT *, m(f,1:4)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;DO e = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;total = 0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;DO d = 1, length&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;IF( m(d,e) .EQ. 1 .AND. m(e,d) .EQ. 1 ) total = total + 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;IF ( total == 8 ) THEN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;PRINT *, 'Strongly Connected At: ', e&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ELSE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;PRINT *, 'Not Strongly Connected At: ', e&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;END IF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;END DO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;END PROGRAM matrix&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114054487669839567?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114054487669839567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114054487669839567' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114054487669839567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114054487669839567'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/analysis-of-fortran-matrix-program-ii.html' title='Analysis of a FORTRAN Matrix Program - II'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114054384131858048</id><published>2006-02-21T09:31:00.000-08:00</published><updated>2006-02-21T09:44:01.360-08:00</updated><title type='text'>Analysis of a FORTRAN Matrix Program - I</title><content type='html'>Here I present a matrix homework. I will post comments and suggestions in a series of posts. First, here is the program at the outset.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;PROGRAM matrix&lt;br /&gt;&lt;br /&gt;INTEGER :: a,b, c, m(4,4), copy(4,4), total, length = 4, d, e, f&lt;br /&gt;&lt;br /&gt;m(1, :) = (/ 1, 0, 1, 0/)&lt;br /&gt;m(2, :) = (/ 1, 0, 0, 0/)&lt;br /&gt;m(3, :) = (/ 1, 1, 0, 1/)&lt;br /&gt;m(4, :) = (/ 0, 0, 1, 0/)&lt;br /&gt;&lt;br /&gt;copy(1, :) = (/ 1, 0, 1, 0/)&lt;br /&gt;copy(2, :) = (/ 1, 0, 0, 0/)&lt;br /&gt;copy(3, :) = (/ 1, 1, 0, 1/)&lt;br /&gt;copy(4, :) = (/ 0, 0, 1, 0/)&lt;br /&gt;&lt;br /&gt;DO a = 1, length&lt;br /&gt;    DO b = 1, length&lt;br /&gt;        total = 0&lt;br /&gt;        DO c = 1, length&lt;br /&gt;    total = m(a,c) * copy(c,b) + total&lt;br /&gt;        END DO&lt;br /&gt;    IF (total &gt; 0)  THEN&lt;br /&gt;        m(a,b) = 1&lt;br /&gt;    ELSE&lt;br /&gt;        m(a,b) = 0&lt;br /&gt;    END IF&lt;br /&gt;    END DO&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;DO f = 1, length&lt;br /&gt;   PRINT *, m(f,1:4)&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;DO e = 1, length&lt;br /&gt;    total = 0&lt;br /&gt;    DO d = 1, length&lt;br /&gt;        IF( m(d,e) .EQ. 1 .AND.  m(e,d) .EQ. 1 ) total = total + 2&lt;br /&gt;    END DO&lt;br /&gt;    IF ( total == 8 ) THEN&lt;br /&gt;    PRINT *, 'Strongly Connected At: ', e&lt;br /&gt;    ELSE&lt;br /&gt;    PRINT *, 'Not Strongly Connected At: ', e&lt;br /&gt;    END IF&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;END PROGRAM matrix&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;One thing that is missing from this program is &lt;span style="font-weight: bold;"&gt;comments&lt;/span&gt;. Tell me what the program is supposed to do, and what each section of the code is supposed to do. It used to be that the letter C at the beginning of the line would start a comment. Here, instead, we use the character !&lt;br /&gt;&lt;br /&gt;Another thing to realize is that you can assign an entire matrix to another matrix with the = operator. You need not initialize &lt;span style="font-weight: bold;"&gt;copy&lt;/span&gt; separately, or even loop, copying elements. Rather, just use =. I will comment out the code and put in the new code in its place. My changes in &lt;span style="color: rgb(153, 0, 0);"&gt;red&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;! program to calculate whether a graph is strongly connected&lt;br /&gt;! it calculates this my using matrix multiplication on the&lt;br /&gt;! adjacency matrix representing the graph&lt;br /&gt;PROGRAM matrix&lt;br /&gt;&lt;br /&gt;INTEGER :: a,b, c, m(4,4), copy(4,4), total, length = 4, d, e, f&lt;br /&gt;&lt;br /&gt;m(1, :) = (/ 1, 0, 1, 0/)&lt;br /&gt;m(2, :) = (/ 1, 0, 0, 0/)&lt;br /&gt;m(3, :) = (/ 1, 1, 0, 1/)&lt;br /&gt;m(4, :) = (/ 0, 0, 1, 0/)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! copy(1, :) = (/ 1, 0, 1, 0/)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! copy(2, :) = (/ 1, 0, 0, 0/)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! copy(3, :) = (/ 1, 1, 0, 1/)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;! copy(4, :) = (/ 0, 0, 1, 0/)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;!initialize a copy of m so that we may calculate N^2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;copy = m&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;DO a = 1, length&lt;br /&gt;    DO b = 1, length&lt;br /&gt;        total = 0&lt;br /&gt;        DO c = 1, length&lt;br /&gt;    total = m(a,c) * copy(c,b) + total&lt;br /&gt;        END DO&lt;br /&gt;    IF (total &gt; 0)  THEN&lt;br /&gt;        m(a,b) = 1&lt;br /&gt;    ELSE&lt;br /&gt;        m(a,b) = 0&lt;br /&gt;    END IF&lt;br /&gt;    END DO&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;DO f = 1, length&lt;br /&gt;   PRINT *, m(f,1:4)&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;DO e = 1, length&lt;br /&gt;    total = 0&lt;br /&gt;    DO d = 1, length&lt;br /&gt;        IF( m(d,e) .EQ. 1 .AND.  m(e,d) .EQ. 1 ) total = total + 2&lt;br /&gt;    END DO&lt;br /&gt;    IF ( total == 8 ) THEN&lt;br /&gt;    PRINT *, 'Strongly Connected At: ', e&lt;br /&gt;    ELSE&lt;br /&gt;    PRINT *, 'Not Strongly Connected At: ', e&lt;br /&gt;    END IF&lt;br /&gt;END DO&lt;br /&gt;&lt;br /&gt;END PROGRAM matrix&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114054384131858048?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114054384131858048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114054384131858048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114054384131858048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114054384131858048'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/analysis-of-fortran-matrix-program-i.html' title='Analysis of a FORTRAN Matrix Program - I'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114047692783589309</id><published>2006-02-20T14:59:00.000-08:00</published><updated>2006-02-20T15:09:44.996-08:00</updated><title type='text'>Some Pointers with the FORTRAN matrix assignment</title><content type='html'>1)&lt;br /&gt;&lt;a href="http://www.answers.com/topic/strongly-connected-component"&gt;Definition&lt;/a&gt; of Strongly Connected Graph&lt;br /&gt;&lt;blockquote&gt;A directed &lt;a href="http://www.answers.com/main/ntquery;jsessionid=3pj8t8clcqf1t?method=4&amp;dsid=2222&amp;amp;dekey=Graph+%28mathematics%29&amp;gwp=8&amp;amp;curtab=2222_1&amp;sbid=lc01a" class="ilnk" target="_top" onclick="addLinkTextToHref(this);"&gt;graph&lt;/a&gt; is called &lt;i&gt;strongly connected&lt;/i&gt; if for every pair of   &lt;a href="http://www.answers.com/main/ntquery;jsessionid=3pj8t8clcqf1t?method=4&amp;dsid=2222&amp;amp;amp;dekey=Vertex&amp;gwp=8&amp;amp;curtab=2222_1&amp;sbid=lc01a" class="ilnk" target="_top" onclick="addLinkTextToHref(this);"&gt;vertices&lt;/a&gt; &lt;i&gt;u&lt;/i&gt; and &lt;i&gt;v&lt;/i&gt; there is a &lt;a href="http://www.answers.com/main/ntquery;jsessionid=3pj8t8clcqf1t?method=4&amp;dsid=2222&amp;amp;amp;dekey=Path+%28graph+theory%29&amp;gwp=8&amp;amp;curtab=2222_1&amp;sbid=lc01a" class="ilnk" target="_top" onclick="addLinkTextToHref(this);"&gt;path&lt;/a&gt; from   &lt;i&gt;u&lt;/i&gt; to &lt;i&gt;v&lt;/i&gt; and a path from &lt;i&gt;v&lt;/i&gt; to &lt;i&gt;u&lt;/i&gt;. &lt;/blockquote&gt;2) A &lt;a href="http://www2.cs.uh.edu/%7Ejohnson2/power.html"&gt;program&lt;/a&gt; that uses the built in matmul, and does assignment from one matrix to another:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;! EXAMPLE 4&lt;br /&gt;!&lt;br /&gt;! Aprogram to compute the largest eigenvalue&lt;br /&gt;! of a real, dense matrix by the power method&lt;br /&gt;&lt;br /&gt;integer, parameter::devno=10, n=10, minit = 10, maxit=100&lt;br /&gt;real::lambda_old, lambda_new&lt;br /&gt;real::rel_err, tol = 2.0**(-20)&lt;br /&gt;real,dimension(n)::x_new, x_old=(/(1.0/n,i=1,n)/)&lt;br /&gt;real,dimension(n,n)::a&lt;br /&gt;open(devno, file='a.dat')&lt;br /&gt;read(10,10) ((a(i,j),j=1,n),i=1,n)&lt;br /&gt;10 format(10f4.1)&lt;br /&gt;iterate: do i=1,maxit&lt;br /&gt; write (*,*) "i = ", i&lt;br /&gt; &lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;x_new=matmul(a, x_old)&lt;/span&gt;&lt;br /&gt; lambda_new = sqrt(dot_product(x_new, x_new))&lt;br /&gt; write(*,*) "lambda_new = ", lambda_new&lt;br /&gt; if (i .gt. minit) then&lt;br /&gt;    rel_err = abs((lambda_new - lambda_old)/lambda_old)&lt;br /&gt;    if (rel_err .lt. tol) exit iterate&lt;br /&gt; endif&lt;br /&gt; if (i .eq. maxit) write (*,*) "Maximum Iterations reached"&lt;br /&gt; lambda_old = lambda_new&lt;br /&gt; x_old = x_new/lambda_new&lt;br /&gt;end do iterate&lt;br /&gt;write(*,*) "lambda = ", lambda_new&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;Another place that uses &lt;a href="http://64.233.179.104/search?q=cache:ypx72bK7y9sJ:personalpages.manchester.ac.uk/staff/david.d.apsley/lectures/fortran/week2.pdf+fortran+matmul+example&amp;hl=en&amp;amp;gl=us&amp;ct=clnk&amp;amp;cd=19"&gt;matmul&lt;/a&gt;.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114047692783589309?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114047692783589309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114047692783589309' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114047692783589309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114047692783589309'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/some-pointers-with-fortran-matrix.html' title='Some Pointers with the FORTRAN matrix assignment'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114018687165299891</id><published>2006-02-17T11:22:00.000-08:00</published><updated>2006-02-17T08:24:29.220-08:00</updated><title type='text'>Explaining Lex and Yacc</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Note: Change {} after includes to pointy brackets.&lt;br /&gt;1)&lt;/span&gt;&lt;br /&gt;What exactly are you doing when you process something with lex?&lt;br /&gt;&lt;br /&gt;Well, lex takes your lex file, say example2.l and generates a file in the C language. The name of this file is &lt;span style="font-weight: bold;"&gt;lex.yy.c&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;In class, I spoke about Finite State Machines, and how they can recognize regular languages. &lt;span style="font-weight: bold;"&gt;lex.yy.c&lt;/span&gt; is an implementation of a Finite State Machine based on your lex file. The regular expressions are inputs, and the actions or printfs are the outputs.&lt;br /&gt;&lt;br /&gt;Thus, let us say we have example2.l:&lt;br /&gt;&lt;pre&gt;%{&lt;br /&gt;#include {stdio.h}&lt;br /&gt;%}&lt;br /&gt;&lt;br /&gt;%%&lt;br /&gt;[0123456789]+           printf("NUMBER\n");&lt;br /&gt;[a-zA-Z][a-zA-Z0-9]*    printf("WORD\n");&lt;br /&gt;%%&lt;/pre&gt; The stuff between %{ and %} will be included in the C file, which is important since we are using printf. The stuff between %% and %% are regular expressions together with the action to take after successfully recognizing that expression.&lt;br /&gt;&lt;br /&gt;At the command line, we type:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;lex example2.l&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This generates the file lex.yy.c.&lt;br /&gt;&lt;br /&gt;Pseudocode to explain what this file contains (obtained from &lt;a href="http://www.cs.man.ac.uk/%7Epjj/cs2111/ho/node6.html"&gt;this website&lt;/a&gt;):&lt;br /&gt;&lt;pre&gt;        state= 0; get next input character&lt;br /&gt;      while (not end of input) {&lt;br /&gt;         depending on current state and input character&lt;br /&gt;            match: /* input expected */&lt;br /&gt;               calculate new state; get next input character&lt;br /&gt;            accept: /* current pattern completely matched */&lt;br /&gt;               state= 0; perform action corresponding to pattern&lt;br /&gt;            error: /* input unexpected */&lt;br /&gt;               state= 0; echo 1st character input after last accept or error;&lt;br /&gt;               reset input to 2nd character input after last accept or error;&lt;br /&gt;      }&lt;/pre&gt; Thus, we start at the start state, read input. So long as we are matching, we calculate a new state based on current state and input character. We do this until we enter an accept state. If we do, we go to the start state once again, so we can match the next string (=token), . If we go to an error state along the way, we say so and try matching again.&lt;br /&gt;&lt;br /&gt;We need not go into detail here how exactly &lt;span style="font-weight: bold;"&gt;lex.yy.c&lt;/span&gt; implements this Finite State Machine in C. You can try examining the code if you want.&lt;br /&gt;&lt;br /&gt;Now, if we want to run this Finite State Machine in &lt;span style="font-weight: bold;"&gt;lex.yy.c&lt;/span&gt;, we cannot, because it is written in C, not in machine language. Thus, we must compile the file.&lt;br /&gt;&lt;br /&gt;There are two ways to compile it. We can incorporate the &lt;span style="font-weight: bold;"&gt;lex.yy.c &lt;/span&gt;with other files in a C project, and call the various functions and access the variables it exposes. We would need to do this because &lt;span style="font-weight: bold;"&gt;lex.yy.c &lt;/span&gt;does not have its own main function. Alternatively, we could specify that libl provide us with an appropriate main(). We do the latter.&lt;br /&gt;&lt;br /&gt;Thus, at the command line, we type:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;cc lex.yy.c -o example2 -ll   &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This &lt;span style="font-weight: bold;"&gt;-ll&lt;/span&gt; gets the main() function from libl. -o states that the output file should be what we specify, namely &lt;span style="font-weight: bold;"&gt;example2&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;We can then run the executable, &lt;span style="font-weight: bold;"&gt;example2.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;2) What exactly does yacc do?&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;yacc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; takes a yacc file which contains BNF and generates a C file which implements a &lt;span style="font-weight: bold;"&gt;Push Down Automaton&lt;/span&gt; (PDA) which accepts the context free language specified in the yacc file.&lt;br /&gt;&lt;br /&gt;We use &lt;span style="font-weight: bold;"&gt;yacc&lt;/span&gt; together with &lt;span style="font-weight: bold;"&gt;lex&lt;/span&gt;.&lt;br /&gt;Our &lt;span style="font-weight: bold;"&gt;lex&lt;/span&gt; file will recognize and inform us about tokens, while  our &lt;span style="font-weight: bold;"&gt;yacc&lt;/span&gt; file will base itself upon those tokens and recognize a context free grammar.&lt;br /&gt;&lt;br /&gt;Beforehand, we used the -ll option with the &lt;span style="font-weight: bold;"&gt;cc&lt;/span&gt; command, so that we were provided with a main() function.&lt;br /&gt;&lt;br /&gt;Now, however, we want to compile more than just the &lt;span style="font-weight: bold;"&gt;lex.yy.c&lt;/span&gt; file. We want to incorporate it with C code generated by &lt;span style="font-weight: bold;"&gt;yacc.&lt;/span&gt; Thus, we will no longer use the  &lt;span style="font-weight: bold;"&gt;-ll &lt;/span&gt;option. Instead, we will make sure that our &lt;span style="font-weight: bold;"&gt;yacc&lt;/span&gt; file has a main() function defined.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3)&lt;br /&gt;&lt;/span&gt;Let us consider example4, which is the thermostat example.&lt;br /&gt;&lt;br /&gt;Create a lex file, &lt;span style="font-weight: bold;"&gt;example4.l&lt;/span&gt;. The contents of this file should be:&lt;br /&gt;&lt;pre&gt;&lt;blockquote&gt;%{&lt;br /&gt;#include {stdio.h}&lt;br /&gt;#include "y.tab.h"&lt;br /&gt;%}&lt;br /&gt;%%&lt;br /&gt;[0-9]+                  return NUMBER;&lt;br /&gt;heat                    return TOKHEAT;&lt;br /&gt;on|off                  return STATE;&lt;br /&gt;target                  return TOKTARGET;&lt;br /&gt;temperature             return TOKTEMPERATURE;&lt;br /&gt;\n                      /* ignore end of line */;&lt;br /&gt;[ \t]+                  /* ignore whitespace */;&lt;br /&gt;%%&lt;span style="font-family:georgia,serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/pre&gt; Most of this should be familiar. We are matching tabs, newlines, the string "on" or "off", etcetera.&lt;br /&gt;&lt;br /&gt;One thing is different, though. Rather that just having #include {stdio.h}, we have an additional line that we are explicitly marking to be included in the generated C file, lex.yy.c. That line is:&lt;br /&gt;&lt;pre&gt;#include "y.tab.h"&lt;/pre&gt; &lt;span style="font-weight: bold;"&gt;y.tab.h&lt;/span&gt; is a header file needed in association with the C file generated by yacc, namely &lt;span style="font-weight: bold;"&gt;y.tab.c&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;We now need a &lt;span style="font-weight: bold;"&gt;yacc&lt;/span&gt; file. The tutorial does a bad job here by separating parts of the file, and not . Basically, we need a single file that does three things:&lt;br /&gt;&lt;ol&gt;   &lt;li&gt;Provide literal code that will include necessary .h files and provide needed functions such as main(). This part will be between %{ and %}&lt;br /&gt;  &lt;/li&gt;   &lt;li&gt;Give a definition of the tokens to be used in our grammar. This line will start %token.&lt;/li&gt;   &lt;li&gt;Lay out the context free grammar, with rules, as well as actions to take (such as printf) after the rule has been satisfied. This should be embedded within %% and %% tags, but the tutorial omitted it, and thus you may have had a compile time error.&lt;/li&gt; &lt;/ol&gt; The contents of the file &lt;span style="font-weight: bold;"&gt;example4.y&lt;/span&gt; should be:&lt;br /&gt;&lt;blockquote&gt;%{&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;string.h&gt;&lt;br /&gt; &lt;br /&gt;void yyerror(const char *str)&lt;br /&gt;{&lt;br /&gt;        fprintf(stderr,"error: %s\n",str);&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;int yywrap()&lt;br /&gt;{&lt;br /&gt;        return 1;&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;        yyparse();&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;%}&lt;br /&gt; &lt;br /&gt;%token NUMBER TOKHEAT STATE TOKTARGET TOKTEMPERATURE&lt;br /&gt; &lt;br /&gt;%%&lt;br /&gt;commands: /* empty */&lt;br /&gt;        | commands command&lt;br /&gt;        ;&lt;br /&gt; &lt;br /&gt;command:&lt;br /&gt;        heat_switch&lt;br /&gt;        |&lt;br /&gt;        target_set&lt;br /&gt;        ;&lt;br /&gt; &lt;br /&gt;heat_switch:&lt;br /&gt;        TOKHEAT STATE&lt;br /&gt;        {&lt;br /&gt;                printf("\tHeat turned on or off\n");&lt;br /&gt;        }&lt;br /&gt;        ;&lt;br /&gt; &lt;br /&gt;target_set:&lt;br /&gt;        TOKTARGET TOKTEMPERATURE NUMBER&lt;br /&gt;        {&lt;br /&gt;                printf("\tTemperature set\n");&lt;br /&gt;        }&lt;br /&gt;        ;&lt;br /&gt;%%&lt;/blockquote&gt;Save this file as &lt;span style="font-weight: bold;"&gt;example4.y&lt;/span&gt;. Then run yacc on it by typing at the command line:&lt;br /&gt;&lt;br /&gt;yacc example4.y&lt;br /&gt;&lt;br /&gt;This will generate two files, &lt;span style="font-weight: bold;"&gt;y.tab.h&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;y.tab.c&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Now, we have our three files:&lt;br /&gt;lex.yy.c&lt;br /&gt;y.tab.c&lt;br /&gt;y.tab.h&lt;br /&gt;&lt;br /&gt;We need to compile them. Remember we are not using the -ll option since we are providing our own main() function.&lt;br /&gt;&lt;pre&gt;cc lex.yy.c y.tab.c -o example4 &lt;/pre&gt; Then run example4.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114018687165299891?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114018687165299891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114018687165299891' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114018687165299891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114018687165299891'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/explaining-lex-and-yacc.html' title='Explaining Lex and Yacc'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114011332289792020</id><published>2006-02-16T17:03:00.000-08:00</published><updated>2006-02-16T14:51:33.963-08:00</updated><title type='text'>Names and Binding</title><content type='html'>We may return to talk more about parsing later.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Name forms: &lt;/span&gt;&lt;br /&gt;max length, connector characters, case sensitivity, Limitation on max length to ease symbol table. C++ unlimited, but depends on implementation. does case sensitivity hurt readability, reliability, writability?&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Special words&lt;/span&gt; = keywords vs. reserved words.&lt;br /&gt;REAL APPLE&lt;br /&gt;REAL = 3.4&lt;br /&gt;INTEGER REAL&lt;br /&gt;REAL INTEGER&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;predefined names&lt;/span&gt; in Ada. INTEGER and FLOAT are there by default but may be overridden. Pascal. Others in Ada brought in via &lt;span style="font-weight: bold;"&gt;with&lt;/span&gt; statements. printf and scanf in C.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. Variables&lt;br /&gt;&lt;/span&gt;Replace absolute address with symbols. A tuple: (name, address, value, type, scope).&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;address&lt;/span&gt;: can have many instantiations of same name at different addresses. via functions, different scope, recursion. &lt;span style="font-weight: bold;"&gt;vs.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;alias&lt;/span&gt; - many names for one address. EQUIVALENCE in Fortran. Pascal and Ada's variant record structure. See &lt;a href="http://faculty.cs.wwu.edu/reedyc/CS141_Spring_2005/Lectures/CS141_Var_Records.html"&gt;here&lt;/a&gt;:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4161/206/1600/VarRecord.gif"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/4161/206/320/VarRecord.jpg" alt="" border="0" /&gt;&lt;/a&gt;How do we implement this? Change size of allocate maximum.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;TYPE&lt;/span&gt; Geom_Type &lt;span style="color: rgb(0, 0, 255);"&gt;IS&lt;/span&gt; (Unknown, Rectangle, Circle);&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;TYPE&lt;/span&gt; Geometric_Figure(Figure_Type : Geom_Type := Unknown) &lt;span style="color: rgb(0, 0, 255);"&gt;IS RECORD&lt;/span&gt;&lt;br /&gt;-- Invariant data fields here&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;CASE&lt;/span&gt; Figure_Type &lt;span style="color: rgb(0, 0, 255);"&gt;IS&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;WHEN&lt;/span&gt; Rectangle =&gt;&lt;br /&gt;   Width  : Float;&lt;br /&gt;   Height : Float;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;WHEN&lt;/span&gt; Circle =&gt;&lt;br /&gt;   Radius : Float;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;WHEN&lt;/span&gt; Unknown =&gt;&lt;br /&gt;   &lt;span style="color: rgb(0, 0, 255);"&gt;NULL&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;END CASE&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;END RECORD&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;constrained vs. unconstrained.&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;big&gt;&lt;big&gt;&lt;span style="font-family:monospace;"&gt;&lt;small&gt;&lt;small&gt;GF : Geometric_Figure;&lt;br /&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;-- An unconstrained Geometric_Figure&lt;/span&gt;&lt;br /&gt;GC : Geometric_Figure( Figure_Type =&gt; Circle );&lt;br /&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;-- A constrained Geometric Figure of Figure_Type Circle&lt;/span&gt;&lt;/small&gt;&lt;/small&gt;&lt;br /&gt;&lt;/span&gt;&lt;/big&gt;&lt;/big&gt;&lt;/div&gt;&lt;br /&gt;discriminant, fixed, variant. reading allowed for all, var so long as proper type. writing: discr if dont change val or as record assignment. record assignment allowed if unconstrained, else discr must match. record compare if discr match/&lt;br /&gt;C's union. C's pointers, C++'s references.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;type &lt;/span&gt;- defines value range and ops can perform. unsigned short int.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;value - &lt;/span&gt;contents of mem cell.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. Binding&lt;br /&gt;&lt;/span&gt;Association between attrib and entity, or between op and symbol. &lt;span style="font-weight: bold;"&gt;&lt;br /&gt;binding time&lt;/span&gt; = when binding takes place.&lt;br /&gt;int count; ... count = count + 5;&lt;br /&gt;Bindings and binding times:&lt;br /&gt;set of poss types for count: lang design time&lt;br /&gt;type of count: compile time&lt;br /&gt;poss values for count: compiler design time&lt;br /&gt;count's value: execution time&lt;br /&gt;meanings of +: lang definition time&lt;br /&gt;meaning of + in this statement: compile time&lt;br /&gt;internal representation of 5: compiler design time&lt;br /&gt;&lt;br /&gt;binding attribs to vars: &lt;span style="font-weight: bold;"&gt;static &lt;/span&gt;= before runtime. vs. &lt;span style="font-weight: bold;"&gt;dynamic&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Type Binding&lt;/span&gt;. &lt;span style="font-weight: bold;"&gt;static &lt;/span&gt;w/ or w/o explicit declarations. Modern: Perl, ML - no explicit. VB6 optional. Fortran, PL/I, Basic: implicit. we spoke about Fortran's convention, and about unreliability. C: declarations vs definitions. &lt;span style="font-weight: bold;"&gt;dynamic&lt;/span&gt;: not bound by declaration, but at assignment, and can be reassigned. =flexibility. func can deal with data of any type. C++ needs know type of the data. Consider swap in C.&lt;br /&gt;Jscript: list = [1.4, 4.5] and can reassign to a scalar.&lt;br /&gt;lack of reliability due to typos generating new vars, or if assignment should not work, will.&lt;br /&gt;usually interpreted rather than compiled because hard to implement dynamic type changes in machine code.&lt;br /&gt;&lt;br /&gt;Type inference: ML can infer type.&lt;br /&gt;fun circum(r) = 3.14 * r * r;&lt;br /&gt;fun square(x) : int = x * x; //int specifies return type&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Storage Bindings/Lifetimes&lt;br /&gt;&lt;/span&gt;allocation/deallocation. lifetime= time var bound to a specific address.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;static vars&lt;/span&gt; - throughout program execution. retain history, speed 'cause no alloc/dealloc. no recursion, waste of space.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;stack-dynamic&lt;/span&gt; - allocated when declaration statement reached. could either be when enter func (Ada) or when reach that pos (Java). Allows recursion, sharing of space.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;explicit heap-dynamic&lt;/span&gt; - using new and delete&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;implicit heap-dynamic&lt;/span&gt; - Perl, Javascript arrays and strings. as a result of assignment.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114011332289792020?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114011332289792020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114011332289792020' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114011332289792020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114011332289792020'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/names-and-binding.html' title='Names and Binding'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-114002044563009676</id><published>2006-02-16T12:44:00.000-08:00</published><updated>2006-02-16T09:38:00.583-08:00</updated><title type='text'>Some Linear Algebra</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Dot Product&lt;/span&gt;&lt;br /&gt;1x + 3y + 7z = 7&lt;br /&gt;[1 3 7] · [x y z] = 7&lt;br /&gt;scalar result. transpose.&lt;br /&gt;&lt;br /&gt;Solving sets of Linear equations. n equations and n unknowns&lt;br /&gt;&lt;br /&gt;x + 4y + 6z = 6&lt;br /&gt;2x + 5y + 15z = -1&lt;br /&gt;2x + 5y = 9&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;[1 4  6]   [x]   [ 6 ]&lt;br /&gt;[2 5 15] X [y] = [-1 ]&lt;br /&gt;[2 5  0]   [z]   [ 9 ]&lt;br /&gt;&lt;/pre&gt;Matrix multiplication. Can implement various operations. Swap rows, add multiple of one row to another, etc.&lt;br /&gt;Other matrix ops: multiplication by a scalar. matrix addition.&lt;br /&gt;&lt;br /&gt;Matrix multiplication, addition, useful for finding cyles in graphs.&lt;br /&gt;Adjacency matrix. A X A yields all cycles of length 2 in the diagonal.&lt;br /&gt;A&lt;sup&gt;n&lt;/sup&gt; yields all cycles of length n.&lt;br /&gt;A + A&lt;sup&gt;2&lt;/sup&gt; + A&lt;sup&gt;3&lt;/sup&gt; + ...  A&lt;sup&gt;n&lt;/sup&gt;. Looking at one full row or column will tell us if the graph is strongly connected.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-114002044563009676?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/114002044563009676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=114002044563009676' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114002044563009676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/114002044563009676'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/some-linear-algebra.html' title='Some Linear Algebra'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113996898498583052</id><published>2006-02-14T17:55:00.000-08:00</published><updated>2006-02-14T18:03:04.993-08:00</updated><title type='text'>Definitions: Finite State Machines</title><content type='html'>The &lt;a href="http://en.wikipedia.org/wiki/Finite_state_machine"&gt;wikipedia entry on Finite State Machines&lt;/a&gt;, which breaks down into Deterministic and Nondeterministic finite state machines. Read up to and including the section on &lt;span style="font-weight: bold;"&gt;Acceptors and Recognizers&lt;/span&gt;, and Figure 2. Skip transducers if you wish, and read the &lt;span style="font-weight: bold;"&gt;mathematical model for acceptors&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;If you want to read about &lt;a href="http://en.wikipedia.org/wiki/Push-down_automata"&gt;PDAs&lt;/a&gt;, see here.&lt;br /&gt;&lt;br /&gt;If you want, you can read about &lt;a href="http://en.wikipedia.org/wiki/Turing_Machine"&gt;Turing Machines&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113996898498583052?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113996898498583052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113996898498583052' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113996898498583052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113996898498583052'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/definitions-finite-state-machines.html' title='Definitions: Finite State Machines'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113996561351287908</id><published>2006-02-14T17:05:00.000-08:00</published><updated>2006-02-14T17:06:53.513-08:00</updated><title type='text'>Linear Algebra: Definition of Matrix Multiplication</title><content type='html'>Read this &lt;a href="http://en.wikipedia.org/wiki/Matrix_multiplication"&gt;wikipedia article&lt;/a&gt;, up to but not including the section labelled the proportions-vectors method.&lt;br /&gt;&lt;br /&gt;I hope to explain all this at the bigeinning of next class.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113996561351287908?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113996561351287908/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113996561351287908' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113996561351287908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113996561351287908'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/linear-algebra-definition-of-matrix.html' title='Linear Algebra: Definition of Matrix Multiplication'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113996537151428023</id><published>2006-02-14T16:59:00.000-08:00</published><updated>2006-02-14T17:02:51.526-08:00</updated><title type='text'>Linear Algebra: Definition of Dot Product</title><content type='html'>From &lt;a href="http://en.wikipedia.org/wiki/Dot_product"&gt;wikipedia&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;In &lt;a href="http://en.wikipedia.org/wiki/Mathematics" title="Mathematics"&gt;mathematics&lt;/a&gt;, the &lt;b&gt;dot product&lt;/b&gt;, also known as the &lt;b&gt;scalar product&lt;/b&gt;, is a &lt;a href="http://en.wikipedia.org/wiki/Binary_operation" title="Binary operation"&gt;binary operation&lt;/a&gt; which takes two &lt;a href="http://en.wikipedia.org/wiki/Vector_%28spatial%29" title="Vector (spatial)"&gt;vectors&lt;/a&gt; and returns a &lt;a href="http://en.wikipedia.org/wiki/Scalar" title="Scalar"&gt;scalar&lt;/a&gt; quantity. It is the standard &lt;b&gt;&lt;a href="http://en.wikipedia.org/wiki/Inner_product_space" title="Inner product space"&gt;inner product&lt;/a&gt;&lt;/b&gt; of the &lt;a href="http://en.wikipedia.org/wiki/Euclidean_space" title="Euclidean space"&gt;Euclidean space&lt;/a&gt;. &lt;p&gt;The dot product of two vectors &lt;b&gt;a&lt;/b&gt; = [&lt;i&gt;a&lt;/i&gt;&lt;sub&gt;1&lt;/sub&gt;, &lt;i&gt;a&lt;/i&gt;&lt;sub&gt;2&lt;/sub&gt;, … , &lt;i&gt;a&lt;/i&gt;&lt;sub&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sub&gt;] and &lt;b&gt;b&lt;/b&gt; = [&lt;i&gt;b&lt;/i&gt;&lt;sub&gt;1&lt;/sub&gt;, &lt;i&gt;b&lt;/i&gt;&lt;sub&gt;2&lt;/sub&gt;, … , &lt;i&gt;b&lt;/i&gt;&lt;sub&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sub&gt;] is by definition&lt;/p&gt; &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4161/206/1600/a.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/4161/206/400/a.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;where Σ denotes &lt;a href="http://en.wikipedia.org/wiki/Addition#Summation_notation" title="Addition"&gt;summation notation&lt;/a&gt;. For example, the dot product of two three-dimensional vectors [1, 3, −2] and [4, −2, −1] is&lt;/p&gt;  &lt;dl&gt; &lt;dd&gt;[1, 3, −2]·[4, −2, −1] = 1×4 + 3×(−2) + (−2)×(−1) = 0.&lt;/dd&gt; &lt;/dl&gt;  &lt;p&gt;Using &lt;a href="http://en.wikipedia.org/wiki/Matrix_multiplication" title="Matrix multiplication"&gt;matrix multiplication&lt;/a&gt; and treating the &lt;a href="http://en.wikipedia.org/wiki/Row_vector" title="Row vector"&gt;row vectors&lt;/a&gt; as 1×&lt;i&gt;n&lt;/i&gt; &lt;a href="http://en.wikipedia.org/wiki/Matrix_%28math%29" title="Matrix (math)"&gt;matrices&lt;/a&gt;, the dot product can also be written as&lt;/p&gt; &lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4161/206/1600/b.png"&gt;&lt;img style="cursor: pointer;" src="http://photos1.blogger.com/blogger/4161/206/400/b.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt; where &lt;b&gt;b&lt;/b&gt;&lt;sup&gt;T&lt;/sup&gt; denotes the &lt;a href="http://en.wikipedia.org/wiki/Transpose" title="Transpose"&gt;transpose&lt;/a&gt; of the matrix &lt;b&gt;b&lt;/b&gt;. Using the example from above, this would result in a 1×3 matrix (i.e. vector) multiplied by a 3×1 vector (which, by virtue of the matrix multiplication, results in a 1×1 matrix):&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4161/206/1600/c.png"&gt;&lt;img style="cursor: pointer;" src="http://photos1.blogger.com/blogger/4161/206/400/c.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113996537151428023?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113996537151428023/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113996537151428023' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113996537151428023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113996537151428023'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/linear-algebra-definition-of-dot.html' title='Linear Algebra: Definition of Dot Product'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113984210144459372</id><published>2006-02-13T06:45:00.000-08:00</published><updated>2006-02-13T06:48:21.470-08:00</updated><title type='text'>A bit on regular expressions</title><content type='html'>From &lt;a href="http://64.233.179.104/search?q=cache:qFTs-glkDrIJ:en.wikipedia.org/wiki/Regular_expression+regular+expressions&amp;hl=en&amp;amp;gl=us&amp;ct=clnk&amp;amp;cd=6"&gt;wikipedia&lt;/a&gt;:&lt;br /&gt;&lt;p&gt;Regular expressions consist of constants and operators that denote sets of strings and operations over these sets, respectively. Given a finite alphabet Σ the following constants are defined:&lt;/p&gt;  &lt;ul&gt; &lt;li&gt;(&lt;i&gt;empty set&lt;/i&gt;) &lt;span class="Unicode"&gt;∅&lt;/span&gt; denoting the set &lt;span class="Unicode"&gt;∅&lt;/span&gt;&lt;/li&gt;&lt;li&gt;(&lt;i&gt;empty string&lt;/i&gt;) ε denoting the set {ε}&lt;/li&gt;&lt;li&gt;(&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Literal_string" title="Literal string"&gt;literal character&lt;/a&gt;&lt;/i&gt;) &lt;i&gt;a&lt;/i&gt; in Σ denoting the set {&lt;i&gt;a&lt;/i&gt;}&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;and the following operations:&lt;/p&gt;  &lt;ul&gt; &lt;li&gt;(&lt;i&gt;concatenation&lt;/i&gt;) &lt;i&gt;RS&lt;/i&gt; denoting the set { αβ | α in &lt;i&gt;R&lt;/i&gt; and β in &lt;i&gt;S&lt;/i&gt; }. For example {"ab", "c"}{"d", "ef"} = {"abd", "abef", "cd", "cef"}.&lt;/li&gt;&lt;li&gt;(&lt;i&gt;alternation&lt;/i&gt;) &lt;i&gt;R|S&lt;/i&gt; denoting the set union of &lt;i&gt;R&lt;/i&gt; and &lt;i&gt;S&lt;/i&gt;.&lt;/li&gt;&lt;li&gt;(&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Kleene_star" title="Kleene star"&gt;Kleene star&lt;/a&gt;&lt;/i&gt;) &lt;i&gt;R&lt;/i&gt;* denoting the smallest &lt;a href="http://en.wikipedia.org/wiki/Superset" title="Superset"&gt;superset&lt;/a&gt; of &lt;i&gt;R&lt;/i&gt; that contains ε and is closed under string concatenation. This is the set of all strings that can be made by concatenating zero or more strings in &lt;i&gt;R&lt;/i&gt;. For example, {"ab", "c"}* = {ε, "ab", "c", "abab", "abc", "cab", "cc", "ababab", ... }.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The above constants and operators form a &lt;a href="http://en.wikipedia.org/wiki/Kleene_algebra" title="Kleene algebra"&gt;Kleene algebra&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Many textbooks use the symbols &lt;span class="Unicode"&gt;∪&lt;/span&gt;, &lt;span class="Unicode"&gt;+&lt;/span&gt;, or &lt;span class="Unicode"&gt;∨&lt;/span&gt; for alternation instead of the vertical bar.&lt;/p&gt;  &lt;p&gt;To avoid brackets it is assumed that the Kleene star has the highest priority, then concatenation and then set union. If there is no ambiguity then brackets may be omitted. For example, (ab)c is written as abc and a|(b(c*)) can be written as a|bc*.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Examples:&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt; &lt;li&gt;a|b* denotes {ε, &lt;i&gt;a&lt;/i&gt;, &lt;i&gt;b&lt;/i&gt;, &lt;i&gt;bb&lt;/i&gt;, &lt;i&gt;bbb&lt;/i&gt;, ...}&lt;/li&gt;&lt;li&gt;(a|b)* denotes the set of all strings consisting of any number of &lt;i&gt;a&lt;/i&gt; and &lt;i&gt;b&lt;/i&gt; symbols, including the empty string&lt;/li&gt;&lt;li&gt;b*(ab*)* the same&lt;/li&gt;&lt;li&gt;ab*(c|ε) denotes the set of strings starting with &lt;i&gt;a&lt;/i&gt;, then zero or more &lt;i&gt;b&lt;/i&gt;s and finally optionally a &lt;i&gt;c&lt;/i&gt;.&lt;/li&gt;&lt;li&gt;((a|ba(aa)*b)(b(aa)*b)*(a|ba(aa)*b)|b(aa)*b)*(a|ba(aa)*b)(b(aa)*b)* denotes the set of all strings which contain an even number of &lt;i&gt;b&lt;/i&gt;s and an odd number of &lt;i&gt;a&lt;/i&gt;s. Note that this &lt;b style="color: black; background-color: rgb(255, 255, 102);"&gt;regular&lt;/b&gt; expression is of the form (&lt;i&gt;X&lt;/i&gt; &lt;i&gt;Y&lt;/i&gt;*&lt;i&gt;X&lt;/i&gt; U &lt;i&gt;Y&lt;/i&gt;)*&lt;i&gt;X&lt;/i&gt; &lt;i&gt;Y&lt;/i&gt;* with &lt;i&gt;X&lt;/i&gt; = a|ba(aa)*b and &lt;i&gt;Y&lt;/i&gt; = b(aa)*b.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The formal definition of &lt;b style="color: black; background-color: rgb(255, 255, 102);"&gt;regular&lt;/b&gt; &lt;b style="color: black; background-color: rgb(160, 255, 255);"&gt;expressions&lt;/b&gt; is purposefully parsimonious and avoids defining the redundant quantifiers ? and +, which can be expressed as follows: &lt;i&gt;a&lt;/i&gt;&lt;sup&gt;+&lt;/sup&gt;= aa*, and &lt;i&gt;a&lt;/i&gt;? = (ε|a). Sometimes the complement operator ~ is added; ~&lt;i&gt;R&lt;/i&gt; denotes the set of all strings over Σ that are not in &lt;i&gt;R&lt;/i&gt;. The complement operator is redundant: it can always be expressed by only using the other operators.&lt;/p&gt;  &lt;p&gt;&lt;b style="color: black; background-color: rgb(255, 255, 102);"&gt;Regular&lt;/b&gt; &lt;b style="color: black; background-color: rgb(160, 255, 255);"&gt;expressions&lt;/b&gt; in this sense can express exactly the class of languages accepted by &lt;a href="http://en.wikipedia.org/wiki/Finite_state_automaton" title="Finite state automaton"&gt;finite state automata&lt;/a&gt;: the &lt;a href="http://en.wikipedia.org/wiki/Regular_language" title="Regular language"&gt;&lt;b style="color: black; background-color: rgb(255, 255, 102);"&gt;regular&lt;/b&gt; languages&lt;/a&gt;. There is, however, a significant difference in compactness: some classes of regular languages can only be described by automata that grow &lt;a href="http://en.wikipedia.org/wiki/Exponential_growth" title="Exponential growth"&gt;exponentially&lt;/a&gt; in size, while the length of the required regular expressions only grow linearly. Regular expressions correspond to the type 3 &lt;a href="http://en.wikipedia.org/wiki/Formal_grammar" title="Formal grammar"&gt;grammars&lt;/a&gt; of the &lt;a href="http://en.wikipedia.org/wiki/Chomsky_hierarchy" title="Chomsky hierarchy"&gt;Chomsky hierarchy&lt;/a&gt; and may be used to describe a &lt;a href="http://en.wikipedia.org/wiki/Regular_language" title="Regular language"&gt; regular language&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113984210144459372?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113984210144459372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113984210144459372' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113984210144459372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113984210144459372'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/bit-on-regular-expressions.html' title='A bit on regular expressions'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113975402060842061</id><published>2006-02-12T06:16:00.000-08:00</published><updated>2006-02-12T06:20:20.616-08:00</updated><title type='text'>BNF in the book</title><content type='html'>BNF is mentioned briefly in chapter 3, on page 96, in the book, and is described in greater detail in chapter 4, pgs 148-156&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113975402060842061?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113975402060842061/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113975402060842061' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113975402060842061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113975402060842061'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/bnf-in-book.html' title='BNF in the book'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113946179733930555</id><published>2006-02-08T21:06:00.000-08:00</published><updated>2006-02-08T22:19:36.296-08:00</updated><title type='text'>Class IV: Describing Syntax - BNF</title><content type='html'>Formal definition of the syntax.&lt;br /&gt;Why?&lt;br /&gt;1) feedback cycle in language formation&lt;br /&gt;2) implementors of compilers/interpreters&lt;br /&gt;3) users of language&lt;br /&gt;&lt;br /&gt;syntax = form of the language, vs. semantics = meaning of language&lt;br /&gt;&lt;br /&gt;syntax of if:&lt;br /&gt;if ({expr}&lt;expr&gt;)  {statement}&lt;statement&gt;&lt;br /&gt;but this tells us nothing about semantics.&lt;br /&gt;&lt;br /&gt;ALGOL difficulties.&lt;br /&gt;&lt;br /&gt;Describing Syntax:&lt;br /&gt;1) Languages (natural and programming) are sets of strings of chars from an alphabet. These strings are &lt;span style="font-weight: bold;"&gt;sentences&lt;/span&gt; or statements. Syntax rules: which sentences are in the language.&lt;br /&gt;&lt;br /&gt;Formal descriptions often don't deal with basic parts - lexemes, which might be specified by a separate lexical specification. Lex vs. Yacc. Lexemes: identifiers, literals, ops, keywords. programs = string of chars, or string of lexemes.&lt;br /&gt;&lt;br /&gt;token = category of its lexemes. the output of Lex.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;identifier&lt;/span&gt; might be total, count, etc..&lt;br /&gt;plus_op just has + as the literal&lt;br /&gt;&lt;br /&gt;index = 2 * count + 17;&lt;br /&gt;&lt;br /&gt;Q: what are the tokens, what are the lexemes?&lt;br /&gt;&lt;br /&gt;2) Two ways of defining lang: lang recognizer vs. lang generator. R (recognizer) takes in input and tells if it valid program. G generates all possible programs. These are related problems.&lt;br /&gt;&lt;br /&gt;3) Formal methods of Describing Syntax:&lt;br /&gt;&lt;br /&gt;BNF - Backus Naur Form. related to Chomsky's context free grammars, in context of natural language. ALGOL 58, ALGOL 60. Panini to describe Sanskrit.&lt;br /&gt;&lt;br /&gt;series of rules, productions.&lt;br /&gt;Alas, the limits of blogspot. {} instead of pointy brackets.&lt;br /&gt;&lt;assign&gt;{assign} -&gt; {var} = {expression}&lt;var&gt;&lt;expression&gt;&lt;br /&gt;&lt;br /&gt;terminals vs. nonterminals. capital vs. lowercase. BNF grammar = collection of rules.&lt;br /&gt;&lt;br /&gt;| for "or." Pascal:&lt;br /&gt;&lt;if_statement&gt;{if_statement} -&gt; if {logic_expression}&lt;logic_expr&gt; then {statement}&lt;br /&gt;| &lt;/logic_expr&gt;&lt;/if_statement&gt;&lt;/expression&gt;&lt;/var&gt;&lt;/assign&gt;&lt;/statement&gt;&lt;/expr&gt;{if_statement} -&gt; if {logic_expression} then {statement} else {statement}&lt;br /&gt;&lt;br /&gt;&lt;expr&gt;&lt;statement&gt;&lt;assign&gt;&lt;var&gt;&lt;expression&gt;&lt;if_statement&gt;&lt;if_statement&gt;&lt;logic_expr&gt;&lt;statement&gt;&lt;statement&gt;&lt;if_statement&gt;&lt;logic_expr&gt;&lt;statement&gt;&lt;logic_expr&gt;&lt;statement&gt;&lt;statement&gt;&lt;br /&gt;use recursion to describe lists:&lt;br /&gt;&lt;identifier_list&gt;{identifier_list} -&gt; identifier | identifier, {identifier_list}&lt;br /&gt;&lt;identifier_list&gt;&lt;/identifier_list&gt;&lt;br /&gt;&lt;/identifier_list&gt;&lt;/statement&gt;&lt;/statement&gt;&lt;/logic_expr&gt;&lt;/statement&gt;&lt;/logic_expr&gt;&lt;/if_statement&gt;&lt;/statement&gt;&lt;/statement&gt;&lt;/logic_expr&gt;&lt;/if_statement&gt;&lt;/if_statement&gt;&lt;/expression&gt;&lt;/var&gt;&lt;/assign&gt;&lt;/statement&gt;&lt;/expr&gt;Grammars, derivations:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Start symbol&lt;/span&gt; S, {program}. Sentence generation called &lt;span style="font-weight: bold;"&gt;derivation&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;{program} -&gt; &lt;span style="font-weight: bold;"&gt;begin&lt;/span&gt; {statement_list} &lt;span style="font-weight: bold;"&gt;end&lt;br /&gt;&lt;/span&gt;{statement_list} -&gt; {statement} | {statement} ; {statement_list}&lt;br /&gt;{statement} -&gt; {var} = {expression}&lt;br /&gt;{var} -&gt; A | B | C&lt;br /&gt;{expression} -&gt; {var} + {var} | {var} - {var} | {var}&lt;br /&gt;&lt;br /&gt;show derivation for &lt;span style="font-weight: bold;"&gt;begin&lt;/span&gt; A = B + C; B = C &lt;span style="font-weight: bold;"&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;derivation order matters not, but this common approach is &lt;span style="font-weight: bold;"&gt;leftmost derivation&lt;/span&gt;.&lt;br /&gt;HW: To implement such a grammar in C++ using STL and rand function, of by labelling rules.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Simple Grammar for Assignment&lt;/span&gt;:&lt;br /&gt;{assign} -&gt; {id} = {expr}&lt;br /&gt;{id} -&gt; A | B | C&lt;br /&gt;{expr} -&gt; {id} + {expr} | {id} * {expr} | ( {expr} ) | {id}&lt;br /&gt;&lt;br /&gt;show derivation for A = B * (A+C)&lt;br /&gt;&lt;br /&gt;4) &lt;span style="font-weight: bold;"&gt;Parse trees&lt;br /&gt;&lt;/span&gt;show parse tree for above. parse tree matches a derivation.&lt;br /&gt;&lt;br /&gt;5) Ambiguity&lt;br /&gt;An ambiguous grammar:&lt;br /&gt;&lt;br /&gt;{assign} -&gt; {id} = {expr}&lt;br /&gt;{id} -&gt; A | B | C&lt;br /&gt;{expr} -&gt; {expr} + {expr} | {expr} * {expr} | ( {expr} ) | {id}&lt;br /&gt;&lt;br /&gt;without using parentheses, what is the meaning of A = B + C * A?&lt;br /&gt;Two parse trees, one with the first expansion of {expr} being the *, the other with the first being the +. Lower down in the tree, the higher its precedence.&lt;br /&gt;&lt;br /&gt;No way to uniquely define the meaning of the structure.&lt;br /&gt;&lt;br /&gt;6) Operator precedence:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;An unambiguous grammar&lt;/span&gt;.&lt;br /&gt;First, simple, example where went to {id} was unambiguous, but wrong &lt;span style="font-weight: bold;"&gt;precedence&lt;/span&gt;. Rightmost is lowest in tree, thus highest precedence.&lt;br /&gt;Solution:&lt;br /&gt;&lt;br /&gt;{assign} -&gt; {id} = {expr}&lt;br /&gt;{id} -&gt; A | B | C&lt;br /&gt;{expr} -&gt; {expr} + {term} | {term}&lt;br /&gt;{term} -&gt; {term} * {factor} | {factor}&lt;br /&gt;{factor} -&gt; ({expr}) | {id}&lt;br /&gt;&lt;br /&gt;show derivation of A = B + C * A on board, and simultaneously draw parse tree.&lt;br /&gt;&lt;br /&gt;7) Associativity.&lt;br /&gt;A = B + C + A&lt;br /&gt;does grouping, ordering matter? Based on prev grammar, would do B + C at lowest level, first. Does in cases of large floats with limited precision. Using our unambiguous grammar, we get a left associative interpretation. (Right associative not possible because we do not have {expr} going into two {expr}s. Left associative because recursion all the way to the left. Left recursive. Can make &lt;span style="font-weight: bold;"&gt;right recursive&lt;/span&gt; and thus right associative.&lt;br /&gt;&lt;br /&gt;e.g.&lt;br /&gt;&lt;br /&gt;{factor} --&gt; {expr} ** {factor} | {expr}&lt;br /&gt;{expr} --&gt; ({expr}) | {id}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Unambiguous if-else&lt;/span&gt;&lt;br /&gt;look at if-else definition above. if have {statement} -&gt; {if_statement}, ambiguity. example in C. show the two parse trees. can require &lt;span style="font-weight: bold;"&gt;begin&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;end&lt;/span&gt;&lt;br /&gt;an unambiguous grammar:&lt;br /&gt;the rule is that an else is &lt;span style="font-weight: bold;"&gt;matched&lt;/span&gt; with nearest previous &lt;span style="font-weight: bold;"&gt;unmatched&lt;/span&gt; then.&lt;br /&gt;&lt;br /&gt;{statement} -&gt; {matched} | {unmatched}&lt;br /&gt;{matched} -&gt; if {logic_expr} then {matched} else {matched} | any non-if statement&lt;br /&gt;{unmatched} -&gt; if {logic_expr} then {statement} |&lt;br /&gt; if {logic_expr} then {matched} else {unmatched}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;EBNF&lt;br /&gt;&lt;/span&gt;{selection} -&gt; if ({expr} ) {statement} [else {statement} ]&lt;br /&gt;brackets for optional component rather than |. Optional recurring via &lt;span style="font-weight: bold;"&gt;actual&lt;/span&gt; curly braces, rather than using recursion:&lt;br /&gt;{ident_list} -&gt; {identifier} &lt;span style="font-weight: bold;"&gt;{{identifier}}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;place options in non-terminal parentheses and separate via |.&lt;br /&gt;&lt;br /&gt;Some allow number after right } to indicate upper limit on repetitions, or + to mean 1+.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113946179733930555?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113946179733930555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113946179733930555' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113946179733930555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113946179733930555'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/class-iv-describing-syntax-bnf.html' title='Class IV: Describing Syntax - BNF'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113942642045841231</id><published>2006-02-08T11:19:00.000-08:00</published><updated>2006-02-08T11:20:20.516-08:00</updated><title type='text'></title><content type='html'>LEX and YACC &lt;a href="http://ds9a.nl/lex-yacc/cvs/lex-yacc-howto.html"&gt;tutorial&lt;/a&gt;.&lt;br /&gt;regular expressions and context free grammars&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113942642045841231?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113942642045841231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113942642045841231' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113942642045841231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113942642045841231'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/lex-and-yacc-tutorial.html' title=''/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113934243402620760</id><published>2006-02-07T11:59:00.000-08:00</published><updated>2006-02-07T12:00:34.040-08:00</updated><title type='text'>Passing Subroutines to Other Subroutines in FORTRAN</title><content type='html'>I hope to mention this in class today. Here is &lt;a href="http://groups.google.com/group/comp.lang.fortran/browse_frm/thread/81396136ad05997f/78b1653edc27d73c?lnk=st&amp;q=%22pass+a+subroutine%22+fortran&amp;amp;rnum=2&amp;hl=en#78b1653edc27d73c"&gt;a discussion of how to&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span class="fixed_width"  style="font-family:Courier, Monospaced;"&gt;The old-fashioned, non-profile-safe way:&lt;br /&gt;      SUBROUTINE SUB (ACTION)&lt;br /&gt;      EXTERNAL ACTION&lt;br /&gt;* ...&lt;br /&gt;      CALL ACTION (arguments)&lt;br /&gt;* ...&lt;br /&gt;      END&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="fixed_width"  style="font-family:Courier, Monospaced;"&gt;      SUBROUTINE DEED (args)&lt;br /&gt;* ...&lt;br /&gt;      END&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="fixed_width"  style="font-family:Courier, Monospaced;"&gt;* ...&lt;br /&gt;      EXTERNAL DEED&lt;br /&gt;      CALL SUB (DEED) &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113934243402620760?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113934243402620760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113934243402620760' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113934243402620760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113934243402620760'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/passing-subroutines-to-other.html' title='Passing Subroutines to Other Subroutines in FORTRAN'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113882389032661268</id><published>2006-02-01T11:44:00.000-08:00</published><updated>2006-02-02T11:13:21.403-08:00</updated><title type='text'>Class II - Some Early History - Pseudocodes and FORTRAN</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Machine Code&lt;/span&gt;:&lt;br /&gt;benefits: fast&lt;br /&gt;drawback: hard to write. ADD might be 14. Readability. Absolute addressing. Recomputing locations, NOPs for deletions. Gave rise to Assembler, with same benefit.&lt;br /&gt;&lt;br /&gt;issues:&lt;br /&gt;floats were simulated. indexing missing - adding var quantity to fixed address.&lt;br /&gt;&lt;br /&gt;instead, bec of the von Neumann architecture, since the instruction was in memory, they modified the address portion of the instruction, which was error prone.&lt;br /&gt;&lt;br /&gt;thus, subroutines to do floats, and to index. since most of time spent simulating floats, little overhead comparatively for doing other things. Thus, pseudocode interpreters were natural developement.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Short Code&lt;/span&gt;&lt;br /&gt;Words are 72 bits, as 12 6-bit bytes. mathematic expressions to be evaluated. Byte-pair values. Some codes:&lt;br /&gt;&lt;pre&gt;01 -    06 abs         1n (n+2)nd power&lt;br /&gt;02 )    07 +           2n (n+2)nd root&lt;br /&gt;03 =    08 pause       4n if &lt;= n&lt;br /&gt;04 /    09 (           58 print and tab &lt;/pre&gt;implemented as pure interpreted. 50X slower than machine code.&lt;br /&gt;&lt;br /&gt;X0 = SQRT(ABS(Y0))&lt;br /&gt;00 X0 03 20 Y0&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Homework&lt;/span&gt;: How would we write Z0 = CUBEROOT(Y1 * Z0)? How would we write Z0=Y0?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;pseudocode&lt;/span&gt; - generally used today as english description of code, not always going into specifics of implementation. here, means something else: an instruction diff than that provided by the machine. initially presented as way of saving space in memory, since pseudocode more compact.&lt;br /&gt;&lt;br /&gt;Implemented a &lt;span style="font-weight: bold;"&gt;virtual computer&lt;/span&gt;, with own data types and operations, atop an actual computer.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Automation Principle&lt;/span&gt;: Automate mechanical, tedious, error-prone activities.&lt;br /&gt;Also, simpler to understand since fewer exceptions, thus &lt;span style="font-weight: bold;"&gt;Regularity principle&lt;/span&gt;: Regular rules, w/o exceptions, are easier to read, learn, describe, implement.&lt;br /&gt;&lt;br /&gt;Compiling routines mentioned in book are predecessor to macros.&lt;br /&gt;&lt;br /&gt;Book designs a pseudocode, based on following capabilities:&lt;br /&gt;float arithmetic and comparison, indexing, transfer of control, IO.&lt;br /&gt;Syntax: Use numbers since many did not have alphabetic IO, 1 number on each card, each instruction one word. Choose how big addresses to be. Machine has only 2000 locations, so allow 3 decimal digits, and other 1000 for interpreter and program.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Impossible error Principle&lt;/span&gt;: rather than detecting errors, may them impossible to commit.&lt;br /&gt;&lt;br /&gt;Since address is 3 digits and word is 10 digits, restricted to refer to 3 variables (mem locations), so commands of the form&lt;br /&gt;operator operand1 operand2 dest. +1 means ADD&lt;br /&gt;+1 010 150 200&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Orthogonality Principle&lt;/span&gt;: they use + and - sign to denote reverse operations. +/-, */ divide, square/squareroot. Two orthogonal, or indep mechanisms: the number = operation, and sign=direct or reverse. two primitives combine in various ways. corollary of regularity principle.&lt;br /&gt;Less to remember.&lt;br /&gt;&lt;br /&gt;But orthogonality can go to far.&lt;br /&gt;&lt;br /&gt;Similarly, = vs !=, and &gt;= vs &lt;. Need not reverse since just reverse order of operands.  no need for positive, negative, zero tests. Can adopt convention that 000 contains 0.  Moving: could be implemented via adding to 0, but adding floats is slow. (So do check if adding to 0 and make that a move op!)  Chose 0 so that ops have easy to remember vals: move, add, multiply, square. regularity principle.  Indexing and loops: x[i] -&gt; z; x -&gt; y[i]&lt;br /&gt;+6 xxx iii zzz&lt;br /&gt;-6 xxx yyy iii&lt;br /&gt;&lt;br /&gt;Abstract out code common to all loops. &lt;span style="font-weight: bold;"&gt;Abstraction principle&lt;/span&gt;, corollary of Automation principle. eliminates possible source of error. "Avoid requiring something be stated more than once, factor out recurring pattern."&lt;br /&gt;+7 iii nnn ddd&lt;br /&gt;i = index; n=upper bound; d=location of beginning of loop. this is a do loop.&lt;br /&gt;+8: read. -8 print&lt;br /&gt;+9: stop&lt;br /&gt;&lt;br /&gt;memory cards read in program as well as initial data, separated by 10 9's.&lt;br /&gt;pg 20 has sample program.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Construct an interpreter for pseudocode.&lt;br /&gt;&lt;/span&gt;read-execute cycle: called fetch-execute cycle before.&lt;br /&gt;&lt;br /&gt;decoding by extracting their parts. &lt;span style="font-weight: bold;"&gt;similar to lexical parsing&lt;/span&gt;.&lt;br /&gt;dest := abs(instruction) mod 1000&lt;br /&gt;&lt;br /&gt;then, based on sign and instruction:&lt;br /&gt;&lt;br /&gt;if sign is + then&lt;br /&gt;do case op of:&lt;br /&gt;0: move;&lt;br /&gt;1: add;&lt;br /&gt;...&lt;br /&gt;if sign is - then&lt;br /&gt;do case op of&lt;br /&gt;0: // op if have negative 0&lt;br /&gt;1: subtract;&lt;br /&gt;&lt;br /&gt;etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Computational instructions&lt;/span&gt;:&lt;br /&gt;multiply:&lt;br /&gt;data[dest] := floating_product(Data[operand1], Data[operand2])&lt;br /&gt;&lt;br /&gt;Test equality:&lt;br /&gt;if floating equality (Data[operand1], Data[operand2]) then IP:=dest&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Debugging&lt;/span&gt;:&lt;br /&gt;Add to fetch-execute cycle a print of IP and the contents at IP&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Statement Labels&lt;br /&gt;&lt;/span&gt;As mentioned above, inserts into code shifts everything over.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Labeling Principle&lt;/span&gt;: Do not require the user to know absolute pos of item in a list, but rather associate labels with any pos that must be referenced elsewhere.&lt;br /&gt;&lt;br /&gt;-7 0LL 000 000&lt;br /&gt;&lt;br /&gt;this binds a symbolic label to absolute position.&lt;br /&gt;&lt;br /&gt;Thus, equality test becomes&lt;br /&gt;+4 xxx yyy 0LL&lt;br /&gt;&lt;br /&gt;but then end up scanning program for the labels. can make label table instead.&lt;br /&gt;&lt;br /&gt;By extension, symbol table for vars. In the data section:&lt;br /&gt;+0 sss nnn 000&lt;br /&gt;+d ddd ddd ddd&lt;br /&gt;&lt;br /&gt;+0 666 150 000&lt;br /&gt;+0 000 000 001&lt;br /&gt;inits a 150 num array to 1s&lt;br /&gt;&lt;br /&gt;This &lt;span style="font-weight: bold;"&gt;binds&lt;/span&gt; the symbol to the location at load time. And loader takes care of storage allocation, instead of having to initialize them all via cards like in the past.&lt;br /&gt;&lt;br /&gt;+6 666 111 222&lt;br /&gt;V222 := V666[V111]&lt;br /&gt;&lt;br /&gt;Can check type info in symbol table to avoid out of bound errors.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Security Principle&lt;/span&gt;:&lt;br /&gt;No prog that violates the def of language or intended structure should escape detection.&lt;br /&gt;&lt;br /&gt;Extend to symbolic pseudo-code. Symbols for vars, ops.&lt;br /&gt;&lt;br /&gt;To allow symbolic, look up ops and vars on symbol table and replace them with actual values, and then interpret. (Alteratively, could have interp directly.) Thus, first &lt;span style="font-weight: bold;"&gt;translation &lt;/span&gt;then interpretation.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;In sum&lt;/span&gt;, pseudocodes provide virtual computer, which was more regular and at a higher level. Increased security, allow debugging such as traces (and breakpoints).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN&lt;/span&gt;&lt;br /&gt;And the IBM 704.&lt;br /&gt;The engineer-coder bottleneck. On other hand, speed of execution an issue.&lt;br /&gt;The IBM 704 developed together &lt;span style="font-weight: bold;"&gt;with&lt;/span&gt; the language, thus tightly integrated. IBM 704 supported floats directly, so no need for simulation, thus speed issue against pseudocodes, thus compiled language.&lt;br /&gt;Skip features in language which not quickly produced in hardware. Thus, limits on statements, on control structures, no recursion.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN 0&lt;/span&gt;: A design document. spoke of efficiency of machine code with ease of pseudocode. "FORTRAN would elim coding errors, thus little syntax error checking."&lt;br /&gt;&lt;br /&gt;Environment: Computers slow, small, unreliable. Used primarily of scientific applications. No existing efficient way to program computers. High cost of computers vs. programmers.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN I&lt;/span&gt;: Implementation introducing realities. Features: IO formatting, var names 6 chars, user defined subroutines, weird mathematical IF statement. DO Loop.&lt;br /&gt;From &lt;a href="http://en.wikipedia.org/wiki/Spaghetti_code"&gt;Wikipedia&lt;/a&gt;:&lt;br /&gt;&lt;pre&gt;10 dim i&lt;br /&gt;20 i = 0&lt;br /&gt;30 i = i + 1&lt;br /&gt;40 if i &lt;&gt; 10 then goto 90&lt;br /&gt;50 if i = 10 then goto 70&lt;br /&gt;60 goto 30&lt;br /&gt;70 print "Program Completed."&lt;br /&gt;80 end&lt;br /&gt;90 print i &amp; " squared = " &amp;amp; i * i&lt;br /&gt;100 goto 30&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;Here is the same code written using control structures.&lt;br /&gt;&lt;/p&gt; &lt;pre&gt;dim i&lt;br /&gt;for i = 1 to 10&lt;br /&gt;   print i &amp; " squared = " &amp;amp; square(i)&lt;br /&gt;next&lt;br /&gt;print "Program Completed."&lt;br /&gt;&lt;br /&gt;function square(i)&lt;br /&gt;   square = i * i&lt;br /&gt;end function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;No &gt; in charset, 704 had 3 way mathematic branch instruction, which replaced FORTRAN 0's IF.&lt;br /&gt;IF (arithmetic expression) N1, N2, N3&lt;br /&gt;&lt;br /&gt;DO Loop. Was posttest rather than pretest because of 704's architecture, as well as other control statements.&lt;br /&gt;No data typing. I_, J_, K_, L_, M_ are ints, rest are floats. because of scientific domain.&lt;br /&gt;&lt;br /&gt;largest part of time spent developing spend optimizing.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN II&lt;/span&gt;:&lt;br /&gt;besides other features, independent compilation of subs. otherwise would crash before compiling, limiting programs to 300 - 400 lines.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN IV&lt;/span&gt;:&lt;br /&gt;Explicit type declarations. Why is this important? reduce errors by type checking, do not introduce new vars erroneously, expand set of names.&lt;br /&gt;Logical IF construct.&lt;br /&gt;Pass subs as parameters to subs.&lt;br /&gt;How would we do this in C++? Digression into complex declarations in general.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Homework Assignment&lt;/span&gt; to print above avg nums in array.&lt;br /&gt;&lt;br /&gt;A &lt;a href="http://www.kcl.ac.uk/kis/support/cit/fortran/f90home.html#1.2"&gt;web site&lt;/a&gt; about development of FORTRAN - what features were added.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN 77&lt;/span&gt;: adds char string handling, logical loop control statements (rather than just for loops), IF with optional ELSE.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN 90&lt;/span&gt;: major differences. names up to 31 chars. ! as comment. collection of matrix functions: e.g. MATMUL, DOTPRODUCT, TRANSPOSE, MAXVAL, MINVAL, PRODUCT, SUM.  User defined data type called "derived type." Dynamic allocation of these types, and dynamic allocation and deallocation of arrays. Vs. prev. only had static data. Select case. Exit = break, cycle = continue of C; recursion. Modules (with public and private data and methods). specification of numeric precision, ";" as statement separator. Lines up to 132 chars in length.&lt;br /&gt;While array processing: A= B*Sin(A)&lt;br /&gt;deprecating features.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN 95&lt;/span&gt;: Minor changes. Forall, initialization of pointers, and of "derived types."&lt;br /&gt;Also, NULL function, automatic garbage collection.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FORTRAN 2003&lt;/span&gt;:&lt;br /&gt;Interop with C, international - allow , or . for decimal point. Access to command line arguments, environmental vars, procedure pointers, IO enhancements, OOP support, parameterized derived types, etc.&lt;br /&gt;&lt;br /&gt;Some linear algebra and graph algorithm introduction. Describe the algorithm.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Next Time&lt;/span&gt;: Names and Binding, in more than just FORTRAN.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113882389032661268?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113882389032661268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113882389032661268' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113882389032661268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113882389032661268'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/class-ii-some-early-history.html' title='Class II - Some Early History - Pseudocodes and FORTRAN'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113881917002253557</id><published>2006-02-01T10:13:00.000-08:00</published><updated>2006-02-02T10:09:16.256-08:00</updated><title type='text'>Class II - Some FORTRAN Basics - Assignment</title><content type='html'>This &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/"&gt;ftp site&lt;/a&gt; has a bunch of demo Fortran programs. For each Fortran file I specify, read each program to get a feel for what it does, and then copy the text of the file, compile it, and execute it.&lt;br /&gt;&lt;br /&gt;In each case, not every line is indented 6 spaces, so either make sure that each line &lt;span style="font-weight: bold;"&gt;is &lt;/span&gt;indented at least 6 spaces, or else save as *.f90. Otherwise, you will get a syntax error.&lt;br /&gt;&lt;br /&gt;1) A &lt;span style="font-weight: bold;"&gt;Kind &lt;/span&gt;is an integer specification of data type for primitives, in general matching the sizeof the data type in bytes. Read &lt;a href="http://www.osc.edu/hpc/manuals/ia64/docs2/f_ug/lim_kind.htm"&gt;this webpage&lt;/a&gt; for more details.&lt;br /&gt;&lt;br /&gt;Compile and run this &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex1a.f90"&gt;program&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;2) Data types can be defined with the keyword TYPE. Members can be accessed with %.&lt;br /&gt;Compile and run this &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex2a.f90"&gt;program&lt;/a&gt;, which creates and uses a derived type for intervals. As requested in the comment, change the program so that it prints the interval length instead.&lt;br /&gt;&lt;br /&gt;Compile and run &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex2b.f90"&gt;this program&lt;/a&gt; which demonstrates nested types.&lt;br /&gt;&lt;br /&gt;3) &lt;span style="font-weight: bold;"&gt;Pointers&lt;/span&gt;:&lt;br /&gt;Read &lt;a href="http://www.personal.psu.edu/faculty/j/h/jhm/f90/lectures/42.html"&gt;this document&lt;/a&gt; about FORTRAN pointers and array pointers. Then, compile and run &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex2c.f90"&gt;this program&lt;/a&gt;. Modify the program as suggested in the comments and see what happens.&lt;br /&gt;&lt;br /&gt;4) Do Loop and Cycle&lt;br /&gt;This &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex2d.f90"&gt;example&lt;/a&gt; demonstrates a do loop, equivalent to a for loop. Cycle is the equivalent of &lt;span style="font-weight: bold;"&gt;continue&lt;/span&gt; in C++.&lt;br /&gt;&lt;br /&gt;5) Nested do loops with names, in this &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex2f.f90"&gt;example&lt;/a&gt;.&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Exit&lt;/span&gt; is equivalent to &lt;span style="font-weight: bold;"&gt;break&lt;/span&gt;. Note that we can break out of multiple levels of loop because of the named loops. This is similar to the labelled breaks in Java.&lt;br /&gt;&lt;br /&gt;6) Select Case statement, as we have in VB6. Note this case statement works for ranges. Example &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex2g.f90"&gt;here&lt;/a&gt; and &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex2h.f90"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;7) Functions.&lt;br /&gt;Example &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex2i.f90"&gt;here&lt;/a&gt;. Note that just as in C, the types of parameters are not specified in the declaration, but just the names. The types are specified subsequently. LOGICAL means boolean. Note the INTENT keyword, which is used to specify that these parameters are being passed in but not out of the program. Note that the function name is also assigned a type, = to the return type, and that assigning to the function name has the effect of specifying the return value. This is also found in VB6.&lt;br /&gt;&lt;br /&gt;8) Arrays.&lt;br /&gt;Note that the : character is used to specify a range. 2:5 means 2 through 5. Either side can be optional. The , character separates indexes when dealing with a matrix. Thus, in C++:&lt;br /&gt;a[7][3]&lt;br /&gt;would be written a[7,3] in FORTRAN&lt;br /&gt;Try out &lt;a href="ftp://ftp.numerical.rl.ac.uk/pub/f90course/demo/ex2j.f90"&gt;this example&lt;/a&gt; and compare the source with the output carefully.&lt;br /&gt;&lt;br /&gt;9) Intended Assignments:&lt;br /&gt;A) Write a program that takes N as input, reads in N numbers into an array, and prints any number A[i] which is larger than the average.&lt;br /&gt;B) Take advantage of the built in matrix manipulation functions in FORTRAN to write a program that takes in N, the size of a directed graph, followed by a series of edges, terminated by -1. Compute whether the graph is strongly connected.&lt;br /&gt;C) Take advantage of the full capabilities of FORTRAN 90. Write a program that will take in a series of numbers, terminates by -1, and stores them in a binary search tree. Then take another series of numbers as input and output whether the numbers are in the binary tree. (All you need implement is insert and search).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113881917002253557?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113881917002253557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113881917002253557' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113881917002253557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113881917002253557'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/02/class-ii-some-fortran-basics.html' title='Class II - Some FORTRAN Basics - Assignment'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113873489746813013</id><published>2006-01-31T11:06:00.000-08:00</published><updated>2006-01-31T12:29:12.750-08:00</updated><title type='text'>Starting FORTRAN</title><content type='html'>A free Fortran compiler: &lt;a href="http://g95.sourceforge.net/"&gt;G95&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Download and install the binary under "Self-extracting Windows x86." Install to the C:\g95 directory.&lt;br /&gt;&lt;br /&gt;Now, make your first program, to print 'Hello World' ten times. Spacing matters:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;     PROGRAM HELLO&lt;br /&gt;     DO 10, I=1,10&lt;br /&gt;     PRINT *,'Hello World'&lt;br /&gt;  10 CONTINUE&lt;br /&gt;     STOP&lt;br /&gt;     END&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;save this file as hello.f in the c:\g95\bin directory.&lt;br /&gt;from the c:\g95\bin directory, type the following:&lt;br /&gt;g95 hello.f&lt;br /&gt;&lt;br /&gt;The compiler will create hello.exe in the same directory. Run it.&lt;br /&gt;&lt;br /&gt;Now edit the file and create a syntax error. Change * to *a. Try to recompile and see what happens.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113873489746813013?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113873489746813013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113873489746813013' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113873489746813013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113873489746813013'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/01/starting-fortran.html' title='Starting FORTRAN'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113865122744751692</id><published>2006-01-30T11:58:00.000-08:00</published><updated>2006-01-31T11:27:29.290-08:00</updated><title type='text'>Class I - Homework</title><content type='html'>&lt;ol&gt;&lt;li&gt;Buy the book&lt;/li&gt;&lt;li&gt;Send me an email. JoshWaxman {at} gmail [dot] com.&lt;/li&gt;&lt;li&gt;implement Pascal string in C or C++&lt;/li&gt;&lt;li&gt;write a program that uses logical XOR&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Read the first chapter (pg. 9-36)&lt;/li&gt;&lt;li&gt;The Regularity principle, mentioned on pg. 11 in the book, is similar to what concept mentioned in class?&lt;/li&gt;&lt;li&gt;Download and install the G95 Fortran compiler, and write and run the hello world program.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113865122744751692?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113865122744751692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113865122744751692' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113865122744751692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113865122744751692'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/01/class-i-homework.html' title='Class I - Homework'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113864686959147354</id><published>2006-01-30T10:29:00.000-08:00</published><updated>2006-01-30T17:31:12.710-08:00</updated><title type='text'>Class I - Preliminaries</title><content type='html'>&lt;ol&gt;&lt;li&gt;Why?&lt;/li&gt;&lt;ol&gt;&lt;li&gt;increased capacity to express ideas.&lt;br /&gt;what can say depends on vocabulary, and prog. language limits what can express. by knowing other langs, know more lang constructs. These language constructs can be similated. e.g. Pascal strings. &lt;span style="font-weight: bold;"&gt;first homework assignment.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;ability to choose appropriate language for the task. else fall back on what you know.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;ability to learn new languages. if know data abstraction, easier constructing abstract data types in Java. similar to natural lang - better know grammar of own lang, easier to learn other language. also, learning second lang tells you more about your own language. e.g. logical XOR. &lt;span style="font-weight: bold;"&gt;second homework assignment.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;better understand significance of implementation.&lt;br /&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;helps understand why designed as is --&gt; better use of the language. know which constructs to use.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;figure out bugs&lt;/li&gt;&lt;li&gt;understanding efficiency. how recursion works -&gt; why so slow&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Ability to design new languages. input format language.&lt;/li&gt;&lt;li&gt;enhancement of computing via natural selection. e.g. Algol 60 better control statements and other features than Fortran, but difficult to read and understand. Programmers did not appreciate features of Algol 60.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Programming domains -- produce languages that specifically suit it.&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Scientific applications&lt;/span&gt;: deal with floating point arithmetic, simple data structures. Most common: arrays, matrices; most common control structures: loops. Competition: assembly, so needed to be fast. Fortran, Algol 60.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Business Applications&lt;/span&gt;: produce reports, precise ways of describing and storing decimal numbers and chars, decimal arithmetic ops. COBOL. Also, spreadsheet and database systems.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;AI&lt;/span&gt;: Symbolic rather than numeric computation. Symbols, consisting of names instead of nums, are manipulated. Linked lists more convenient than arrays for this purpose. More flexibility required -- e.g. to create and run code segments during execution. LISP - functional language. Prolog - Logic programming.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Systems Programming&lt;/span&gt;: The OS and programming support tools = systems software. Fast execution (since always running) + low level features. Made special languages for the particular systems: IBM: PL/S, dialect of PL/I. Digital made BLISS, language just above assembly. Burroughs: extended ALGOL. UNIX written in C so easy to port - low level, efficient, easy to shoot self in foot.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Scripting Languages&lt;/span&gt;: Batch programming. DOS batch? &lt;span style="font-weight: bold;"&gt;sh = shell=&lt;/span&gt;calls to system subprograms&lt;span style="font-weight: bold;"&gt;. &lt;span style="font-weight: bold;"&gt;awk = &lt;/span&gt;&lt;/span&gt;for report generation, then became more general purpose. Perl began as &lt;span style="font-weight: bold;"&gt;sh + awk&lt;/span&gt;.&lt;br /&gt;tcl - scripting language; tk - method of building X-Window applications.&lt;br /&gt;Javascript.&lt;/li&gt;&lt;li&gt;Other special purpose languages. RPG - produce business reports, GPSS - systems simulation. Inform - Zork type games.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Lang Evaluation Criteria - What makes a language "good"&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Readability - ability to be understood - in terms of problem domain. use ill-suited lang, will be unreadable.&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Simplicity&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;ol&gt;&lt;ol&gt;&lt;li&gt;small vs. large num of lang components - learn subset.&lt;/li&gt;&lt;li&gt;feature multiplicity: + 1 vs. ++, which have slightly diff meanings&lt;/li&gt;&lt;li&gt;operator overloading, if misused. + on arrays to return scalar sum rather than vector sum.&lt;/li&gt;&lt;li&gt;but simplicity can go too far. consider assembly. no control statements, complex data structures.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Orthogonality&lt;/span&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;small # primitives combined in small # of ways, consistently&lt;/span&gt;&lt;/li&gt;&lt;li&gt;e.g. pointers should point to any type.&lt;/li&gt;&lt;li&gt;VAX:&lt;br /&gt;A Reg1, memory_cell&lt;br /&gt;AR Reg1, Reg2&lt;br /&gt;&lt;br /&gt;IBM:&lt;br /&gt;ADDL operand_1, operand2&lt;/li&gt;&lt;li&gt;i before e, except after c. confusing&lt;/li&gt;&lt;li&gt;lack of orthogonality in C: can return structs but not arrays. structs cannot hold void or struct of same type. (not true in C#, Java) Array el cannot be void or a function. (but can be func pointer) a + b where A is a pointer does different things depending on pointer type.&lt;/li&gt;&lt;li&gt;Too much orthogonality. ALGOL 68. conditionals can appear on left side of assignment, also declarations, etc., so long as result is location.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Functional vs. Imperative lang&lt;/span&gt;. Functional, such as LISP - single construct. But efficiency problems. (I would add also readability/writability)&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Control statements&lt;/span&gt;: gotos vs. while, for loops. spaghetti code. how to restrict: near targets, limited number, always precede targets except to form loops.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Data types and structures&lt;/span&gt;:&lt;/li&gt;&lt;ol&gt;&lt;li&gt;bool type in C++. timeout = 1 vs true.&lt;/li&gt;&lt;li&gt;Lack of structures in FORTRAN 77, req parallel arrays and use same subscript.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Syntax&lt;/span&gt;:&lt;/li&gt;&lt;ol&gt;&lt;li&gt;identifier forms. Basic: E or E3.&lt;/li&gt;&lt;li&gt;keywords that can identify. some lang, like FORTRAN 90, allows these to be used as var names as well.&lt;/li&gt;&lt;li&gt;end vs end if, end loop, {}&lt;/li&gt;&lt;li&gt;code self documenting such that semantics follows syntax. static has 2 or 3 meanings in C, C++. names such as "grep" requires special knowledge to understand.&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;li style="font-weight: bold;"&gt;Writability - &lt;span style="font-weight: normal;"&gt;how easy to code solution for given problem domain&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Simplicity, Orthogonality = less programmer need know, since limited constructs and few limits on how to combine them&lt;/li&gt;&lt;li&gt;Abstraction - allow definition and use of complicated structures and ops allowing details to be ignored. increases naturalness of expression. e.g. function, rather than repeating commands each time with diff variables, creating clutter. data abstraction: example above of parallel arrays. or how to implement a binary tree in fortran vs. in C.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Expressivity.&lt;/span&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;to make less cumbersome. count++. &lt;span style="font-weight: bold;"&gt;and then&lt;/span&gt; to do short circuit (automatic in C), for loop. syntactic sugar.&lt;/li&gt;&lt;/ol&gt;&lt;li style="font-weight: bold;"&gt;Reliability - &lt;span style="font-weight: normal;"&gt;performs to specs under all conditions&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;more important in specific domains - control airplanes, medical equipment, etc., but in general.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;type checking&lt;/span&gt; - C doesn't do it. C++ does. can cause errors&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;exception handling&lt;/span&gt; - Ada, C++, Java.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Aliasing&lt;/span&gt; - two items refer to same entity. can cause problems. but also powerful language feature. references, pointers, point to same location. unions.&lt;/li&gt;&lt;li&gt;Readability/Writability. unnaturalness leads to errors. also need maintain/modify.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Cost&lt;/span&gt; - diff definitions&lt;br /&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;training programmers, paying programmers to write it, time to compile, time to execute (and optimize diff things), price of the compiler/interpreter - Java, cost of poor reliability in human terms and in further business, cost of maintaining.&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;Other ways of evaluating langs exist. portability, generality (to wide range of applications), etc. and depends on perspective.&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;Influences on Lang Design&lt;/span&gt;:&lt;br /&gt;Computer Architecture: von Neumann, variables model memory cells, assignment models piping data to CPU, and iteration is most efficient, because instructions stored in memory in adjacent locations. Recursion, functional langs inefficient.&lt;br /&gt;Programming Methodologies: cost shift from hardware -&gt; software.&lt;br /&gt;type checking problems, lack of control statements.&lt;br /&gt;then, more from process oriented to data oriented - data structures, then object oriented programming.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Language Categories&lt;/span&gt;:&lt;br /&gt;Imperative, functional, Logic, Object oriented.&lt;br /&gt;Logic: rule based lang. instead of specifying exactly how things are done algorithmically, rules specified in any order and lang implementation system chooses execution order. Prolog.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Implementation Methods&lt;/span&gt;:&lt;br /&gt;cocentric circle diagram - bare machine, Macroinstruction interpreter, OS, C++ compiler, FORTRAN, C, Ada compiler, Assembler, Lisp interpreter, etc., all providing virtual language machine. OS command interpreter.&lt;br /&gt;A) Compilation. diagram&lt;br /&gt;Source program&lt;br /&gt;lexical analyzer ---lexical units--&gt; Syntax analyzer&lt;br /&gt;Syntax analyzer --- parse trees ---&gt; intermediate code generator/semantic analyzer&lt;br /&gt;&lt;br /&gt;both lex and syn output to symbol table, which feeds the intermediate code generator/semantic analyzer as well as the code generator&lt;br /&gt;&lt;br /&gt;intermediate code generator/semantic analyzer --intermediate code--&gt;code generator&lt;br /&gt;code generator --machine language--&gt;computer&lt;br /&gt;computer takes this and input and generates results.&lt;br /&gt;&lt;br /&gt;Linking step to link to system calls (addresses of functions)&lt;br /&gt;Based on von Neumann architechture, a &lt;span style="font-weight: bold;"&gt;fetch-execute cycle&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;initialize program counter&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;repeat &lt;/span&gt;forever&lt;br /&gt; fetch instruction pointed to by program counter&lt;br /&gt; program counter++&lt;br /&gt; decode instruction&lt;br /&gt; execute instruction&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;end repeat&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;von Neumann bottleneck&lt;/span&gt;&lt;/span&gt; a result of having to transfer instructions via the bus to the CPU.&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;benefits: speed&lt;br /&gt;examples: C, FORTRAN.&lt;br /&gt;&lt;br /&gt; B) Pure interpretation.&lt;br /&gt;No compiling. benefits - symbol table present. errors easily found and can give line number. can fix. Examples: Lisp, APL, batch files. C, C++, debug mode. Source program and input data go directly to the interpreter.&lt;br /&gt;drawbacks: slow.&lt;br /&gt;&lt;br /&gt;C) Hybrid. All steps up to intermediate code, preserve symbol table, but run the intermediate code. Java runs in both hybrid and full compile mode.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113864686959147354?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113864686959147354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113864686959147354' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113864686959147354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113864686959147354'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/01/class-i-preliminaries.html' title='Class I - Preliminaries'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21499889.post-113821002799401544</id><published>2006-01-25T09:17:00.000-08:00</published><updated>2006-01-30T10:28:52.480-08:00</updated><title type='text'>The Book For This Course</title><content type='html'>The book for this course is &lt;span class="title"&gt;&lt;span style="font-style: italic;"&gt;Principles of Programming Languages: Design, Evaluation, and Implementation&lt;/span&gt;, &lt;/span&gt;by Bruce J MacLennan. The ISBN number for the book is 0195113063.&lt;br /&gt;&lt;br /&gt;The book is available for purchase and partial viewing at a number of locations. It will probably cost about $25, plus shipping and handling.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://books.google.com/books?vid=ISBN0195113063&amp;id=d-Rxa3zwdXIC&amp;amp;amp;pg=PA1&amp;lpg=PA1&amp;amp;dq=Principles+of+Programming+Languages+:+Design,+Evaluation,+and+Implementation+MacLennan&amp;prev=http://books.google.com/books%3Fq%3DPrinciples%2Bof%2BProgramming%2BLanguages%2B:%2BDesign,%2BEvaluation,%2Band%2BImplementation%2BMacLennan&amp;amp;sig=3XyiOumL-op0a_b91h8AlVlvOng&amp;pli=1&amp;amp;auth=DQAAAHAAAADVmq9LzDGztE1qU5mVPc4dRgrDCXKwDkrM6lq4FDeL9NfthkOrOxmwtUGtPsN5ni5KBl5kMAkhdzZ-9GW7AvAbrFyOBwXwIHKfdoiRRNG8S_lDiGIlhf0GMDXpCbE9GEtMI8MbKxL54u6k0rio15Be"&gt;books.google.com&lt;/a&gt; has the book scanned, and has a bunch of links to sellers.&lt;br /&gt;&lt;a href="http://www.amazon.com/gp/product/0195113063/ref=sib_rdr_dp/102-8007951-9100902?%5Fencoding=UTF8&amp;me=ATVPDKIKX0DER&amp;amp;no=283155&amp;st=books&amp;amp;n=283155"&gt;Amazon.com&lt;/a&gt; also has the book scanned, and offers the book for purchase.&lt;br /&gt;&lt;a href="http://www.alibris.com/search/search.cfm?qwork=5341138&amp;wtit=Principles%20of%20Programming%20Languages&amp;amp;ptit=Principles%20of%20Programming%20Languages%3A%20Design%2C%20Evaluation%2C%20and%20Implementation&amp;pauth=MacLennan%2C%20Bruce%20J%2E&amp;amp;pisbn=0195113063&amp;pqty=35&amp;amp;pqtynew=3&amp;pbest=2%2E95&amp;amp;pbestnew=99%2E90&amp;matches=35&amp;amp;qsort=p&amp;amp;cm_re=works*listing*buyused"&gt;Alibris.com&lt;/a&gt; offers the book used, and seems to have the best price, but for older editions of the book.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21499889-113821002799401544?l=programminglanguages.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programminglanguages.blogspot.com/feeds/113821002799401544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21499889&amp;postID=113821002799401544' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113821002799401544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21499889/posts/default/113821002799401544'/><link rel='alternate' type='text/html' href='http://programminglanguages.blogspot.com/2006/01/book-for-this-course.html' title='The Book For This Course'/><author><name>joshwaxman</name><uri>http://www.blogger.com/profile/06958375916391742462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
