SOFTWARE ENGINEERING III
OCTOBER 5,  2015

	And, we have new data definition.  Okay, go down here.
	Starting file lines, a 54, 57, new data definition, list of number is either this thing I'll call the empty list.  So first of all, if would write ked, if we write code, it's going to process a list of numbers.  What does that code look like?  What will the code look like that processes a list of numbers, not knowing what the function does.  Don't all type at once, now, no, I'm kidding, you can all type at Wednesday, that's fine.
	The answer I'm fishing for, we spent several weeks on this, I hope it's clear, list of data numbers is -- a union type, it's something or something.
	Okay, code that handles union type is what type, what type of code, what will it look like, it's a con with 2 branches, 5, 6, 7, con is 2 branches, and in particular, remember how we did the library item, we had, a library item, either a book or DVD, in one of cases we had, say, we had a book, con of 2 branches, book or DVD, when we had a book we asked what was in the template then.  For, function to handle a lib item.  If it's a book we can pull of the book object, and DVD pull up those fields.
	We'll come back and see that in a second for the numbers.
	First, let's go ahead and, yes, he has header and, have a con o with 2 branches in there.  Okay.  Let's make examples of the data.  Can somebody give me an example of a list, according to the data definition?  What is an example of a list?  -- my hint is the first person who answers has ease -- easier job than anybody else.  -- double quotes, is that a list?  It says, interesting, no, that's a string not a list.  The empty list, I type in empty list, that doesn't work, a, list of strings.  I type that in, A is not dough fined.  Something I type into Racket that is a list of number.
	Cons one -- okay.  No, that doesn't work, what's something, hint, I gave you a definition, Ironclad definition, there's not doubt what is a list, look lines 56, 57, there we are, Chris got it.  There we are, that is a list.  How do we know, line 56, right there.  And I know that when Aaron said empty you probably think, thinking that exact same thing.  So -- okay.  Yeah, so, the tick mark, open per ran, close paren, there's literal way of writing empty list, give me another example of a list.  Hint, use the definition.  We can't lose, another hint we can't use line 56 any more.  So, 1, 2, 3, doesn't like that.  In fact, so, we say one, 2, 3, yeah, it doesn't look like line 56 and line 57, it's not part of the definition of I list. 
Yeah, so what mark has there, is -- make cons of something and something.  Okay.  The first thing to make cons ha to be what type?  Line 57, has to be number.  And that's the second...., what does that have to be, does that have to be?  
	Looking up line 57, second thing has to be list of number, I would not say list of numbers, technical thing I wrote is list of number, I need to replace this...., with a list of number, in particular, 1, 2, 3, is that a list of number, no it doesn't match.  What's the only list of number we have written down already previously?  The example we just did.  That empty list example, tick mark open paren, close, now closer on the track, this, make cons of 3 tick open closed.  That follows this definition here, 3 is definitely a number, 3 is definitely a number and, the empty list is definitely a list of number as previously established.  
	So make con of 3, in addition to make, go ahead and have data definition like this, make cons was an instruct, what else do I need to do to have that is that correct get worked into the Racket language.  Thinking back -- oh, yeah, define struct.  So define struct, so here I'm going to define struct, cons has 2 fields, we know they're types, that's given in line 57.  I'll call that number, I'll call it the first -- and I'll call that list number, I'll call that rest, so instruct with 2 fields inside called rest.
	Examples of data here, make cons of 3 and here -- can somebody make me another example of a list?  A bunch of people are throwing things out, yeah, okay.
	If there's lag between video and audio, I'm waving back and forth, I'll wave up and down, wave up, wave down, wave up, wave down, if they can calibrate that lag.  So, yeah, make cons of, go ahead and make cons, make cons of 4, that's a number, and then I need to go ahead and put.... needs to be a list, should say make cons of 4 and empty list again, that will give me a list, a lot like the example we already have.  Is there some other list I can use besides these 2 lists, yeah I'm going to copy and paste the things in line 64 and place it in the place I need to place a list, list of number.
	So line 65, that's also a number, so make cons 3, make cons of 4 and make cons of 3 empty, that's a list.
	Can I make another example of the list?  Now start to see the pattern here, right?  Make cons of 5.  With some list.  Hey, the list that I previously made online 65, I'm going to copy, and paste that -- okay.
	These are examples of data that follow from that data definition.  And, this data definition is, this is like Ironclad contract.  That's a list, open paren make cons, some particular number and some particular list of number.
	Okay.
	And what's interesting about this, data definition, -- the data definition for list of number includes, the list of numbers, self referential data definition, or if on whiteboard, our chalkboard -- in adobe connect, draw a little line from, pointing to you on the screen, from that list of numbers, circle that in line 57 and draw arrow back to line 55 and say hey look at that, middle of definition reference back to main definition.  So -- okay.
	And is that self reference?  Is that bad?  Means circular logic or nonsensical, no, we go a ahead, make sense of data and build smaller ones up.  Make cons of 3 and something, at that point the only list I already previously made was empty so I had to, had to put that empty list there.
	So -- okay.  By the way how are other people on the lag, is there a lag, lag between the audio and what I type on the screen, I see.
	Which is still a lag.  Is anyone besides Steven getting that lag?  How do you know?  I'm going to change line 64 and change it back.
	Add a new line, change it back, add a line, change it back.
	Okay.  I'll speak a little after I do.  That would be hard for me to type things in advance and 10 talk about them later, I don't know I'm capable of doing that --
	So -- at the break I'll try to disconnect and reconnect again, that might help.  Where were we, it sounds, this sounds all good, I now have a confession to make.  Define struct con is already built into the language, so we don't need to say define struct cons.  Okay, and actually I have the this down here, talking about lines 72, 73, 74, -- owe -- okay.  And constructor is not called make cons, it should be, but the name of the construction is cons.  Make cons of 3, I'm going to say cons of 3 -- cons of 4 and -- cons of 3, the empty list.  So, usually Racket is pretty dang consistent, this is one place maybe not fully consistent.  I think it is, full Racket the constructor is the same name as the type.  
So, in full Racket, if you say define DVD blah-blah-blah, the constructor is called DVD not make -- hyphen DVD, I like the make hyphen --
	So as mentioned online, 76, constructor is actually -- just cons.
	Line 77, selectors, you think selectors would be con stash first and con stash rest, I would make it consistent with all the others instruct created.  Here it's not.  They don't call is con's stash first, they call it first, so I'm going to go ahead, and, copy and paste that, switch to the interaction window here -- clear this screen, get to the top.
	Okay.
	We give this a name.  Define, I'll call it L 2, the list that contains 2 numbers.
	What is L 2, cons 4, cons 2, empty.
	Give me something to type, in try it yourself in Racket.  I want, I have L 2 I want to pull out that 4 sitting inside there.  I remember cons is, cons of 2 fields, first thing is 4, other thing is this whole cons 3 empty.  Okay.  Steve will be out for a second.  Cons number of L 2, not cons number, but what's the name of the field, the type of the field is number, but the name of the field was first.
	Yeah.  And then like I just finished saying, you think the cons first would be the name of the selector, but it's just plain first.  For better or worse -- because this is built in.  How do I pull out everything but the 4, that's rest L 2.
	Again, yeah, L 2 is instruct with 2 fields, first pulls out one of fields and rest pulls out other field.
	We mentioned before, in general the constructor and selector are inverses, one takes individual parts an makes into object.  Selector take an object and pull out tease individual parts.
	First in rest are like mathematical inverse, they makeup math Matt hell inverse between the 2 of them.
	-- mathematical inverse.
	Steve is getting some lag on the screen there.
	Okay.
	Try logging out and back in again and see if that helps.
	We'll try that.  Your task, go ahead and pull out the 3 that's in, that's hidden inside L 2, once you type in, take L 2, and want to pull out that 3, that's nested inside there.  And then even how do you pull out that empty that's sitting deep inside, L 2, how do you, pull that out?  Answers, to be resumed when I log back in.
	Go here, quit, adobe connect and come back in -- audio is back -- I can also turn offer the screen sharing maybe, since it doesn't play a part that might contribute to lag.  If lag resumes I'll turn off screen sharing.
	Back to sharing this.  How could do I pull out the 3 inside there.  Rest of L 2 pulled out of that -- and that's instruct with 2 fields.
	How do I pull out the, the field name first?  Take, first of -- that rest of L 2.
	-- okay.  And if I cons 3 empty an and want to pull out second of these 2 fields I use rest.  So say rest of, rest of L 2, -- exactly the first of rest L 2 gives me cons 3 empty, called rest on that, pulls out empty part.  So, in fact whenever you call rest, what is the type of the result?  What is the type of the result calling rest?  List of number, exactly.
	How do you know that.  Looking back on data definition, line 57, I guess I can update now, say cons -- so -- yeah, cons and whatever I call first on list of number I get back in number.  So, there's never any trouble distinguishing can hold something am I good getting back number or list of numbers, always keep those clearly different.  Okay, good.  It could get worse as I talk more and more, could be slowly building you remember, glad the lag is working better.
	Okay.
	Yeah, So do -- there's also a predicate, just like there was, when you did define struct book, we did function called book and took in anything and say hey is this a book object.  Line 79 on my numbering, I realize my numbering changes a bit as I type in extra lines -- my file line 79.  There's a function called cons, so cons of L 2, is true.
	Okay.
	Cons of 45, -- not cons of constructor or cons the predicate -- cons of 45, 45 is not a cons.  Cons for constructed list, okay, so -- okay.
	I want you to write a function that takes in a list of numb and returns, sorry the signal is breaking up, write me a function that takes in and handles a list of number -- this is the template, right?  How much of the code can you write without knowing what the function does just that it takes in a list of numbers, list of number.  What can we do?  And, we already, again, this is the file line, 87, 88, we know from the data definition, I have an union type for cons, I have con with 2 branches and I can ask these questions, am I empty list?  Corrective list?  And cons is built in, function empty is also built in.  Function that takes anything that says yes or no, was a given just the empty list, only one thing that make it's return true.  So -- and, da-da-da -- checking on the discussion board a bit.
	Okay, I don't see a green button, maybe that's only appears when there is lag, so -- okay.
	Cool, thanks Chris.
	Okay, so, -- yeah, looking there, I already typed it for you, but the template for a list of numbers as a con with 2 branches, if we have an empty list, is there anything more I can do to get my answer?  That point I need to know what my function is wanting to return.  I can't do any more light now without knowing more information.
	If I have a cons object.  Corrective list, can I still do some work without knowing what the function is doing?  Yeah, I can pull out my fields, cons is an union, -- product type, compound type, instruct with 2 fields, pull out those 2 fields, like lib item, lib item was DVD or book and we had con with 2 branches -- (Inaudible) branch for book we pulled out feed for book object.  Other branch for DVD, we pulled out DVD, exact same thing here that's -- there's one thing that's different.  When I pulled out first of in my template, oh,  if I have a cons then I can pull out 2 fields first and rest of (Inaudible) what is the type of first of a-lon, it's a number.
	This is a number.  What is the type of rest of a-lon.
	This is a list of number.  Okay.  So rest of a-lon is list -- if I have a number, what are everybody, shout out a function that, can take a number.  So when I write first of a-lon this, I might be passing this to functions to -- everybody shout out a function that can take a number as an input.
	And again, this is just, this is a function I might be calling in the future when writing a real function.  Plus, what's another one -- number to string, awesome.
	That's a function, maybe calling plus on this thing or number to string, somebody give me one more.
	So number question mark can take in anything, you're right, I might be calling this, but I don't need to call it because I know there's a number, so I don't have to ask, I don't need too ask if this first of a-lon is going to be a number, I already know it is.
	 Other ideas, and there's times and divide and minus and all of those, substring, yeah, a string and second number, yeah, maybe.
	Greater than, greater than is the one I was hoping someone would say, definitely takes in, wants to be given a couple numbers.
	So, in the back of my head, writing template, yeah, maybe I'll call some function that wants to take in numbers here.  Which one I might call depends on the problem.  Rest of a-lon, it's type was list, what is a function that wants to be given a list of NUM.  Hint, showing on the screen now.
	What is a function that wants to be given a list of NUMS as input.  Yeah, FUNC for list, how do we know, it's in signature.  So -- here is now, this is step 6, step 3 C of the template, design recipe.  Yes, finally finishing out the design recipe.  If you're doing something, pull in a field and happens to be the same type as the function that you're, writing, the template you're writing once, go in and add the natural recursive call.  
	Why the 9 out of 10 times, a function dealing with a list is going to pull out the sub part of the list and make recursive call right there, not all of the time, but most of the time, that's the right thing you want to do.  Just by virtue of that self reference of data definition, I have a self reference here, func-for-list on the whiteboard, and draw arrow up to the func-for-list. 
Yeah, where is that self reference in data definition, there's exact mirror image of that self reference in my code.  That's not coincidence, that's how we want to write things.
	So -- let's go ahead and -- look at this -- by the way rest of a-lon was list of NUM and what type of func-for-list return, we don't know yet, we have not written anything, okay, go ahead and write, the function sum -- sum takes in list of numbers and adds up all the numbers, return sum of all of the numbers inside the whatever I call my I list.
	Okay.  What is the first list of writing a function?  Check exception.  Here we are, lines 94, 95, 96, 97, -- did I not take that out -- sorry.
	Make sure I got rid of other answers here.
	Okay.  Okay, sorry this meant to beginning file that did not have the answers yet.  Okay -- I might go ahead and have a header, purpose statement, might have, sorry I have the signature, purpose statement, header line 108 and go ahead and run that now, just so I'm, make sure not missing any open parens, press run and I get window saying -- 33 of 42 tests failed.  Bunch of tests failed.
	Okay, what tests passed.
	The first test that failed, line 94.
	Okay.  -- sorry I sort of got carried away, I haven't finished talking about the check expense.
	I check expect, hey I need to try and call sum and call it on different list, let me, what are different list I can try it on.  Don't waste your time coming up with new list, you have something you already wrote, go up to example of data, grab those.
	Some of the empty list, what should the answer be, E?  I put in 0, is that correct?  -- well, I'm thinking of -- the sum of no numbers all of 0, maybe I guess, I'm going to add, take the sum of all the list of coins in my pocket.
	Okay?  And let's see if I can do life demo here --oh, my gosh empty pockets, sum is 0, that's clearly the answer.  Okay, I'm happy with that.
	-- what about the list of cons 3, empty, I'm going to think of this as empty list, I think of cons, giver me a list and tack a new number on the front of it, sort of like a -- bunch of post it notes.
	I saw with empty pad of post it notes and hey maybe I'll cons 3 on to that and get a 3 on there.  And maybe cons 4 on to that stack of post it notes and cons 5 on that stack, all of these give me a list of NUMS, cons 3 empty, I took the empty list, tacked 3 on front of it, add up the numbers, there's 3, and sum of that should be 3, take that list, 3, tacked on to empty list, tack 4 onto the front of that, cons 4 of cons 3 empty.
	Okay, that's a list.  That's 2 numbers in it, 2 things in it, add them up, we get 7.
	Okay.
	So sum of cons 4, cons 3, empty is 7.
	And, finally other example, cons 5, cons 4, cons 3 empty.
	So that's going to be add up.  Those are 3 things on that list, we add them up, we get 12.
	Why do we get (inaudible)?  We have 5 plus the sum of the numbers on the other list, which we already decided is 7, so 5 and 7.
	Let's go, -- write the real body of sum.
	Rather than just the 999.  How do we do that?  Check expect, have everything there.  Let me go up and grab that template.  And I'm going to move down here, template, everything except that, only thing I need to change from template is natural recursive call that was func-for-list, I now give particular name, sum.
	So this is what the template gives us.
	Let's start writing coat.  3 dots dots dots to fill in.  Let's look at first branch, con of empty a-lon, we already answered this question in test case, if you have empty list, what is the sum of numbers in it, we decided 0 was reasonable answer in that case.
	Okay.
	Here is more interesting, cons of, then again, pay attention to exact steps we're doing.  You might be able to jump straight to the answer here, but more complicated examples, what is our thinking that we follow on here.
	And I'm going to do this partly by using, call this inventory with values.  Owe ki?  I'm going to say, suppose a-lon is particular concrete example, not just a list with bunch of things in it, suppose it was cons 5, cons 4, cons 3 empty, easy to think about concrete things than abstract general cases.  So let's make thinking easier.
	Suppose it was, -- look at template, it had first of a-lon, it was cons, 3, 4, empty.
	First of a-lon is 5.  Take out some of these answers here.
	What is, here with had rest of a-lon, what is it's cons 5, cons 3, cons 4 empty.
	Again, I guess in that answer file, didn't mean for you to be there that you downloaded.  First of that was 5, and rest was the other field which is a big one.  But big value stuff in a that fold, cons -- I'm going to write that down, be concrete, what is rest of a lone, cons 4, cons 3 empty.
	But that's not entirely everything in template.  Here is the thing that people over look, my template included sum of cons 4, cons 3 empty.  What is, sum of cons 4, cons 3 empty, what answer is that going to get back, gray box I have highlighted.  What answer will give back?  Sum of cons for cons 3 empty, wait a minute.  Up here, it's going to be 7.
	-- I can figure that out.  So -- yeah, what do I have sitting here in my template?  I have, this piece which is 5, if a-lon were this list, this piece which is 7, if a-lon was that big list, and what do I need for final answer, I have test, test case for that too, sum of cons 5, cons 4, cons 3 empty, I need to get 12, here is where my thinking starts.
	The template gave me 5 sitting here in template and I have 7 in template, I need to get 12.  What is the general rule now that's going to bring me from those 2 parts, 5 and 7 to my final answer, 12.  -- just add them.
	How do I add 2 things, I replace with plus, another...., not there at all, hit tab, indent line to be indented.  Okay, so, yeah, plus of, first of a lone and some rest of a-lon.  And again, the way we treat this, let your thinking begin, tough to do this, let your thinking begin with, I've given first of a-lon and given the result of the recursive call, how do I start building my answer.  That's what the template gives us, that's why I suggest using for the template, okay.
	Let's go ahead and do one more example.
	Already there, go ahead and delete it, function my length.  Takes in list of numbers an tells me how many things are in it.
	So, my length of empty list, there's nothing there it's 0 things, how about cons 4 empty.  How many items in that list?  Oh,  just the number 4.  By the way some people want to say there's 2 things, there's 4 and tem empty list there.  No, that's not how it is.  -- how many stacks in post-it notes, took empty post it note and slapped 4, how many are there, single one and says 4.  There's one post-it note in that stack.
	Cons, if I take cons 4 empty take that stack post with stack with single page and cons 2 on front of that.
	I get a new stack of post-it-notes containing how many things?  2 things and how about this one, cons 99 on to that previous example.
	Well, now has 3 things in it.
	Again, cons I think of, making us instruct with 2 fields, but also think of it as, give me a list and one (Inaudible) item and I'll make I list of slightly longer, slightly shorter list with one extra item tacked on to the front.
	Okay.  Let's start writing code for my length and then take a break.
	So I went ahead, went and wrote the, contract for you, the signature, my length takes list of number, returns a natural number.  Okay.
	Returns a length of, since I have parameter and name that had here a-lon, I refer to that by name in purpose statement.  I have signature, purpose, header, I stubbed out, let me go ahead and make sure my, I don't have any friends missing, I want to press one, and 25 test cases failed.  First failing test case, line 25.  I expect.  You knew it would fail, so let's go ahead and write my-length.  And one more time, I'm going to give you the, sort of guess it almost, but I'm going to give you, walk you through the thinking procedure and give you a chance to write a function on your own.  So -- okay.  What are we going to do?  Grab the template.  Template for any function that handles list of numbers is probably going to be helpful.  Copy that, move down to, my stub function, get rid of stuff there, and I think we're good, only thing I need to change is again, change, take my length, take out what was func-for-list in template and replace with list my length. 
Handy editing tip -- in any program, double click means select a word you're on.  I select my length and C for copy and then paste.
	So -- okay.
	There we are.  So again, pay attention to the steps, the questions I'm asking myself as I write this.
	My length.  If I have the empty list, what should the answer be?  We have a test case, my length, empty list should be 0.  I'll fill in 0 for that first....
	Here is more complicated.  What if I was given, what if A lone were cons 99, cons 2, cons 4 empty, excuse me I have to cough.
	I'm thinking a-lon, I'm making a concrete case in my head to figure things out.  Suppose A lone were cons -- etc... what piece template leave me sitting here on platter, it's a serving tray and 2 things sitting on it.  First of a-lon what is first of a-lon in this case?  -- it's type is number, what particular number, again I'm trying to get exact -- a-lon.  Cons 99, cons 2, cons 4, what is first of a-lon, 99.  Yeah, 99 one of 2 things sitting on serving tray is 99.
	Rest of a-lon.  If a-lon were cons 99 --cons 2, cons 4, empty.
	-- okay.
	That's rest of a-lon, it gave us my length of rest of a-lone, what is my.
	Above us, yeah, that was 2 -- okay.
	So, -- here's what I've given on the silver serving tray, there's template gave me 99 and 2 -- those are the 2 things sitting on serving tray, what answer am I trying to get in that's check expect, I'm trying to get the answer flee.  How do I go from 99, 2 and build the answer 3, the.
	99 first number on list, 2 everything.
	The 99 doesn't enter into it.  Sometimes we have things in template we don't use.  That's okay.  Hey take the length of rest of list 2, and add one on to that.  That's how we get from 99, 2, and 3.  I through away 99, add one, --	Okay, thoughts, observations, going back to last week, union types, compound data types an putting together with self reference, that's the new part.
	But -- and go and -- actually start my webcam this time.  I'm still sharing my Racket.
	-- and the thing, new stuff added to the, design recipe I'll scroll up to the top of this file now.
	We added basically 3 C -- is the new part -- add the natural recursive call as appropriate.
	And you do that by thinking what is the type of this, what is type of that, I pull up my feeds, what are their types.
	If one of types is the type you're writing the function for, think about writing that natural recursive call, step 6 is what I want you to be working on.  Applying, be conscious of doing this.  It helps debugging overall.  Not just look at code and try to figure out in general why not working, give me a particular input.  See what's happening for this particular input.  And, what the, value of each sum expression is.  Okay.
	So -- and again my claim is when writing this function, let me go backup to the sum function, first and, rest and sum of the rest.
	And I sort of said start your thinking there.  If you have list of containing 5, 4, 3, rest contains 4, 3, and sum of that will return 7.  Wait a minute, I can't call sum yet, I haven't finished writing function.
	Let me throw this out to see if it helps settle it.  You're write writing code all of the time you call some other library function, you write some function, call it substrate no problem.
	Writing a function you call one of your own functions as helper function.  Sometimes you're writing code and decide you're going to call as a helper function, call a function that you haven't written yet but about to.  And you're like, I haven't written that helper function yet but as soon as I do, I know this part will be correct.  That's natural thing to do.  And that's what we're doing here.  
	You're saying, yeah I want to call helper function sum and I know I haven't written sum yet, once that recursive function works this function will work, and that seems magical, I think the other way to submit this is the same way that you do, in discrete math, do proofs by induction.  Same way we build up examples of a data.  What does something do on the empty list?  It works there.  What does this function do if I sum of cons 3 empty, work it through. 
	You see clearly it works because recursive call on rest is going to be a smaller list of already handled.
	How about cons of 4, cons 3 empty, again, your recursive call is going to be working on smaller list that you already worked through that all and you know it works.
	Just like you know, hey cons of 4, cons of 3 empty meets the definition of a list, why did we know that, cons ever number 4 and something else that was a list and I already worked through the cons 3, empty was a list.  So the same knowledge that you know these multiple nest of calls to cons, meeting that definition to a list.  That same thinking is same thing why recursion works.  Maybe that helps you, maybe not, maybe you still have a little suspicion in the pit of your stomach, yeah, it kind of works but I don't understand why or how to write it and my advice is -- go with the template, -- and say, starting with the result of the recursive call how do you take that, put it together to get my financial rural.  		Which is how proof by induction works.
	Hey, am I back there -- I dropped out for a second.
	I'll start sharing screen again -- sorry video should be back now, sorry about that.
	Okay.
	Yeah, so, it's the same reason why induction proofs by induction works, why this natural recursion works.  There are other types of recursion where you don't file design recipe and have some clever idea, that's different type of recursion, you probably never, when people teach recursion they mix this altogether, examples of natural recursion and examples of clever recursion altogether and never point out some are natural and some require clever or these fill routines an search routines, are -- recursive algorithms but don't follow straight from the definition.
	This is way of doing it from the data definition, really say what is a list -- we should be there.
	So -- contains 93, give you a list of numbers an you tell me whether or not it contains the number 93, okay.
	We can do test cases for that.  Right.  I'm scrolling down to line 163 in the file after having types new lines, contains 93 empty list, clearly 93 is nowhere on the empty list.  How about the list containing, cons ever 93 empty, yeah, that definitely does do it.  These are the test cases I naturally want you to write, list of like 0, couple lists of like one, where the answer is true, one where it's false.
	List of length where the answer is true, list of length 2 where the answer is false and then maybe a longer list.
	So -- okay.  Go ahead and start on your own, fill anything contains, 93, and see if you can write that.  At least go ahead and put in template, ask yourself about, the different parts of it, -- and how to combine them -- and think about it for one particular example.
	Give you 2 minutes to do that.
	We did that data definition way back then, we don't need to redefine what I list of numbers is, we already know what that is.
	  My length.
	>>>  Okay, hopefully you found the template for -- any, code processing you list NUM, contains 93 wants to do that.  Change the name of that recursive call, change function for list the particular function we're looking for -- what is the answer for empty?  -- did you all get this?  -- how many people got as much as I typed there, how many people had that on their screen?  -- yeah, so, false or -- hopefully you got that, that's mine intent, at least copy and paste the template, be able to come up with template on your own but we had it here.  And this, start looking at...., if you have empty list the answer is false.  Hash F, hash false are both literal false.  -- and it turns out false without the hash is a variable, like I constant, hams to bound to literal value faults.
	No, no, don't be sorry, it's all cool.
	I'm sort of explaining what is the difference between hash false and false.
	One is variable bound to false, the other one is not variable at all, just the false value sitting in middle of program.  That's difference between green part in Dr. Racket, it's will literal value.  If blue, it's identifier.
	Okay.
	So yeah, false.  Okay, now, how do we write the rest of this?  -- on oh, my gosh, let me give, now it's going to be tougher because more cases going on maybe, let's choose one, and I happen to contract one that's, particularly helpful, but choose anything.  -- choose some interesting value for a-lon.  and scroll down a bit to see test cases as well.
	-- okay, suppose a lone were this big thing here, the list containing 55, 44, 93 and 7.
	What is if a lone is that, what is first of a lone?  -- 55, exactly.
	Okay.
	What is rest of a-lon in that situation?  -- yeah, we're, really, in order for this to be code, cons 44, cons 93, cons 7 empty, but the list containing, 44, 93 and 7 -- okay.
	So yeah, what is contained 93 of rest of a-lon?  -- this is the one that I really want everybody to get, what is contained 93 of rest of a-lon?  -- yeah, not false.
	Boolean equal, that's a function, it's not a function.
	>>>  True?  I think it's true.  What type, some people, what is the type contains 93 rest of a-lon, that's why I had you write down that signature, I didn't have you do it, that's why you write down signature before anything else, many what is the type.  If it contains 93 I get back a Boolean.  Okay, if I call it contains 93 on the list that contains 44, 3, 7, sorry, 44, 93, 7, this one here -- what is the answer?  -- it's going to be true.  Yeah, so -- Sean I think maybe you had the right thing, but hey the list contain continuing 44, 93, 7, contains 93 of that thing is going to be true, look at check expect.
	Here is -- my thinking -- first of all, first of a-lon, what type is that?  That's a number.  What is some sort of function is related to the task at hand, what's function that accepts number and helps with task at hand?  -- first of -- but that's what I asked.  I nurse that, next recurring ever will don't try to unwrap the recursion in your head, what will contains 93 give back if you pass this thing here, what is square root of 16?  You would not say the first time square root probably has loop inside and first type through the loop it wouldn't give the answer for, it might give the answer 10.713, I don't care about what it does the first time through the loop or anything like that.  What is the answer.
	What is the answer that contains 93, yeah.  It's weird mind set, but all I'm asking for is what is the answer that contains 93 of this other list.  And that's why, hopefully maybe I try to build up these test cases to sort of smaller test cases are going to help me walk through the later check expects.
	Yeah.  Cool.
	Okay.  Yeah, so -- now thinking back on this, so this thing here is true.  This thing was 55.  And now I'm going to be like, what's the rule for taking 55 and true and what's my answer by the way?  -- if a-lon is all this, what answer do I need to create?  -- exactly better be returning true and we're given 55 and given true.
	Okay, how can we put those 2 things together?  -- I know the answer is true because this second part is true.
	Yeah.
	By the way for the first part -- yes, so maybe a con if, there's -- I'm going to go now, -- yeah we can do that, go ahead and say, cond and what is different sort of cond, this is not doing data analysis, I have question answer pairs, I don't know how many question answer pairs I'm going to have.
	One of question that's matters -- and this may be sort of hey, let's go look at contains 93 of the rest, if that thing is true -- what is my answer going to be?  -- well if that thing is true, my answer is going to be true.
	Right?  -- does that make sense?  -- a cond where, if that -- if that called to contain 93 is true, recursive call is true, then my answer is true.
	What else do I need to do?  -- any other way I can also be true?  -- if first contained 93, does 17 contain 93?  -- if you're on the right track, you want to look at the first -- but not at the, I don't talk about what number containing another number, a number is not a list, it's equal to 93, how do I ask, if I have first of a-lon, for template and say, is this equal to 93, yeah, what's the function that does that?  -- equal, I call equal function, I pass at 93 and first of a-lon.  If this thing is all, if this thing is true, what is my answer?  -- yeah, true again.
	Okay.
	Am I done there?  -- so I've used the pieces of template, put them together using con -- sound good, some people are maybe wondering, shouldn't I say, if contains 93 is equal to true then return true?  -- was anybody wondering that?  Some people may have been wanting to write Boolean equal with this, with true, if this holds then that's my answer.
	I, are people wondering, should I talk about that?  -- I claim that, is -- asking, go down here, asking, Boolean equal of BLAH, whatever that is, and true, where blah is some Boolean, if blah evaluates to true, this thing is true.  If blah is false this Boolean equal is false.
	That's long way of writes blah, if blah is true this is true, if blah is false this is false.
	Same thing here, I can just write this much for my question -- and yeah, contained 93 returns true then take this cond branch, otherwise don't, and the answer for this cond branch happens to be the Boolean true.  Okay.
	We all good.  Run our test cases?  -- like this?  -- oh, no, check expect encountered and error, cond, all questions were false.  And gives line number and gosh, what's going on here, check expect contains 93 of cond 7 empty.
	I passed the first test case, passed the second test case, interesting I didn't pass the third.
	Let me think about my code -- rest of a-lon was the empty list, right?  -- if a-lon was cond 7 empty, rest of a-lon was the empty list contains 93 of empty list was false.  So cond wouldn't take this branch, what about this?  Is 93 equal to first of a-lon.  No, don't take the second branch.  Now that I think about, my function can only return true as written.  And that's a problem.  I can return false up here.  But if not empty list, then, I'm saying, hey the answers just, has to be true.  Oh,  wait a minute I need another else clause here.  I need to say, what's another condition -- hey what if, this wasn't true and this wasn't true, hit here, I guess I could say else -- false.  Is that clear?  -- I need an -- else.  Otherwise there's, once I get to this cond I was always returning true, i was always returning true -- so -- and in fact I fell off the end.
	Think I think makes more sense to me.
	And okay, we have some failures, but those are way down on contains, which is written later.  So -- okay.  I'll pass our test for contain 93 all pass.
	We took the pieces of template, contains 93 rest of a lone and first of a-lon and put those pieces together uses cond and equals.
	To come up with our answer.
	How do people feel about that?  -- I'm going to do, leave this in the notes here, go ahead and copy paste this -- there we are.
	I'm going to give a slightly different answer going back to this here.
	You know, I like this, we had from the template we had different parts here, get rid of everything else.
	I like this, we had this from the template, we had first of an O a-lon asking whether or not first of a-lon was equal to 93, I think that was important thing, so I had, these 2 bits here.
	Let me swap their order, actually.
	So this was a Boolean, this was a Boolean and again looking at my, go back now to the inventory with values and looking at this one, in this case we had, see equal, if a-lon is this list here, 55, 44, 93, 7.
	It's first of a-lon equal to 93?    -- this expression evaluates to false.
	All agreed?  If a-lon is the particular list here, then I'm going to get concrete exact, in that case, this expression is false, this expression is true and overall answer was true.
	And now, back at the question, how do I combine these results to get the answer, overall answer I want and sure enough, now 2 Booleans, and looking at these 2 Booleans saying whether or not what the answer should be and we did that with cond.  I'm going to scroll down here, this truth table, the first input was, equal 93 and first of a-lon.  The second input -- result of the recursive call contains 93.
	And if that, if first number is not 93 but rest contained 93, my answer should p be true.  What if I got true and false?  The first number is 93 but rest did not contain 93.  My answer should be true.
	What if they're both true?  -- what if the first number of the list is 93 and the rest of the list contains 93.  Can that even happen?  -- have I lost everybody, can that happen, is that a sensible situation, first of list is 93 and 93 occurs later in the list, sure I look at temperatures in July, it was 93 and it was 93 previously in the month, happens all of the time.
	In fact the only way we return false is if the first input, if the first was not equal to 93 and the second was, recursive call did not contain it.  Does this truth table look familiar?  -- yeah, this is the truth table for OR, it's true, or second input it true.
	-- like that, I'll look at these 2 things an say how do I combine these 2 things -- what's the rule, or them -- I claim this is the same thing as that cond.  -- yeah, we certainly can write a general contains function, I just kept is simple for the moment.
	In fact I'll leave that as exercise, write your own contains anything at all.  Any value that you care to pass in.  That's the more interesting, more natural function.  Contains 93 is blatantly odd.  Okay, the point is, yeah I can use or on this, and still pass test cases?  -- all by 17 passed.  And I look at it, it's this down further that it happens.
	So yeah, actually doing this OR got me the answer as well.
	And so yeah I go from template and say hey -- I have, this part was in template, this part was in template.  What did I need to add.  Comparison with 93 was crucial, equal and 93 and how did I combine these parts, realizing I could write with OR, but cond was long way of doing or.
	If I have 2 Boolean,s if first is true, return true, if second return true, OR false, that's second -- long way to -- how many characters in this version here, how many characters, how many things do we have to type, that weren't in the template?  -- had to type hash F, OR, and equal -- and 93.
	Everything else was sitting for me in the template provided for me.
	How many things were not in the template?  -- the call to add one -- and the 0.
	So there's like 5, only had to type 5 characters not sitting in the template.  And had to throwaway some things in the template, look at sum how much was in this answer, oh, the 0 and the plus, 2 characters.
	Yeah the template we can get a lot of mileage out of this template and the reason is, hey, if you want to process a list, a lot of your code is not really about stuff germane to the exact problem, it's about just handling the fact that you have the structure here, you need to reverse the structure, the cond, 2 questions, pulling outfields, making recursive call, that's in.  That's one reason I'm stressing this design recipe, it's paying off, we're getting a lot of interesting things happening.
	So.
	Yeah, after writing contained 93 we realize contained should be fine, I'll let you go ahead and write your own contained function.
	Your own contains function.
	I have a bunch of test case there's.  That's function that's operate on lists.  Every cond dm a function, no, if you have union type that has case 17s, you have with 17 branches , remember stop light color, one of 5 things and we had 5 branches.  Here why 2 branches?  From the data definition.  Of the list, a list of number was either empty or conds and nothing else.  That's why we have 2 branches for function lists which what you may be asking, I realize.  Every cond in a function that handles lists will have 2 branches.
	We saw when we had that nest the cond that contains 93, that was cond that had 3 branches.
	That's because this cond was not doing the data analysis at all.  Was not say s union type and trying to figure out what type of branch of union cond I'm in.  This branch was there for a different reason.
	-- every function that process an union type with 2 variance will be a cond with 2 branches.  It's good, like I know I get agitated and wave hands around, this is fundamental concept, yeah, the shape of our code, follows from the data definition.
	-- and later when you write programs involving trees we'll have a different data definition but don't, don't do nothing different than today, exact same methodology doing here applies to functioning with trees, we need to get the data definition.
	By the way -- we'll come back to that.
	Let's go ahead and do one more, see if we do this before the break.  -- one more function called, called triple ever even.
	This is a function that returns a list.  That's only new thing here.  -- I want the function triple every even, call it TEE.
	Give me a list of numbers an give me back the same list except every even number in the list got tripled.
	Let's look at -- line 246, if I give list contains 92, 3, 4, the answer will be list contains 93, 2 triple and 4 triple.
	93 does not get tripled because it's odd number.
	Okay.
	And actually gave you all test cases for this as well.
	T of the empty list, what should the answer be, list just like empty list, except every even number there has been triple.  Is the really empty list or does not make sense in the problem?  The situation?  --
	>>>  Triple every even make sense?  Doesn't make sense to check, again, hey there's the payroll computer and everybody making even amount of money is going to get salary tripled.  I'll send a list of everybody in IT department and math development, and now list in basketball weaving department that currently doesn't have people.  I think triple every even, you should be able to give it any list that you want.
	-- and empty list is definitely a list.
	Is this the correct answer?  Again I have no idea, everyone is stone silence or like, whatever this is really obvious -- if I take the empty list and go through and, good, good, I'm going to go through a list and take every even number I find and triple it.  If I start with even list, how many even numbers do I find in the empty list?  I didn't find any.  
	So I'm going to return a list that's just like my input, just like the empty list but without anything changed at all.  I didn't change anything, that's the empty list.  So -- I think I really claim that yeah, take every even number there and do something with it.  I'm already done before you start.  There weren't any even numbers I had to do anything with.  So I'm going to return the empty list.
	Triple every even conds for empty, that's list that contains just the number 4.
	Conds give me a small list like the empty list, slap 4 on the front of it, that's the list just containing the 4.
	Okay.  Go through, here is list containing 4, go through for every even number triple it, 4 is even, I'll giver you back the list containing 12.
	Which is what this is -- conds 12 empty.
	Okay.  Triple every even number in the list containing 7, there aren't any, so it's going to be every number that was in there totally untouched, the list containing 7.
	Okay.  And these I think, these whole things almost make more sense and more things in it, perhaps, I don't know.
	Okay.  Go auto head and write this function.
	Follow, if in doubt go to top of file and look at steps of design recipe, I've given you an example here, you can stub it out.  Remember this is important to remember, you take in list of number and returns a list of number.
	Stub function that, at least always returning correct type, but that's not always the answer so -- I'll have to check some other things first.
	Yeah, I'm sure enough is currently getting, I didn't do, comment out that whole contains block, how do I do block comment in Racket again, hash pipe.
	Starts a big block comment and I'll -- take out that whole section and pipe hash.
	Like to type pipe hash, there we are.  By the way these log comments net in other languages.
	Okay, I'm going to hit run here, and -- oh, yeah, the first test case failed this one, because I have not written function yet, returning empty all of the time.  At least all the other I can run it, see if I'm hitting my check expects.
	-- what's the first thing you're doing is writing this function.
	Triple every even.
	Copy and paste template.  This is list that handles even numbers, I bet template will help me, I'm going to scroll up.
	Find the template -- paste it, remember to make that name change there.
	Da-da-da -- here we are.
	Copy, change that function to list back to T for this function here -- okay.  Yeah, so what is the empty list and hey, our whole policy of doing check expects and check expect should include all the samples of data, and samples data should include both cases and first case was empty list, so yeah, not by coincidence but steps of design recipe we know that --thought about maybe have to think about for a while -- okay.
	-- now, -- I'm getting bandwidth notice, so turn talking head -- off here -- I didn't -- what step of designer species should I look at.  Steps one, 2, 3 were for data types, we did that for list of number and had not repeated those, step 4, header purpose contract type.
	Inventory with values.
	So/did -- if you're stuck about what to do, you were not reading the design recipe.  I put these down in the list, 1, 2, 3, 4, 5, 6, 7, 8, so you don't get stuck.  You might say what am I suppose to do, you should have said I'm trying to do inventory with values.
	Consider a particular test case and think about specific value of each sub expression, okay.
	And, particular test case that works down here, what's a nice more involved test case that gets this down into the conds branch?  -- cons branch?  The cons 4 empty, say -- look at the particular test case, cons 4 empty.
	So -- yeah in that case, what is first of a-lon in this example, if a-lon is cons first empty, what is first of a-lon?  4?  What is rest of a-lon?  -- a lone is cons 4 empty, what is rest of a-lon, somebody besides Chris -- if A is cons for empty what is the rest of a-lon, exactly, empty list.
	What is -- I'm thinking of a-lon as being cons 4 empty -- of, okay, first of a-lon, I have 4 and I have, see this is empty list, what is -- TEE rest of a-lon in this case, somebody bids ASHENAFI -- so, the question I'm asking, this gray highlighted part of code, what is that?  -- T of rest of a lone.  You, right, 12 will play into this, here is what ix getting at.
	I have 4 and -- (Inaudible) what do I need to get as an answer, cons 12, empty list.
	So what am I going to do?  Somehow need to take -- first of a-lon, and triple (Inaudible) okay.  And then, so that gives me 12 and empty list, how do I put 12 and empty list to get the answer of cons 12 empty list?  -- hopefully you can see the answer as cons.
	This part is 12, this part is empty list, and I want to get cons 12 empty list.
	So -- yeah, put cons around those 2 things.
	Okay, that works for this now, but you're probably like, wait a minute.  4 was even number, what if I had, cons of 7 empty.
	And I'm going to jump up when I do these inventory value.
	I jump up to a bigger example.  I'm going to look at this here, suppose a-lon were cons 93, -- I guess different things I can try here -- suppose a-lon were this, cons 93, cons 4, empty, contains 93, 2, had 4, I think in my head this way -- I write it like that -- and see later on that's a shortcut we can use, but not allowed yet.
	-- in particular, we want to be able to write this function really well and realizing there's a bunch of cons you need to do to create that list that contains 83, 2, 4.
	If a-lon is this, what is first of a-lon?  93.  What is TEE of rest of a-lon?  It's, TEE of this, which is the list containing 6 and 12, what answer do I want?  93, 6, 12, how do I combine 93 with the list 6, 12, to get the list.
	Cons except without the times 3 -- okay.
	And now sort of like in the general case, yes, either it depends whether or not this number is even.  Okay.  Either my answer is going to be cons with a times 3, triple that number and add on to all of the others with even numbers triple.  Or -- don't.
	Just use the number itself.
	Okay?  -- in fact I'm going to go ahead and be subjective, I'm going to say, either multiply, suppose I always want to multiply, but either multiply by 3 or multiply by, what should I multiply if I don't multiply by 3?  -- yeah, either by 3 our by one.
	Gosh I want this to be 3 or 1, depending.
	That sounds like what sort of statement?  -- that sounds like an IF statement.
	If something is true, use 3, otherwise use one.
	In my multiply.
	And now, people have been wanting to do this and type this for a while.  So Steven typed earlier, what is the condition, decision, should I multiply be 3 or multiply by one?  -- yeah, IF, turns out there's a function -- even.  You can give it any number and it will tell you yes or nor that's an even number, what number do we care about if it's even?  
	Good job on restraint there, very good on self-control.
	You may not have known even was in the language and we can come back to what we do in that case, who do we care if what is even.  Do we care about being even.
	First, when we say first or rest, I wasn't sure about what that was, yeah, so, if, I'm going to copy and paste this -- so here, this is already kind of sneaky way of writing this, I'm being sneaky, here is what I expect people to write, if the first number is even, use times 3 of first of a-lon.  Otherwise use, just first of a-lon -- yeah, how do you use OR for this?  I don't think OR plays into this, it's only the evenness of the first number, nothing else comes into it.
	If you have an F with no else -- yeah, except -- except what do you want to use.
	Functional paradigm where you always need to say what your answer is, and you're thinking about variables, variables change overtime.  I like this, because I don't need to think what is first of a-lon, well sometimes it's 4 and sometimes it's 12, I don't like that, that's more confusing to me, I have the whole concept of time and my question of what is first of a-lon, what is first of a-lon at this point in the program.
	-- I'll sort of claim that after a while, this is easier because I'm never changing anything and no concept of time.
	2 separate IF's, only have one IF here, IF with 2 branches, if some condition, here is what I want you to use if the condition is true, 3 times the first number.  Otherwise I want to use just the first number.
	Remember what about that?  Still having cons, we decided it was cons of something on to all the other numbers with their even ones tripled.  And only question is what do we cons on, either the first number or first number tripled.  And that's what we put in-- want in here.  The way the indenting works, be careful, I'm passing 2 things to cons here, -- and another way of saying this, is -- hey, I have the you want me to partnership the every number on the list, great, my template gives me the rest of the list with all its numbers tripled as needed and I already started with that.  All I need to do is take that list and tackle one number on the front, what number do I cons on the front of it?  This thing here -- either 3 times the first number or just the number. 
So -- okay, let me go ahead and da-da-da -- copy, paste, leave this here, I'm going to comment this one out -- and now go back to other one, now I'm going to look at the specific expression and get back to that thing we had a moment ago.  First write it in long roundabout way, that seems to make no sense.  But now, I'm like, wait a minute I have an IF statement and then I have something in the true part and in the false part and it's being duplicated.  And I don't like duplicating.  The fact I   multiply that's duplicated in both branches, if something happens in the condition of true-or-false.
	If I have if statement, anybody that happens in both branches didn't depend on the condition.  Here is where I'm going to factor out.  I'll say, my answer for that first part was, it was always times of something with first of a-lon.
	And this part here is either 3 or 1.
	And that is, well go ahead and put back in here.  There we are.
	So now, Chris this might make you a little happier that you don't have to repeat this quite so much.
	The first of a-lon get repeated less, this is kind of weird, this is what's cool about Racket, all these Lego pieces that interact.  The result of IF because it's not an one armed IF, because there's always an answer I can use this answer as one of the 2 arguments to multiply.
	Whereas if I had one armed IF, IF something is true do something and no else at all.  Then I could not do this thing that I did here.
	Yeah, the indenting, I'm trying to indent clearly on this.
	The answer is cons with, hopefully that cons pretty clear has 2 arguments, here and here.
	This multiply has 2 things, multiplying 2 things, this number and this number.
	The first number is self and IF, could break that IF on to 3 lines but I think it's clear evident here.
	Maybe not -- maybe that's clearer for you.
	Multiply, 2 numbers.  This number and that number.
	-- so, I'm throwing several things at once, the main thing is -- hey approaching these problems this is a function that use the template for a list of numbers an returned a whole other list as an answer, that was the only twist not up in the previous ones.
	I'm throwing in other stuff.  The factoring out, IF statement, that's kind of cool, if you don't like that and want this version down here, no problem, use that version down there, I'm happy with that.
	I'm going, this is version I end up preferring here -- yeah, this is -- does this past test cases, let's give it a try.
	And, extra paren got in there -- now look -- I think I fixed things up to it and now failures, that's down in the my max, in later line of code.
	Another thing that neat about Racket that I happen to love, is that semicolon comments are one single line, hash semicolon comments out the next expression.  If you have hash semicolon in front of paren it comments out all the way to closing parens, these 2 closing paren are matching define and cond.  And this is all commented out, these are not commented out.
	So, especially in cond branches, this is awesome way to take, come out, comment out a whole cond branch.  Okay, that was a long session, take a break and, -- come back and finish up talking about lists in a moment -- 
	[Break Time] I'm pausing the recording.
	>>>  After class is finished I'll talk it file we build up and post everything I type and it will be on the lectures page.
	Those 5 minutes went by fast.  Didn't they.
	Did that comment out -- that whole thing?  -- in a special goo yi looking box.  Actually replaced it, that's not -- that's not -- can't undo that sounds definitely weird.
	-- let me look here, I'm going to -- the thing I commented out anyway.
	And then -- certainly insert comment box, you're right, think it would do that.  Click outside the comment box.  You could not undo things inside the comment box.  If you click outside the comment box and then hit undo.
	Comment box has own sub editor, so has own history inside there, I guess.
	Okay, let me turn the recording back on to finish up.
	Okay.  So go back here, so/, we've looked at handing list of numbers, function that's return a number like sum, function a return of Boolean like contains 93, function returns a whole another list based on the list you passed in.  Kind of contrived example, but, -- it's not unusual to say I'm going to have a function that takes in a list and returns another list.  Okay.
	Da-da-da now I want to write a function called my-max, the reason I call my-max and my length, anywhere built in, why write if already built in.  If it weren't built in how would we do it.
	Okay, max takes in list of numbers an returns the biggest one, that's what we want it to do.  Okay. How do we go about doing this?  -- check expect.  Here is a list that just contains the number 7, which is my-max return?  7.  What are some interesting test cases?  Here I have a list that contains 4, 7, what should max be?  7, how about a list that contains, let's make this 7 and 4.
	Again, cons 7, cons 4 empty, what is this max?  7.  And throw in a couple more, go and take that 7, 4, empty and say cons 2 in the front of that list.  What is the maximum now?  Well, still 7.  And, what's the other thing to try?  Cons something that is the new max on there, cons 9 on that list, that raise the max up to 9.
	Okay.
	By the way, sometimes doing had these test cases, people say, can I go ahead and name a list and refer to the name, refer to same list multiple times instead of doing that.  Sure.
	I can see something like this instead of lines 291 and 293-6789 you might say define L 74 to be that.
	And then you can look at -- my max of L 74, look at my-max of, cons 2 with L 74 and max of cons 9 on to this L 74.
	One nice thing about the fact we have immutable data.  L 74 will always be that same list, calls my-max doesn't change it.  I don't have to worry about the order of these 2 calls, none of them are changing the list anyway.  L 74 is always the list, cons 7, cons 4 empty.
	Okay.
	Da-da-da -- okay, let's go ahead and first of all, now I have more interesting things going on here.  What is, the check expect for the empty list, what should the answer be?  -- and here I said maybe negative infinity.  Okay.  Does that work?  How do you feel about that?  -- saying maximum number and the, empty list is negative infinity.
	Sounds like you're all strongly have no opinion.
	Okay.  Sure or undefined.  Yeah I don't like it.
	It turns out I don't like it either -- and here is why.  Yeah, we need to return a number and any number.  I mean could I return 0?  Well, no.  Because in fact I should have a test case.  What if all input are negative?  What's the biggest number out of negative 2 and negative 4?  And somehow if the maximum of the empty list is 0.  Somehow that things don't jibe.
	Yeah, maximum of that negative 2, negative 4 is negative 2.
	If I have any number at all, it needs to be huge negative number, can I say negative 99999, I could, but you could construct a list that containing negative numbers more than the numbers I put down.  So -- that doesn't, you can't really use negative 99999, because I can construct a test case that will be worse.
	Probably by the way code will work, if you add on -- more numbers you can only increase the maximum.  You can never decrease the ma'am numb by throwing more numbers in the list, the worse you can do is keep maximum the same.  If it was negative 99999, I could never get a maximum smaller than that.  So -- negative infinity would kind of work but I don't like for 2 reasons.
	One is -- it make it's sound like negative infinity was in my list, what's the maximum number out of the list that contains negative infinity, negative infinity, negative infinity, the empty list never contain negative, the maximum number should always be one of numbers in the list.
	And so, yeah, so in the computer systems, infinity is a number, right.  Negative infinity, Java has is as well, in Java you can say double dot we have negative infinity and positive infinity, Java so it takes more typing to write, there's a named constant, double dot negative infinity, and I trip E, this counts as double.  This really is, in exact number, it's a double.  It really is in the system but I feel like the maximum number in the on the list should be one of numbers on the list.
	The other reason I done like it, is because, -- getting philosophical, in general, the trick, when calling my-max take the most negative thing.
	If I want the maximum string, the biggest string alphabetically, I can write a function that takes a bunch of strings an says what is the biggest string, biggest means coming last in the dictionary, and there empty string might be reasonable, like using 0, something that's, the smallest possible string just like negative infinity might be the smallest possible number.
	So that might work, now here is a different question, I'm going to give you a bunch of strings an I want to you find the minimum string, you can do that, but maybe base case would somehow involve the left evident possible string and there is no largest possible string, no infinity string value baked in the system like this for numbers.
	Here I might be able to use negative infinity to sort of get me through this problem and other situations, other values might work, but it won't help you all of the time.
	And, I'm going to just leave this, and keep this here and say -- leave the negative infinity, but I'm also going to say that -- really the function my-max is not defined on empty list.
	And which means not defined on list of number I can't call my-max on this list of number.
	I need new data type.  Maybe non empty list of number.  That would always be well defined.  Putting that aside.  Let's look at -- how we're going to write this function -- we have the template here -- did I get the purpose and description?  I want all of that.  I don't have that yet.
	But here we are down here, my-max.
	That was copy paste thing I that I put.
	-- let's copy paste the stub, my-max, copy paste the template.  Okay.
	Change this name function for list, change to my-max, copy paste, double click, paste.
	Okay.
	Okay, so if we have empty list we go ahead and use this fake value of negative infinity.  Okay?  And now, here is what the template gives us, it gives first number on the list and gives us the biggest number in all of the rest of the list.  Okay?  -- how do we put those together to get our answer?  -- so again, think about, this one here, cons of 9 and L 74.  We have 9 and we have the max of L 74, which is 7.
	So we have 2 numbers.
	By the time we start thinking about this, that are no numbers left.  There's the number 9, 7, how do I get the right answer?  I'm going to compare them with greater than.  That's an F statement.  If greater than -- if the first number is bigger than the max of the rest, what should the answer be?  Well, -- first.
	Otherwise, what is the answer?  My-max of rest of a-lon.
	Okay.  So I think that should be good.  I think we're happy with that.
	You're right, Steven, you think the function was named greater than question mark because it returns Boolean, for better or worse they use the same name Java uses, takes in 2 numbers an returns a Boolean.
	No, don't be sorry, I think it's interesting that, you're right, that's the more consistent name.
	I like throwing these comments out.  Don't be sorry, I'm actually happy that -- okay.
	Let's go see if we pass or test case.
	Pass or test cases.
	Okay.  And do I need to comment something out here?  Go ahead and hit the stop button.
	Rots hold on.  All 38 tests pass and user break.
	It ran a long time.  Why?  Let's go and comment this one out.  Is what I want to do.
	Comment this one out -- okay.
	I'm going to run and always my tests pass.  Great, including all those tests we had for check expect up here.
	Okay, sounds pretty good.  I like all of this.  It turns out for really annoying reasons it doesn't pass when I check the negative case.
	And the reason is -- negative infinity, this is double negative infinity is a double, which is approximation to the real answer, that's what the class double means, Racket terms it's in exact number not exact number.
	And you can't use check expect on in exacts.
	Because you'll never be, are 2 numbers close to one another, that's the best you can do with doubles.
	I need to use check within.  Negative infinity is not within 20 of negative infinity, negative infinity is not within infinity of negative infinity.  Hard to use check within for that.
	I'm going to gloss over that, don't worry about it.  I'm going to leave that comment out.
	So all tests pass.
	So we're happy, right?  Yeah, happy, go through and say, hey what about this here, the takes negative 18, 17, 16, 15, all the way to negative -- 1.
	If I scroll over, negative one empty -- look at those closed parens piled up.
	So I have big long list, negative 18 through -- what's biggest number in it, negative one.
	And run this, and it's going to run -- and all 37 tests passed.  No problem.  Now I'm going to do the same thing, now it's slightly different.  This is starting negative 23, negative 22, negative 21 down to, up to negative one, and maximum of that should be negative one, nothing different there.  And I run this, and we wait.
	And we wait -- and we wait some more.
	And I have a pretty fast machine, it has lots of memory and we're waiting, and we're wait, oops all 38 tests passed.
	What's going on here?  -- something is going on that -- is a qualitative, quantitative issue, it's works, it works but taking longer an longer.
	Especially on 18 still goes quickly, but negative 32 took a long, long time.
	So, recursive log, yeah, so -- recursive log, yeah.  Suppose that, -- calling my-max on a, suppose I have a list an calling my max on that list going quickly, tenth of a second -- so let me write this down, suppose -- for some lists blah, my-max of blah takes 0.1 seconds to complete.  Okay?  How long does it complete and returns, what do I want to say?  -- returns one hundred.
	How long does it take for my-max, I'm going to call it cons of 50 blah, let's look at code?  My-max of cons 50 blah.  So go through here, blah in some list, yeah exponential is what it's going to be.
	If the first number is bigger than the maximum.  So it's 50RBGS maximum of blah, rest of a-lon, that was exactly blah.  This takes tenth of a second to run.  Right?  And if, greater than 50 and returns one hundred, greater than 50, 50 is not greater than one hundred, if it were it would return that first number.  Otherwise I do this, wait a minute, comparison didn't take long, this took a tenth of a second.  Then this took a tenth of a second.
	Whole thing took at least point 2 seconds, because I made that same recursive call twice.  Only happened because the first number was not bigger than the other maximum.
	Okay.  How long does it, -- it take, my-max of cons 50 cons 45, cons 50 blah -- take.
	Well, what is rest of that, the rest is cons 50 blah, I compare 45 with my-max of cons 50 blah.  That returns one hundred.  Okay.  So, and took point two seconds to go ahead and -- do this one here, took point two seconds.
	By dumb luck we're not big enough, so we call this one, that takes another point two seconds.  That takes 0.4 seconds.
	Each time, we add a small item to the front, running time doubles.
	How long do we have to double point.  One second is not really that, it's barely noticeable.  Point two seconds somewhat.  How long does it take to become noticeable?  Well what if I double something 20 times?  2 to the twentieth?  What about 10 times, 2 to the tenth roughly?  I know it's late.  This one we all know.
	It's roughly, yeah, exactly 1024, roughly a thousand.  If I add tenor small items from the front of the list, it will take a thousand times longer, even if tenth of second, that's a hundred seconds.  Gone from tenth of second to nearly 2 minutes by adding 10 small items.
	And we see it happens here.  I don't know how, it doesn't take long to run-on the empty list, it takes on the order of nanoseconds for the empty lists maybe microseconds.
	2 to the 18th time, 2 to the 23 time that's time, 2 to the 10 is about thousand, 2 to 20 is about a thousand, thousand, or a million.
	8 million, some of us 8 million times longer than call ting on the empty list, and that becomes noticeable, takes about 30 seconds.
	So -- have the right answer, do the right thing, problem is its taking too long.  Why is it taking too long, I make recursive call here and then do a whole bunch of work and then I redo that -- same work a moment later.
	That's it.
	So -- I'll finish with something that some of you may want and are asking about in week 2.  I want to go ahead and make a local variable.  Okay?  To store a temporary result.
	Go ahead, I'm take this, copy and paste the whole function, comment out this first function here, and here is what item going to do.  I'm going to say -- go ahead and compute my-max of rest of a-lon, and I want to save it in a variable.  Little local variable.  Here is how I will do that.  let -- let star, max 0 the rest.
	Now I'm going to have, here is how it looks, I'm going to have let max O the rest and here is what I'm going to set it to be, local constant, never going to change.  And now, take this whole IF statement and that's what I I'm going to throw in for the...., inside the LET statement.  LET has 2 parts.
	New variables you want to add and then the body.  The body is just like we had, instead of making recursive call now I can talk about max 0 the rest.
	Instead of here, I can say, max 0 the rest and I'll   hopefully probably mangle and butcher my -- parentheses.  Let's see here.
	There's my IF statement.  There was the answer, IF statement.  Here is the end of LET statement.  This whole LET statement.  That was the answer for the second cond branch.  That's closes off con and define.  Getting tab, use tab to reindent the way I think it should be, okay.
	So let this be this and then -- here is the answer, the entire let statement.  Run this -- an boom all the tests pass instantaneously, we didn't notice any delay, okay, I guess there's a bit of delay getting this to go.  Here is up shot.  Adding local variables, we didn't use them up until now, never used a local variable besides parameters to a function.
	And we sort of got by without them.  Here is a case, there might have been times you wanted to have local variable but it wasn't, didn't give them to you and repeated stuff or wanted to name sub part of big answer you were building up so we had a big answer.
	Great, that's all good.  Here is a place, where you using names really matters in a real way.  It avoiding exponential blow up.
	So -- syntax for let's star.
	Open paren, let star -- bindings body -- maybe go ahead and do something like this.
	In fact, I can finish up and give this, and -- give this grammar actually, let star expression is this.  Now, what we mean by body, body is actually any expression.  So in fact I can say expression here I guess.
	Okay?  Bindings that has more detail into it.
	Bindings -- is, actually I'm going to say, put, curly braces around here.
	Bindings is going to be 0 or more of these pairs.
	How do I say that?  -- from our grammar from least week, either empty string or single binding.
	Followed by other bindings.
	By the way does this look familiar?  -- we've seen other grammar rules like this last week as well.  This looks like data definition of list, a list is empty or a single thing tacked on to the front of a list of number.
	A list of number is either empty or a single number tacked on to a list of number.  This is exactly the same idea we used when, making our data definition for list of numbers.
	Here is in context of giving grammar for this, what is a single binding, I need to give you that.
	It is a square bracket, followed by an identifier, followed by any expression and a closed single bracket.
	So things I'm put anything angle brackets, those are non terminals.
	Okay.
	Let's go up and see if, does this follow, can I derive this string up here from this grammar?  -- let's see, that expression has to start with open paren, that expression has to be this.  That is open paren, LET ass sister risk, and spaces I'm not worrying about, open curly bracket, great, a bunch of bindings and closed curly bracket.  I need to later verify that whole orange part can be generated from bindings, the bite non terminal called bindings.
	And here is this part here.  Yeah, this needs to be an expression, it turns out it is, we won't talk about the grammar for an expression, but, yeah, big, almost everything in Racket is an expression, including calling IF, anything that returns an answer is expression.
	And after expression we need closed paren and sure enough that's the one that closes off that entire LET statement.  So -- as long as bindings can generate that -- we're in business, can bindings generate that, let's see, it's going to be a single binding followed by bindings, and that recursive call to bindings is epsilon, really we have a single binding here, do we have I single binding?  Let's check, open care square bracket?  Yes,  followed by identifier, yes, followed by expression?  Yes,  that's expression.
	And does it have a closed square bracket, yup it does.
	So -- yeah, 2 things in 2 different ways an playing both ends of candle here, I showed how let star works, to make it look like identifier, and then also given you grammar for it.
	Oops -- since we talk about grammars, maybe it doesn't make sense now, but sit down yourself and see it if it makes sense, in particular what are these curly brackets mean, I'm going to have a whole bunch of potential bindings here, we only had one, but I could have more, some ID -- and, some (Inaudible) and so on -- let star, you have variables that you like followed by let star expression.
	If you look at the, let star and look for that in the Dr. Racket help?  You'll find they'll have own different notation but give the syntax for it and go ahead and give semantics.
	Let me finish with that and we'll be done.
	Okay -- yeah, 845, -- 545 to 8:45 p. is the actual time.
	-- bind, that identifier to that -- to the result -- then, evaluate the body expression -- using new identifiers.
	And its result is the result of the entire let star expression.
	We'll come back and talk more about that.  Maybe it makes sense.  So -- okay.  -- sounds good, I'll let you all go.  Yeah I see -- I'll let you go, and this file again will be on the lecture page and put the videos posted as well.  They'll be a new homework coming out hopefully by tomorrow afternoon.
	With stuff in it.  On the grammars, read that second in the book on the grammars, they'll by problems, including problems from there.
	Okay.  Good night.
	I'll see you all next week.