PROFESSOR:  Okay, somehow usually start -- adobe APP, that didn't start up entirely -- just lost the sound.
	Maybe I want to start sharing my screen?  Da-da-da -- hold on.  I'm logging out and log back in.  Yeah, I did -- I'll fix that, I'll double check, I'll log out and log back in.
	PROFESSOR:  Okay, that should be better.  Now the adobe connect add in running.
	I forgot which CHROME browser I need to use.
	I think FireFox.
	Yeah, so let's, start sharing the screen here, is I can quit FireFox now that the add in is running.
	There we are.
	Then I want to bring -- this on top, I'll check that setting right now, while I remember it.  How is the quiz looking?  People looked at it?  And again that's meant to be the mechanical stuff to help you get on the way it doing the homework 3 B, which is a couple of functions -- so let me look here -- da-da-da -- assessment, there we are, don't have that, da-da-da, attempts 2, somehow trying to maintain 2 sections is also -- I've done this for the other section, I thought I made the same thing.  So 2 attempts and average of the 2 attempts.
	So you have incentive to do well the first time around, if not you have a way of working on that.
	Okay.  And just, so, yeah, first, looking at the quiz real quick, that's -- best way I guess can I preview it.  Here, are you able to see the quiz preview coming up.
	On my Screen cast.
	So yeah, Aaron is asking about number 3 -- function which takes in a GLURP -- we look at union types we had before I think we had some code for like a stop light color and it was an union type of 5 options, what was the code, COND with 5 branches, that should be knee-jerk reaction, if you have union time with 17 variances, you'll have 17 branches.  I can tell you that much that's what you're going to need to do to handle that type.  17 things you need to handle, well, go in figure out, which of the 17 item us have and handle it, so.
	And, yeah.  So that was a few questions there.  And then looking at the, Chase asking, again, say few things on the discussion board, too, so check out discussion board, if you want to go to the discussion board, subscribe to changes, so when something is posted you get e-mail.  If that's fine with your workflow.
	That can be good.  Going to, da-da-da, so, we have a data definition, directory response is this or this or that.
	And just to keep in mind this is data definition, define new type of data, we now have a new type.  After putting this I know it's only incumbents, we have Boolean, strings, numbers, images, and directory responses, because we now have the data definition, once you put in comments in program, that's a new type.
	And that's good, because question asks write a function, given a direct try response and returns a string, returns one of those 3 things correspond to go the case 3s.
	So, question, a lot of people ask, is, what should I do if I get a string that is longer than 14 characters?  What should I do if I get 20 characters long, what do you think my answer is going to be?  What should I do if I get true instead of false.
	No.  Let's go back and read the problem.  What do I give this function, what type does it take in?  Write a function that takes in what type?  Directory response, you're given a directory response.
	Is the Boolean true, is that a directory response.
	Boolean, it's not a string it's not.
	No, true is not a directory response.  So does 0 function have to worry about given true, no.  Worry about given scanner, no.  About given regular expression object?  No.  Those are not part of this function don't try to process such inputs.
	Do O you do need handle any directory value response.
	Is a string that is 20 characters long is that directory response?  Know.  So your function is not going to be given that, your function will be given directory response.  And I'll confused.  If I say your function takes in string, you would not think what happens if you give me Boolean or scanner object.  You just write a function that handle string.
	Here taking directory response.  Here is what I think not clicking, we're internally the fact had we give stated definition, we're making a new type, and that type is directory response.  And that is a technical type and we know exactly what is a directory response ant what isn't.  Now granted we're in a language like a lot of dynamically type languages, like python, Java script or racket.  You don't key, declare the types in the program and no type checker that prevents from passing faulty type, if they do, that's their problem.  If racket if someone calls square root and passes instead of number, square root doesn't check that.  That's error and problem is on whoever call the square root incorrectly, they didn't read that description correctly.
	So, I don't know if that's what I mean by over thinking it.  But -- that's what I lot of people have, define a new type, write a function that takes in that type and pep are confused about what that function takes in.  So.
	We're going to worry about, now you might want to say, hey, if I, SEAN your question, what if somebody passes in something of the wrong type.  Because of language doesn't prevent it.  We can go ahead and write code to circumvent that, it's a lot of code, boring, in interesting and doesn't do anything.  If you get something from the outside world might worry, of course best thing from outside world from user that's usually a string you're getting.
	Validating a string of certain form is one thing.
	And if you, -- there's a note, discussion board as well, if you really say gosh I want this to be enforced by the program.  This comment, hey my function takes directory response, I'll have that in my signature for the function.
	I wish enforced by the run time system.  It can if you want.  There's something called contracts and Lincoln lectures page and read about that around do it.  Instead of saying define, define contract.  You put signature right there in the code.  The one thing it would mean for directory response you need to write a function called directory response that can take in anything that says yes or no, is this directory response.  That can, it would take in anything and says is this directory response like we have Boolean question mark, that says takes in anything and, if you make your own data type, -- and this is kind of -- and then this contract system is basically, a checks as a precondition when somebody calls a functional run time, it calls, it might wall your function directory response on that input.  Another example, that happens when you have, these run time checks, I can write a function that takes in only prime numbers bigger than 10,000.
	As long as I can write a function that takes in anything that says is this a prime number bigger than 10,000.
	I can write in racket, and somebody tries to pass in 10,004.  It will say nope that doesn't meet, that doesn't meet this other function which was provide that had tells me prime number bigger than 10,000.  Friday to pass in 7, likewise would fail.
	Turn these into real run time checks, I don't want to digress on that, something good to know about how type systems can work and dynamic type systems, but for now, this class, we're going to put these in comments unless you want to go further, and you only have to handle the type I ask you.  You have to handle anything of that type.  That's all you have to handle.
	Yeah.
	So, okay.
	Yeah, don't need to query some data set.  It returns, one of these 3 things depending on the case 3s in the data definition respectively.  If not sure, that's great question to put on discussion board.
	Okay, and hopefully you looked at that, started that, fin E finished that, and we're moving on from the union data types, which is this directory response, I'll say, data definition with -- or in it.
	And counter part.  We didn't have or in the definition, we had, AND, yeah, hey, I think we had a book, a book, what is a book?  Actually, a, string for the author and a string for the title and a natural number for the number of pages and Boolean whether or not copyrighted.  And so, we won't call that an union type, that's not in OR, it's couple different words but you can call is a compound type.  Because a book, is compound made of 4 other smaller trunks of information.  So call it compound type or call it, sometimes call it product type.
	Why do I use the word union and product type?  Because, we this definition of slides from last time.  I said a type is a blank of values.
	-- a type is a blank of values, can you fill in the blank?  -- collection?  Yeah, yeah.
	Usual word, instead of collection, a type is I type of values, that's kind of redundant.  -- yeah, yeah, no, cool -- but yeah, so usually collection is the right meaning, a type is a set of values.
	Yeah the set of short in Java is setup numbers from negative 32,000 to positive 32,000.  And set of all possible strings that's infinite set.
	Set of Boolean is 2 values.  Here we have, really I'm taking the union of a bunch of sets.
	I'm looking at the set of strings of lower case letters, with the length in that region, that's a set.  False that's a set with only a single element in it, and private, so talk about the union of these things.
	That's why we call them an union type.
	You can think of these as the union of several other smaller types.
	And so -- we have unions and if you remember from your discreet math, car tease an prods of 2 sets.
	The Cartesian of things and numbers is a pair.  One string and one number.  So, so Fred and 17 and cheese and 0.  That's another element of the set, strings cross numbers.
	Okay.  That's what we're doing here, if you think about it, pull up the doctor racket.
	-- we went ahead and said a book is a title and a, yeah, title which is a string, another string, a natural number and Boolean, give necessity any 2 things in Boolean, that's going to be one book.
	That's why, all of that is a, motivation as why I might call it a product type.
	I'll try toe say the word compound type, people are less scared of that, means the same thing, compound type made of 4 things.
	As I recall last time, we were in racket and we, had the data definition for a book, and it will give the data definition, these 2 ways.
	I'll, giver, say define instruct, that keyword that adds new type to the language.
	Racket has, -- string strings and images, and numbers, now book, define instruct book, and gives the name of the fields.
	-- oh, yes, Steven, intervention, interesting to think of intersection of 2 sets speed, what that would mean for types.
	Turns out that's not useful to us, but worth thinking about.  When would that make sense and when wouldn't it make sense.  All these are ways of making new types out of existing types.
	Data definition for union, is making new types -- when we go ahead, we saw this is not racket, we're not recording, thank you, sorry -- we also saw that, this, Java is the same way, how did we tell Java we had a new type that included -- 2 strings a number and INT.
	How did it tell Java that was a new type?  -- okay.
	Compound.
	Types, new book is how we constructed instance of the type, if you gist go to Java and type in new book, it will say unknown type book, there is no type book, you can say new string or scanner or new capital I integer.  So class book, that's the keyword that introduces a new class in Java, and once we do this, and saw this last time.  Once we have this in the for field, there's a new type in Java, INTS, Booleans and books.
	And I can write I function that returns a book as result --
	Yeah, so -- and I forget, how much, I know we showed this Java last time.  Let me go back to the racket for a second.
	So -- excuse me.
	-- this little Java, by the way this is enough to compile, when you write Java classes, write this much, class and fields an have it compiled right then and make sure you don't miss typos yet.
	Okay.
	Back E back in racket, line 6, 7, are the exact same thing as that Java class.  In fact, almost word-for-word, we don't say class book, we say define instruct book and your right.  We say the names of the field, the types online 6, so still have the types.
	Along with that.
	Almost word-for-word the same in Java, racket, making a new structure.
	Now, I'm going to think of structure, I think of instruct as object without methods.
	We make functions in racket.  In Java they have methods class to functions but not quite, they have this thing thrown on top of it, that I'm not going to pursue right now, racket does have an object system, if you won't to do (Inaudible) in racket, look it up, but we're going to stick with so-called static functions if you're a Java programmer.
	Okay.
	So, I go ahead in racket and give in define struct, it's comment, if you leave off comment will get upset.  Make couple examples of the data.  And so this is the constructor here, and the constructor in racket we see, -- the name of constructor is racket is make book, we'll call this function like we call any function, open paren, the name function and the stuff we pass to it.  It may, -- (Inaudible) behind the screens for us, Racket made the correct store, as soon as I said define instruct book.
	Does Java make the -- is there a constructor here?  Yeah, turns out there is a constructor for class book right now, let me go ahead, and need to --I can call Java constructor and say new book, I can't say new book and The Cat in the Hat -- by Seuss, 37 pages and copyrighted.  I can't say that.
	And in fact we get error message, says there is no such constructor.
	But there is a constructor that was made, yeah, I can call the constructor here, new book and I get a book object, passed at nothing, I have book object, look at it, and what is inside field, initialized fields to something 0, null for the strings and, is that eye useful book object?  No, that is the least useful book object I've ever seen.  Java gives me a constructor, but constructor that's totally of no interest to me.
	I want a contractor for books like the Racket, I give the 4 piece information and makes object for me.  So how do I write the contractor?  Yeah, okay, here is the, code here, -- lines 7-12 is the contractor that I wrote myself, and it is a boring constructor.  -- I wrote it, in fact, interesting code to write?  Fun?  Know.  Not at all.  I just need to go through and check boxes, take each field make a parameter that corresponds and fill in the fields.
	I could have typed a little less here, I'll tell you in a second why I chose this format.  But overall, this is so boring, for you using -- there's a (Inaudible).  There's a mini item, create constructor from field.  And you check that item and computer writes this code for you, that's how boring it is, I want to create fun code, not code that's so boring a computer can write it.  Yeah, so it's clunky compared with Racket.  I phrase it Racket gives me the right defunc constructor for whatever Java didn't give, every class the write, I write this constructor here.
	Yeah.  Actually, I lied I'm not going to talk about syntax here, this is how I write constructor, notation, and this for clarity reasons, okay.
	You can, shorten it up a bit.  And then, once I have contractor, I, this is the constructor here in Java, in Racket the constructor was called make hyphen book, and in Java it's called.
	It's going to be weird, I'm going to say, it's note make hive fen book, it's called new (inaudible) book.
	-- now write technically new operator, not, I think this, really this is a function new book and call the function new book and get object back, that's sounds like a function to me.
	So -- okay, new book and make book in Racket, exactly parallel thing.
	So -- and so I have examples both in of the same 2 books.  So pretty much identical Racket in Java except I spilled out contractor.
	Yeah, so in, in the -- Java I went ahead and made a couple variables and assigned, B 0 get this here, how do I do in Racket?  I don't need to do that by the way, I could just say, new book, and then, create the book object and not save the result.  Still compiles and does everything.
	How in Racket do I give a name to something?  Seen that keyword before already -- I want to give the name B 0 and B 1 in Racket, how do I do that?  Somebody remembers this from the first homework?  Second homework, have we done it?  Yeah, tea fine.  I go ahead and say, define B 0 to B that -- define -- B one to B, second one.
	If I want to say B 0, B 1 instead of make book blah-blah-blah, that's fine.
	Okay.
	So, again I'm thinking of the design recipe in my head.  We have data definition, we make examples of data.  One thing -- when I said define instruct book, the constructor was made for me, the other thing that got made for me was 4 different getters or selectors.
	And, they have, free defined names, book -- hive fen title.
	Book, title, title B 0 comes back -- so book title, again looks like, or it is just another function.
	Takes in a book, extracted title field from it.  How do I find out how many page are in B one?  -- yeah, call a function -- exactly name of function and here is the, biggest thing, not called book pages, what is the name?  Remember our defined instruct?  Our field is called NUM pages.
	This is what generates all the other stuff.  Book NUM pages and pass it -- whatever book object I want.  Pass at that book, might pass it -- new, or sorry -- make book, and might be the book.  Hello by HMMM and thousand pages long and not copyrighted.  I can run that.
	So -- yeah, okay.  So book NUM pages, one thing people forget when they get into it writing code, they forget the selector is equaled book NUM pages and want to call it just NUM pages -- or want to call it something like B 0 NUM pages.
	But that's not the name of the function.
	It's book NUM pages.
	-- okay.  In Racket, what do you call the getter?  The selectors the getters?  This is a string question, not Racket, Java, in Java, Java provides a -- corrector provided ways to get to the 4 fields, what are those 4 fields called?  Well -- I'm going to view the getters as, something like, dot title.
	-- okay?  So that's weird.  It's an object.  Like dot, and method name but not really method name.  I don't use parentheses.  Dot title, I'm going to think of that, and dot author I'll think of those as being the getters, they do, take B 0 and get title out of it.  Same thing here, except in Racket, little longer, because we need to throw in book hyphen, in Java, we said B 0 dot title and it knew B 0 was book, it doesn't type as much in Java for the getters.
	Now, when I say getters usually we think in Java of another method we wrap on top of primitive internal field access sores, usually called something like get title or get author and wrap that on top to get more control over function and that's fine.
	I'm saying what is the internal way of getting those field that's Java provides and doesn't look like a function at all, but now that I see Racket it's kind of a function, give it object and get answer back, sounds like a function to me.
	Okay.
	If you want it define, define, get title, of a book and then go ahead and do whatever you want.
	Probably something on top of the primitive book title, B 0.
	Again, just another function that you write.
	So -- okay, yeah, let me go, call it grab title or get title or fetch title, something a little different.  Sometimes you want to wrap the contractor a bit.  Have your own constructor that always fills in 0 as number of page ors something like that.  So might make a function called -- create book -- that calls the underlying create book.  Things like that.
	Okay, da-da-da -- great go ahead and write a function involving books.
	-- I want to go ahead and write the function -- also be a little bit interesting.  -- have a couple.  First let's go ahead and write a short simple one.
	Called reading time -- or time to read.
	-- what is time to read do?  Let necessity give check expect here.
	Time to read, and if you give me a book, it returns how long it takes to read the book and I'm going to say I consulted with people in the book industry and found out national average it takes people 2 minutes per page to read a book -- so, B one was this book here, the cat in the hat.
	It has 37 pages, so how long do I expect to result to be?  It take twos minutes pr page, 37 pages --74.  And that's going to be, that's going to be the amount of time it takes to read, 74 in minutes.
	And I can do other ones.
	0 page book?  How long will that take to read?  0.  Okay.
	Great.  And if you want it go ahead, exactly, if you want to have other check expects, you quo could, I don't need to have named this B 0 and B 1.  I can make a book and use it right away.
	I'm looking for book on my shelf or something like that.  What's a book with a short title name that I can act as a real book.  PHP for all.
	Okay.
	And it's huge book.
	And it's by, Amy, I don't know -- and it is copyrighted -- okay.  Timed read of that book should be 2 times 1083.  I'll shoes a number that's easy to multiply by 2, there we are.
	There we are.  Okay, there are my check expects.  Go ahead and give me, what's the next step of design recipe to write this function time to read.
	Make she can expect, next scroll down, yeah.
	Sorry, I can't see -- for me the code is covering up everything else.  Move the camera pad a little bit down, a little out of the way.  There we are.
	Okay, so yeah, now go ahead and what is the next step of the design recipe.  We do a test cases and then what.  If you're having trouble remember bettering, bookmark it, write it down, laminate it, tattoo on arm.  Before the stub function -- before you stub it out, it's part of that same step, but several things we want to do.
	So again, go to web page, at top, there's a link, homework page is about recipe.  So the signature and header.  What's the signature for this function, time to read.
	Signature for this function, -- time to read, what's the signature --
	And part of this means remembering, what is the -- that signature and what is the form we take to write it.  Yeah, so, go to include book to INT, time to read to INT, there we are, Steven has exactly what I want to write down.  I want the name of the function and then colon and then stuff Aaron provided.
	And not sure.  It takes in a book and returns an INT.  Okay.  Sounds good.  By the way is INT the right return type here?  What was the -- the typed the number of pages?  Of the number of pages?  If we look up.  Data definition, we're clear, NUM pages is natnum.  What's wrong with saying it's a natnum?  That's great if the average reading time is 2 pages per minute.  Next year new study, says average reading time is 1.982 pages per minute.  Well, that's not going to be natural, even if natural number for amount of pages, the reading time in general I'm going to say is going to be a, depending how I want to write it, this is maybe more detailed then you need, but it's worth thinking about, and realizing to yourself.
	It could be, it's return on amount of time, and amount of time is inherently a -- a real number.  And so that's sort of suggests that.  If you don't read an integer, if you read 1.9 pages per minute, then yeah -- okay.  So, and NUM negative, you can't read I book in negative amount of time, you could read in 0 amount of time.  0 is not positive.  So that's the signature.  If you said real here, I would be happy.  Point out maybe it should be a real number, and non negative, always a little question of how precise you want to get about the type.
	Signature, exactly, yeah -- signature, after signature and before the header, what was the one other step.
	Yeah, the purpose.
	So the purpose, what is the purpose of the function?  Return the amount -- of time to read -- and there's one important piece of information I want to include here.  Can anybody read my mind?  About what this piece of information that should be mentioned in purpose statement?  The units, exactly.
	This is the only place where that tends to get mentioned and it's pretty important.  It's not obvious from other parts of code, that's pretty crucial.
	Now I can go ahead and giver the header, by which I'm going to define -- time to read -- come up with a good parameter name -- what's good parameter name -- gosh, really I don't think of great name.  This book or I --/-- I'll call it A book, but this book, in object-oriented program it's called -- this.
	It's often so automatic, you don't actually write it out.
	I'll call it A book.
	And again, this is what I call header, line 33 here.
	And I like, just this point I want to make sure I have all my paren's correct and checks okay, and fill in with some -- not, some incorrect answer but at least one that meets the signature.
	So fill with non negative real.
	So fill it with -- something like that.  Just o see.
	And then run it and make sure that I have all parentheses matching and sure enough, I ran 3 tests, 0 tests passed.
	Go ahead and finish that function for me, replace 9999 with actual code.
	What's easiest way to splat text to you guys, if I want to copy and paste and give to you guys, what's the easiest way to get to you, is there a pod?  Files.  Add new file share -- okay.
	Let me, -- I'll save what we have so far and up load that file right now.  How I do up load the file?  In file pod is not -- browse my computer, there we go.
	Okay, can you see that file pod?  I should not cover up the chat window.  We don't have enough space.
	Okay.  If you want to grab that, you can.
	In -- the meantime, how do we finish that function?  Yeah, so SEAN has something there that could be good.  And what I want you to think about here, you know it's something times 2 -- sort of go top down or bottom up.
	I'm going to look a little bottom up.  I was given a book and the know reading time, expert buddy said, title doesn't matter, author doesn't matter, just number of pages, so how do I, extract the number of pages and I want you to sit down and even gauge and go book.
	Probably go up to data definition and say what's that field call add again?  Okay.  So book NUM pages of a book.
	This area, returns an unusual number and take that and multiply by 2, how do I multiply by 2, call star function and give it 2 inputs.
	So I think this is what SEAN has here.
	Again, I want you to engage with being able to remember that, that this is, calling the getter.  And just, being fluent with that so you don't get stuck later on and have other homework involving STRUCT and get errors all over the place.
	I run this, see if it works.
	3 tests passed.  Awesome.
	So I'm going to go through one more example, I'll go through and do the check inspects for you and say, okay, how would you actually write the code?  So, how about, I'll start with check expect -- I'll call this book to string -- and if I give it B one, I expect to get back the following string.  The Cat in the Hat by Dr. Seuss, 37 pages -- and that was a copyrighted book.
	And if we had a different book like -- B 0 here, I'm glad I gave the names B 1 and B 0.  I might have to look them up again, but I don't have to repeat that.
	Do you want to repeat make book of brevity and wit, -- give it a name and use that name in all of those   situations.
	I see a name I could have written out that contractor called.
	So this was, -- brevity -- and changed this to be 0 pages.  This one is not copyrighted.
	(Coughing).
	I hope I don't, I don't blow your ear drums out, I apologize.  I'm almost over this cough that's been hanging on, doesn't hurt, it's just is there, it's been several weeks now.
	Okay, da-da-da, great, what else do I want?  Signature.
	So go ahead and give me the signature for this function -- everybody do it themselves -- don't type enter yet, I give everybody to write the signature for dysfunction book to string.  Look at examples, reverse engineer.  Don't type it yet, go ahead, start typing but don't hit return.
	you should be able to do this, I'm trying to communicate this is something I do expect you to be able to do.
	And start writing it, you realize it's almost silly signature.  now people can go and press return --
	Yeah, so exactly, -- both of those exactly right, book to string name the function and give space and colon and type it takes in, book, arrow, hey, wait a minute.  This function is too well named.
	Okay.
	Purpose, return an user friendly string representing a book -- go ahead and put header, define book to string of, again I can't think of better parameter name other than book, there's nothing special about it.  Not the current best seller and not whatever, the book that I'm currently reading, just any book at all.
	Okay.
	In fact, one thing, when I say representing the book -- I'm going to go ahead and actually -- go retroactively and do to my other one.  Instead of saying time to read a given book.
	Meaning you give me a book and ail tell you about it.  That's what parameter means.
	I like referring to my parameters in the purpose statement.
	Okay.
	Okay title.  Signature, purpose, header, just a stub here, blah-blah-blah -- run that -- and all -- on parens passed.
	I have 2 test cases failing.
	So let's fix that.
	.
	-- so now, so here is how I phrase this problem here -- inside the body for this function we're going to need to pull out the field.
	So everybody write a different constructor, a different little things that inside this code, pull out the different fields.
	Everybody choose a field at random.
	So, NUM pages, book title.
	Both of those on the right track, can you fill it with something that's actually going to be in my code, in particular, call the function, don't tell me name of collection book title, but call book title.
	Not just say the name of field, say I'm actually going to call it.  Close but not B 0, B 0 is no the book I'm interested for this problem.
	Yeah.  -- so you have this here, and then, Chris, yeah, book NUM pages of a book -- and, book -- what we had, title, NUM, what else?  --these 3 windows are, having the Racket open, yeah, it's, author, book, author -- of a book, and I kind of like, just because I'm slow and simple minded put in the same order, unless I have reason not to.  Here I'm going to swap lines, I want to, here is what I want to do, here is aside, fancy keyboard combo, if you look in documentation for doctor Racket there's a bunch of keyboard combinations that can help you around.  Right arrow and left arrow move one character forward and back.
	Escape right and escape back.
	Online 48.  I'm in the beginning of open paren, I hit escape right and it gets me to the end of the expression.
	That's one way toe navigate.
	And then the other thing, if I want to transpose 2 expressions, swap the expression before and after where I am at now, I'm at end of line 48 and I want to switch the book Arthur -- escape control T, escape is prefix that does it at expression level.
	Transpose 2 expressions and it will swap those 2.  Each expression took up a line.  Book, NUM pages and book is copyrighted.  What was it?  -- let me scroll up and look at data definition, again is copyrighted.  That's kind of long name.  I'm going to go, if I were in Java I would probably call it is copyright.  Since I have the question mark here, that tells me it's going to be yes or no question.  So copyrighted with that question mark.  So I'll go and change that.  Okay.
	So these 4 fields.
	Okay.
	And now I need to take these thing things and do something with them.
	So, I'm not saying I'm done -- but I'm like, this is sort of on the road to getting there.  In fact, right now I'm -- I'm going to copy and paste this and go down to the bottom and I'm going to paste this and I'm going to put in block comment for now -- I'm going to call this the template for book.
	We'll come back to that.  lot's finish this book to string.
	Again, taking sort of bottom up, small pieces I'm going to need, now I need to start assembling them.  You might want top down that's cool too.
	But, yeah, okay.  I'm looking at this, -- and I'll, take a break after this here.
	Book title of a book, that gray piece, piece highlighted in gray, that whole thing evaluates to what type?  It's going to be a string.  So I have a string and look at this gray area and that's string.  If I look at this gray area, what type is this?  It's an INT.  And a can tell, I want a string is there some function that can take this INT or natural number I'm getting and turn into a string and then go off and is search the Racket pages and there's function called numbered string.
	There might be integer to spring or INT to string as well, okay, that's all good.  
	And now, it's good guess, might well be there, would not surprise me if it's spelled out to integer, if there's integer to spring not surprise me.  The fact that you can guess the name like that, it's probably both a good system, system, you're catching on and provider system has few surprises.
	This last one is Boolean and want to turn into string that has open bracket C or not.  I have to think about that one.  So Boolean and depending on true or not, I want to get something different.
	What is a function that takes in a Boolean and giver a different answer depending whether or not that Boolean is true.
	Come back.  I'll show a slightly variant on COND, let's see, take a 5 minute break, rounding slightly upwards.
	See you in about 5 minutes.
	I will mute and have a coughing fit here.  That will be fun.
	
	[Break Time] 
	[Break Time].
	PROFESSOR:  My computer froze up for a second.  Start resuming these.  Is the web cam okay?  Is anybody having stuttering issues because the web cam is too much, if so, let me know.
	And start recording, start sharing the screen --
	Yeah, I can go ahead and have a CON here, but for the book title, that's a string and I want it and want string pending, but I want title, author, want the number of pages turned into a string, only thing left is this Boolean, I want to is say depending on this Boolean, I want the string for the copyright or the want the empty string, I can use COND here, I like COND when I have a bunch of cases or even case 2s, doing case analysis on union type.  I see COND as top level of a function, that's like handling union type.  If that's what they're doing, it helping communicate that.  There's another function called IF, IF is function with flee inputs.
	Okay?  It takes in -- a Boolean value and then says, what should the result of function be if that Boolean is true and what should it be if it's false.
	It's like an IF/ELSE, there's always an ELSE, not like Java, if condition is true do something.  If condition is true -- here is the answer to the IF -- so in this case, we have copyright, see otherwise, this is exactly the IF statement you use in Excel®.  If you use Excel spreadsheet.  It rocks.
	Does Java have IF like this?  Notice this IF is going to evaluate either the string C or empty string and I'm going to have this in the middle of string pinned.  Can you go ahead and have in Java IF statement in the middle some big string append?  Not the remember IF statement, but one thing that you can do, one thing you can do is something along the lines of -- look at this, is copyrighted -- you may have seen this before, -- oops, I need colon in there in Java.  So this, operator, question mark with colon, it's way of writing IF, but doesn't look like a regular function, it in fixed notation, plus comes between the numbers it's adding, not like math dot square root you name in front the number.
	-- this here, the name of function is question mark colon and that name it interspersed in the middle of the other arguments, which is weird syntax.
	And nice thing about this in Java, you can't leave off the ELSE part.  An you can put this inside a bigger expression.
	So, I'm going to say, dot -- this dot length.  That gives length of the string or I can say this -- plus hello.
	And I'm adding 2 strings now.
	Not really regular expression, just sort of, you write in regular expression of question mark is a special character and special, colon can do something special.  But understand not related to that.  This is Java's weird syntax for the IF as an expression.  As n expression, meaning it can return, evaluate and give back an answer.  As long as IF statement, IF and curly brackets that cannot be the part of middle string append and I have to put actions inside there.  And ELSE is optional.
	Yeah, but -- so looking back at this, this is kind of have, I could have used COND, COND is more general, it handles --
	Okay, -- great.
	So here I have a string, here string, here string, these are 4 strings and all the string that's makeup the answer including what comes in the end, either copyright or empty string depending whether or not copyrighted.  How do I put these together?  That's going to be called string append -- and, hopefully you noticed in Dr. Racket, tab does not mean insert tab character, you're expect how Racket code is formatted, indent the way you think should be indented.
	We'll see what we need in a second.
	And so if you hit tab, I take these parts out.
	Hit tab often when writing Racket code in Dr. Racket.  If it doesn't look indented the way you shy it should be, probably meaning missing parentheses or something, so you can figure out -- before you have bigger mess to unravel.
	Okay.
	String append, all o those things -- you see I have open paren for define, so close that up.
	So I can run this, and, 2 tests, failed and start looking at it, yeah, the Cat in the Hat.
	Oh, I want a comma and space, great, I can go ahead and string append.  This string and between that I want to append a different string in between those 2, so -- by, so and so -- an after book author I have space and open paren and number of pages and after of that letters PP, close paren -- and that was followed by empty string or space.
	This is why, empty string is important to have around.
	It plays the same role as number 0.  Life is easier when we have 0 as number to work with and add 0 to things if I feel like it.  I can, -- okay.
	Run this -- and all tests pass.
	Okay.  So, I was doing this, now, exact O any exact questions on that?  Hopefully that makes sense.  We meet our test cases, we gave signature, good to remember what's coming in, what types are coming in and returning, and all of that.
	And then, the one thing we did before we still got started.  These are a bunch of things I know I'm going to be doing, pulling out all of the fields.
	In fact if I were to ask you, I want to write a function that takes in book object and goes, okay -- write that function -- and now you're like I didn't hear what you said.
	You heard it takes in a book, right?  -- if it takes in a book, what do you know, what is code you already write right now, by the virtual fact that this code processes a book.
	And that's what we're calling the template.  So template for a book, -- I call it FUNC for book and it will take in some book and pull out the different fields.
	Once it pulls outfields, what it does, I can't fill that in yet, somehow I need to explain all these different pieces.  But I'm going to do that, and remind myself of the types of this, book title that returns a string, book author returns a string, book pages returns natural number.  This last one Boolean, remind myself types and functions I want to call them.
	If I ask you to write 25 function that's handle this book, you'll use this code a lot.  And pay attention to how many extra characters we have to type beyond the.... (coughing) -- excuse me again.
	In fact I go up and start, I won't be able to put a description there, purpose statement, but I can start the signature, I'll have to change the name whenever I make a real function but it will take in a book, and return something.
	So, this is kind of handy, in fact, Racket student language knows the ideas of template.  If I included this open paren around it then I can save this, it doesn't give a syntax error.  It sort of, ..., that's template I'll leave it alone.
	So this is, the template for any function handling a book.  Okay.
	New example.
	Let's write a function that handles a book.  Okay.  I'm going to write, I'm going to call this function derive, and what do I want to derive, what does that mean?  I'm talking about copyright raw law, making existing work and making derive from it.  You take music and slice it up and add another beet over it and publish it and say this interpretation is my art work, based on someone else's but new and I don't need copyright on the original because I made new artistic work of it.  I take picture of amazing guy and put words on top and bottom and call it a mean and say it's new art.
	Okay.  So that's -- what I mean by derive, derive, I take a book, and do some examples, I'll take that Cat in the hat and I'll add -- add -- me, BARLIN add another 5 pages to the end of it and I'll call it a new book.  Okay?  -- so derive, if I give it this Cat in the Hat book, I want to get new book back, here is the book I want back -- not quite named The Cat in the Hat, it will be named -- the son of The Cat in the Hat.
	Okay.  And, the author is not going to be Dr. Seuss, it's goes to be SEUSS and BARLAND and it's going to be 42 pages, originally I thought it was 37.
	And it is not going to be copyrighted.  I'm doing this for underground printing press in basement and publishing on web.
	So the answer, I want a new book that has these fields.
	How do I make a book that has these 4 fields?  Check expect to work -- make book -- I'll hit tab, tab, tab, -- there we are.
	Okay.  So here, this is one check expect and hopefully informative what this function is doing.  Taking existing book and makes new book from that.
	Okay.  Questions?  Can you make another one?  Probably should, right?  -- what should I do for this orange one, book B 0?  -- I'm going to go ahead -- anonymous, add 0 more pages onto it, it should be a new book, tell me what this result should be for the check expect?  -- and again, the real thing, the result is book, and I haven't, the exact fields that are there, I don't already have so I need to make a new book that has the field that's I want.
	So I have to go and look up what that B 0 was, it was brevity and wit, so now, the name is going to be -- you know, I think just son of, rather than the son of.
	That's usual all paradigm.  Son of brevity and wit, by BARLAND and anonymous, ON, -- whenever you derive a book, it will not be copyrighted.  Flat out never copyrighted.  So, great look at this, and let's see what --we can do.  What's the next step in the design recipe.
	What's the next step in the design recipe?  -- and again I can go up and recipe here.
	By the way, choose data definition, give examples of data and have template.  We do that once for the type book and never need to do it again, as long as we're still using book.
	We did a test cases now we need the contract, header, purpose, okay.
	Contract, header, purpose.
	Contract, derived -- takes in what and returns what?  I'll fill in the purpose while you fill in rest of the signature there.
	 So, what's the signature of derived?  -- how many input dozen we give it?  And what types are they?  -- take another 60 seconds and see if you can write it down.
	 mark has an idea, -- yeah, so the, the signature is about types.  So, SEAN and Marcus right, how many things do I give it?  3 pieces of information.
	A book, a string, and a some sort of number -- book -- string -- and now some sort of number -- what should we call it?  You know since represents number of pages and earlier we said, number of pages is natnum, I think, if I am representing a book, does it have integer number pages or not and you can go back and forth and depending what you mean by that, physical books have, number of sheets of paper as natural number.
	But once we have E books, maybe I consider book that's 3 and a half pages.
	We set natnum, I'll stick with that, what is return time book.
	Okay.
	Okay.  So, take, and now, the header, think of good parameter names, what should we call that book?  In this case I have a better -- name for that -- let me come back for that.
	The string here, I could call it just -- a string.  But there's many anything what the string is, what's the good parameter name for the string we're getting.
	Yeah, new-author, I like that, -- okay.
	Great.  And this integer here, number of represents the number of pages added so -- added pages, maybe?  Sure.  NUM added pages?  Whatever, what should we call that first one?  -- yeah, original book, I could call it original book, I know from signature it's book, as programmer I expect other people to look at both name of parameter and type.
	So, calling it original book might be redundant.  -- okay.  Anyway.
	I'm happy with these names here.  And now what is this body look like.  Wait I minute -- I'm going to go ahead and copy and paste a bunch of stuff from template, and see if I need to, shouldn't call it A book, call it original.
	By the way -- time saving tip, you probably know this -- double clicking selecting and entire work.  Dr. Racket, double click anything Dr. Racket selects a word knowing how things are punctuated in Racket.  Copy, double click own A book, double click paste.
	That's nice and easy.  Okay.
	Yeah, so, gosh, what information do I have going on, I have the original, the title of the original, author of original and also have new author and added pages.
	So I have, gosh, 3 strings, 2 natnum and Boolean all happening?  Okay.  Anyway, now we're ready to start saying there's template, let's write this code.
	-- book title -- what am I going to do with book title?  Start with Cat in the Hat.
	Should I be top up?  Bottom down?  In this problem, how do you want me to approach this, we're already a little.  Sorry, top down or bottom up.
	We're already a little bottom up because from what's in our template -- first one wins.
	Top down, okay, my final answer, how do I make my final answer out of all the little sub parts, what do I need to do?  And hint the answer can be seen in check expects.
	What function am I going to call that assembles all the other pieces here?  I have a bunch of small strings and might build to bigger strings and so on, but then I'm going to do something with other pieces?  Yeah, make book, exactly, this is right on -- make book, hit tab so it looks nice -- and tell, make book and it was 4 different things.
	Yeah, my answer needs to be a book type.  So better call -- make book.
	Now what should the 4 things be, and I guess now I'll walk down, so I have, the Cat in the Hat.  That's part.  The original cat in the hat book, this part here, is cat in the hat I want son of -- so string append, son of -- and book title -- I forget a space there, no biggie, if I forget about that my test cases will be over that, so I'm happy with that.
	So that's the first thing that make book is going to want.
	The next thing make book wants is author, and needs to be original author, followed by the new author with ampersand in the middle.  SEAN is working ahead here.
	Book author, original, space, ampersand, and new author.  I'm stretching the end -- I'm not too wide, about a, you know, at least 80 characters online before I line break, maybe one hundred is a reasonable default these days, if not even wider.
	But okay.  Anyway so, okay, blah-blah-blah, how many pages?  Plus of that, with the added pages.  And then now, what's the copyright status of the result?  And when I was doing test cases I said, it's always going to be, somebody publishing underground, not file for copyright, they want other people to make further derivation from their work, so we don't really care what the original copyright was, whether it's true-or-false, we don't care.  What are we going to use for the copyright of the result.  It's always false.
	Okay.
	Let's see if that works, run -- all tests pass.
	Okay.  WHEW -- does that make sense?  People okay with that?  Kind of a lot, went through kind of fast, but -- it's the same idea we've been applying.  Yeah.
	And if we look at this code, about half of it was already in the template.  We added the make book, and we added some string appends and some pluses.
	But if you don't, if you look at, I didn't have to type what was in the template because I copied and pasted that, stuff in parameters I had those sitting for me, so it was actually, one word, 2 words, 3 worlds, 4 words, I guess I have a thing think about this, 5, 6, 7, 7 words not in the template.  I like the template, it saves typing, often, we see examples in addition to template it's one word or 2 words is all you need.  Sometimes the template brings you really close.  So I like this idea of formalizing it and adding that step in there.  This design recipe, as you get more experience.  Once you even grain the steps you may not write it out and do the template until you write the second such function and so on.
	So this design recipe is not, something you follow religiously, but it is the exact step that's expert programmers follow when they go about designing new work.
	And I like the designer speed, focuses on getting data definition right is where a lot of thought should be going.
	Okay.
	Other thing interesting, this is function that takes in a struct and returns a struct.  And that's sort of -- we take a book and turn in new book.
	We have never going to change fields in a book.  So -- we're never, once we have a book like The Cat in the Hat, the title, 37 pages, that's never going to change.  We might make new books, maybe make new book that's have the same title but different number of pages and program can use that.  But never have an object and then change the fields in it.  We'll be functional programming for this class.  So -- in particular, you're not allowed to use Racket function that's have exclamation point in them.  None of the built in functions.
	Those are all function that's change fields.  So even if you see those in documentation, we'll not be using them in this class, again, exclamation point is the forbidden character in the build in library function names.
	-- it's sort -- setters, the student languages don't have the setters.
	Okay.  Question about, union types, take a break and talk about that, sure.
	-- just so you know, next step is combining union types and these compound types, rather have an union of compound types.
	It will be a natural thing,we see if in a second.
	Chase a particular question?  -- union type is just, yeah, going to get input, either one of these, those, or the others.
	Code, handles it, I have one particular one of them, is it these, those, or the other.
	So --again, notice I give points for all of the steps, if you have test cases, if you have signature, a purpose statement, and header, you know that's already well more than half the points.  Going and finishing it and getting it working, that sort of, okay, somehow, that's important, but, I'm more important about getting this other framework in place.  What was it about the homework, which homework problem?  Trying to remember the first one?  -- I already forgotten.
	Directory response -- yeah, so, again the general situation is you're going to get directory response, go back and pull up that -- web page for a second.
	There's no structure going on here.  Define the structure, not a define struct if that's what you're saying, how do we know that this problem is not a define struct, what's the keyword?  Because the define struct says a book is an author, string and another string and a natural number and a Boolean, this is OR, it's either string OR false or private.
	So again, some of the exact examples to look for in the notes.
	We did the stop light color, was, processing union types, what were some of the other examples.  Da-da-da -- just simple functions like initialize, functions handling strings and then uses COND, that was the example where we had the stop light color that took in an union type.
	 so then taxable income was another union type, so look up code we did for all of those.
	Every problem on the homework, hopefully is -- all ideas you need are from an example we did in class.  Sometimes it's, putting in the pieces together, takes some thinking, but, yeah.
	So basically it will be getting your CONDs right and figuring out.
	Like here, I have this definition of stop light color and it's one of these, either red, yellow, green or flashing yellow and so on.... we have to ask, I need to come up with questions so if I've given some random, SLC or ASLC, is it red?  Yellow, we use COND and tests were equal, that made sense.
	When we had the numbers, I'm giving number and it's either in this range, that range or that range, different question, symbol equal, I went ahead and had a, used less than.  Okay.
	And then, the interesting thing was, the taxable income entry, can either be a symbol or a Boolean or one ever 3 numbers.  That's almost too close to the homework problem.  I didn't realize how close it was.
	And how did we do it?  Here are different questions.  If you give me A taxable income entry, ask if it's symbol, if it's false, if it's a number that's less than 9075, we may have talked about it, or maybe the other section.
	There are 2 versions of this file, one in distant section and other -- you can leave off that AND part if you want.
	As long as you ask question that's can distinguish all the different cases you need to distinguish.  That's the purpose.
	-- so, okay, let's go ahead and -- do one more example, I want to go ahead, so I want you to go and take a few minutes, and be looking how we did this.  Here is what I want to do, I rant to -- I want to represent a DVD, us libraries we do more than books, we rent DVD's as well.
	I want a data definition -- a DVD is -- and now I want data definition that represents, and what things do we want to keep track of?  Maybe title, maybe how long it is, maybe -- whatever the rating is, PG, R, whatever.
	And I'm sure that's enough for now.
	So go ahead and see, this is the real thing, this is in real world, your boss says we need to go ahead and write programs involving DVD's and they'll give you tasks, but before you get to the tasks, step one, figure out data representation.
	So go ahead and take 5 minutes, and see what you can come up with, a data definition for DVD, hint -- maybe looks like our other data definitions.
	You can look at other previous files.
	Title, length, rating -- I'm not too concerned about the details.
	-- let's go for title, length and rating.
	And take 5 minutes, see what you can come up with, and I'll take a break and be back, and I'll pause the recording just to make it less suspenseful for people watching the videos.
	The exercise is, I want you to come up with a reasonable data definition for a DVD -- something that encompasses the fact that DVD's have titles, the title, the length of the DVD, and the what the rating is, PG13, or are.
	I'll write that down here, and leave you to it.
	This is separate from the 5 minute break, take 5 minute break as well, but you're not on break right now.
	PROFESSOR:  All the way through step 3.  
	PROFESSOR:  Okay, go ahead and come back.
	-- should DVD string included.  Designer pieces that 1-3.  -- go ahead, what sort of data definition do we have for DVD, DVD is, first of all is this compound type or union type?  Stop light color or like book?  Yeah, compound type.
	How do we have compound type, let's scroll up and see how we did that before.  We sort of, we had a define struct, number of fields and include the types -- okay.  So go ahead and do a define struct and the types.
	-- what should we name the struct, DVD is good, minus one is you chose a different name.  That's confusing.
	It can be in all caps.
	Define struct DVD and open paren by field names.
	We decided, title, length, rating.
	Gosh, I almost like, if you boss we are to say these are the things we care about, those are good adjectives, and, had you talk to somebody in the movie business, and they use those err terms, so whatever they use, you can use in your program.  You could say length in minutes if you wanted to, at that point I might call if just minutes.
	Is usually I like calling it length and having comment saying what the units are, but yeah, we definitely need that.
	Okay.  So, DVD is -- make DVD, where you have to give me, I'll line it up, title, what type should that be?  -- should probably be a string.  Length?  Yeah, natnum, or real -- again, a little bit, up to you, can you have a movie that runs for 4 and a half minutes?  I don't see why not.
	Usually when people report it on websites, they round it to the nearest minute.  But, yeah.  If you want to stay with that.  Say, yes in my system a movie has integer number of minutes an my system will be unable to cope with movie that's have fractional number of minutes.
	We'll have to fudge to get that done if at all.
	How should we represent the rating?  So, CHAR, symbol.  The reason I don't like character had we make examples of data, what are possible ratings, B that's fine, but PG is not single character.
	So I can use a string, but you know, I'm going to say that we have strings, we have I am symbols that are awfully similar, for me, this one symbol feels right, so I'm going to go with, ASHENAFI's suggestion, I'm not going to do substring, not do going to string the ratings Luke numerated type symbols.
	In Java I would use enumerated type.  Exactly.
	So great, that's good, that tells me the 3 fields, tells me this, and should probably have some comment, somewhere, saying, -- the run time -- in minutes.
	 there are different ratings for different codes.
	If some other weird rating, if ambiguous, maybe in I don't know, in SOLVENIA, G means gory movies and if it's rated G you have to know if USG before I bring my daughter to it.  Yeah, stick with US ratings.
	The point is, as a programmer, you think about what is the right way it represent the data.  A struct for DVD overall and then the different fields.
	Okay.  So that was step one, can you make me examples of the data?  Fine to speak Java we're is speaking in all sorts of languages here.
	Step number 2, examples of data, So, hopefully, you made examples of the data.
	Make DVD -- Spiderman 5 -- okay, something like that.
	Good to go ahead and exercise different options, with strings -- what are some string that's I think about?  Gut reaction, can you have the empty string here, string of length one?  String of longer than one?  Punctuation -- only punches ail, all same letters?  Different letters?  I'm not putting any restrictions, if they want to make title of movie called empty string, that's fine.  One thing I cannot have in my system is an untitled movie.
	My struct must have a title and I'm using a string.  I can use empty string and sort of save untitled but that's maybe technically different.
	I have websites, where I don't have a password versus websites I have password and that's empty string.  I can use string untitled until someone makes a blockbuster movie called untitles.
	Or is that untitled movie or movie whose total.
	We don't have -- how would you do this in real life?  If you wanted to allow untitled movies?  You probably have new data definition for the title and probably be, can be a string or false.
	That's a pretty, yeah, but artists, they like to go and insist their movie does not have a title -- like Peter Gabrial's first 4 albums, they call Peter Gabriel one, 2, 3, 4, they're not titled.
	Yeah, you're right, in real life another data definition and probably union type, either string or false.
	Exactly.  Yeah.
	Okay.
	I don't mind this being shortest a movie can be?  Could be as short as 0 I guess, it's very difficult -- what is the adult rating?  -- M for mature, is that what it is, I don't know.
	Okay.
	Yeah, so, okay.
	NC 17, thank you.
	(Coughing) yeah, so -- this is a, shocking movie here, not very long, no title but NC 17.
	So those are examples of the data, do that, and they with can go ahead and give me the template for any function that handles a DVD.
	 I was thinking of movie that was actually 0.0 seconds long, since we have natnum we can't distinguish, the so bad the whole thing got censored, every bit of it.  Okay, template.
	functioning for DVD, I don't know what sort of time it returns, I can't give a description but I can start writing -- and be ready for a break after this.
	-- what are the steps here, pull out the fields.
	So now, that's what I want you to remember, what are different ways to extract the fields, sorry -- how do you extract each of the 3 fields.
	So DVD title is name the getter, you have to actually call it, how do you call function in Racket, open parentheses and then the name of the function.  Yeah.  Length.  And I'm thinking this is going to be a string like Spiderman 5, it's going to be a number like 92 and this last one symbol like PG.
	Go ahead, take a 5 minute break, we're 4 minutes over due for that.  And come back and carry out to 8:25 p.m., somewhere in there -- I think I forgot to resume recording after our 5 minute break, oh, well -- 
	[Break Time].
	
	PROFESSOR:  The moment I turn the camera back on, I have to cough again, and forgot to turn on the camera, too.
	And you missed my beautiful face.
	I'm sorry, so sorry.
	Okay, recording enabled.  In the fire sharing pod, I put the file where we were just at.
	There's no sound --there, now it seems to come through, the sound is now coming through, okay, sorry, I don't know what happened there.
	Okay, thanks.
	PROFESSOR:  The sound went out again.
	The sound went out again.
	The sound is out -- turned on the sound again.
	Now I hear him, now I don't -- now I do.
	Okay, wonder if I should log out and log back in.  My connections.
	If it drops out once more, I'll log out and log back in.
	Okay.
	-- don't think so, we'll find out.  -- yeah, so I should be able to give you data definition, you figure out it should be compound or union and do it and be able to setup a template and write functions involving that type.  Okay, I will sit up straight with good posture, good advice anyway.
	There we have.
	Okay, now I'm going to go for one more twist.
	Data definition.
	And actually nothing new -- not sharing screen, thank you -- da-da-da, and new part is going to be, we'll call this a library item -- and going to be, a library item, going to be union type, something or something.
	A LIB item is -- a book, or a DVD.
	Okay.  So, new data definition, now book and DVD are predefined terms, so we're making a new type, union of 2 other types.
	Can you give me some examples of the data?  That's easy.  Copy and paste Spiderman from there and grab that Cat in the Hat, no problem -- okay.  Those are examples of data, in fact I'm happy without having those.
	Keep in mind, I want a function that can take in either of these 2 things.  Okay?  -- owe say, so data definition, examples of the data, and now templates.
	That is, again when I say template, I mean the code that I can write not knowing what the function does, but knowing what type it handles.
	-- code for any function which processes a lib item.
	Okay, so go ahead and call that -- FUNC for lib item.  Signature will take lib item and do something -- we don't know -- yeah, so this is an union type, so going to be conditional.  Yeah, go ahead and, FUNC for lib item, and I'll call it an item -- okay.   COND, hopefully between this and doing the homework we're getting -- we're getting fluent with this COND.  It's a COND with how many branches?  -- yeah, a COND with 2 branches.
	So -- I know I have that, now I need a question, I'm going to give you a lib item, code, lib item, you need to tell is it a book object or DVD object, yeah, no problem.
	Again, extract the getters from the object.  We don't know what object we have, so we don't know what the getters are, I'm not sure if that's what you're asking.  So we'll fuse together what we've done.  It turns out, there's a, which question, which -- what's the function you wish you had to figure out if something was a book versus DVD?  -- does anybody want to throw out and make a wishful function?  Yeah, book question mark.  It turns out I lied, I didn't lie, omitted something, when you say define struct book, or define struct DVD, it make   you a constructor, make DVD, it gives a bunch of selectors, DVD title, DVD link and gives a predicate DVD, a function that takes any type in the world and says yes, or no, this is a DVD structure.  In Java I think of instance or dot class or something like that.
	Okay.  -- yeah, so -- we have COND with 2 branches an questions we can ask about them.  We'll fuse this, idea of COND and other thing we learned which is in template we'll go ahead and say, if I'm sitting here and my code reaches and makes to this answer, I know I have a book item.  What do I do know, if I know I have a book, I can actual outfields of the book.
	Okay?  -- book title, book author, an n item, book NUM pages an item, and so on.
	yeah, sort of copy paste, I'm trying to get inside here, you're right that may have saved "me"time here, so -- okay.  Same with DVD, should I try copy/paste here, watching me type is painful, I'll concur with that statement.
	Okay.
	Something along those lines.  Okay.  Great.  A DVD -- oh, thank you -- copy and -- okay.
	This goes ahead and this is template for function that has lib item.  It's an union and within the union each branch is -- a structure so we pull out the fields.
	Okay, so go ahead and write a function -- have an example, let's write some code.
	I want a function -- I think I called it -- time to waste.
	-- you know how I bunch, grab an item, how much time will I waste with this item from the library.  What is the time to waste?  We'll get some examples, I'll grab Spiderman from the movie, how long am I going to waste on that.  It turns out watching movie is 92 minutes an another 5 minutes to get DVD, out of case, and blue ray so takes several minutes to boot up.
	So it takes 97 minutes, that's how much time I can waste on that item there.
	How about time to waste, Cat in the Hat, I could say B one here, I think I gave that name -- and this one decided reading it takes 74 minutes, but I don't know about you, when I have the book I turn to the back cover and I read how great the book is going to be, that maybe takes an extra one minute.  So it was, 74 plus 1.  Let's stick with 74, I want to stick with that.
	So -- let's make is 75.  Now I can go ahead and give a description there.  Time to waste -- a DVD's run time plus, 5 minutes to get it going.  Or for a book -- 2 minutes per page -- or whatever its reading time, plus one minute to read the back cover.
	Whatever.
	Let's write this function -- hey, copy and paste right here.
	Go ahead and make the signature as well.
	Give me the signature for time to waste.
	Okay, takes in lib item and that's what I want to say.
	Positive real number or non negative real number.
	I kind of like that -- again you're like, wait a minute, you said it was first why non meg negative, why mot positive.
	Here is my real description that goes in header, it's going to be what does it function return, the amount of time I can waste, how I compute that, that might be a comment that goes inside the function and in general for this class we won't do this -- but I think it's a good distinction.  Inside the function I'll talk about details how it's calculated.  People that call me, they don't care how calculated.  As I maintain code I may realize some of numbers are wrong and maybe I don't read back cover, something I might have, a, not a non negative answer.
	Might have 0 answers, might have a non positive.  
	Similar.
	Even if everything else is natural numbers maybe it takes 4 and a half minutes to get cued up and not 5.
	I'm happy to go ahead and -- say that yeah, it's going to be a real number even if everything else is natural numbers.
	This is real number, because adding in pauses and non negative -- okay.
	Let's go ahead and do the DVD one first.
	How do I do this?  -- 5 minutes plus the running time -- what do I do with the title?  We -- nothing to do with how long the title is.
	And rating that doesn't matter either -- okay.  Just the length of DVD, it's that plus 5 minutes.
	Okay, so plus 5 -- okay.  Sometimes with the template, I will delete things that are in the template that don't apply to my particular problem.  That's fine.  Doesn't take me long.  And now, what about this?  It's going to be one minute plus the time it takes to read the book.  What was the time to read the book and now set you up for a little -- testing you here -- how long does it take to read the book and add one minute on to that --you're like, well it doesn't -- title doesn't matter, book doesn't.
	>>>  74 for one test case, but a different test case will give different answers.
	Can't always say the answer is 74.  Because I don't say for any book, for any book how long does it take to read it.  Wait a minute.  We already have a fan have I function that determines the time to read.  So rather than say it's going to be the number of pages times 2, I'm going to go back and say, we have a function time to read, and I'm going to call that, time to read, that was the name.
	Good, so -- yeah, I'm going to say really the answer here is plus of one and time to read of an item.
	That's actually the entire, entire case.
	So in this case, there's a difference here, this one I was using bits of the template and put them together.
	This one I have existing code and I'm going to call a helper function, refer the whole thing to helper function, especially if I were to have it written license separately if I think that separate function is useful in its own write, even if I didn't have helper function written, this is worth being its own helper function.
	So -- so that's another sort of thing I can do there.
	Okay.
	So I might call it helper function, I might in line the code, here I called the help err function and had additional work there.  Let's run it.  I need to change this name here, don't I.
	-- what's, previously defined and cannot be redefined.  No problem.
	Copy, double click copy, double click paste.
	-- and now I have this, this actually I already had a, this is note from previous time.
	I was reminding myself what I wanted.  Okay.
	Time to waste.
	What's going on here -- I didn't mean to goof up, but this is sort of thing to look at, time to waste, expects only one argument finds 2.  Give this DVD, wait, the amount that I want to, that's.
	I forgot to put these inside, I didn't mean to, that was mistake -- and if these line are getting long I might put things on multiple lines makes the check expect easy.
	File pod's thank you.
	-- okay.  So I made those check expect and run it, and I hope it runs, okay, all the tests pass.
	I see a little black up there, what's that?  That is code that was never executed.  That's inside template no problem.
	I should scan through and make sure there are no real code branches never executed.  If so I have test cases not accurately doing their job.  Not fully testing something.
	Okay.
	So that's the idea how to combine -- an union of structs, we'll use this a fair amount.  This is common pattern that comes up, union of structs or at least one of branches is struct, if we go to design recipe, -- pull the browser -- so template, we're doing, 3 A and 3 B might both apply.  Union type include a COND for one branch for option.
	If product type, even in one of those branches, pull out each field.
	Okay.  And then, C ignore C for a bit.
	We'll come back to that.
	The inventory, think about what type each piece is and think about the functions you might want to call.  And that sort of thinking step that I do.  We'll come back later and see more of the inventory with values when looking at particular -- same thing with a particular test case.
	And it will get more important once we hit recursive data definitions.
	Okay.
	Questions?  Thoughts?  -- while doing that, one more thing I thought I wanted to do -- da-da-da -- yeah, I think that was all the stuff I had on my list -- just a couple things to mention.
	If, I have an union type or something like that, or even a compound type and pulling up fields and that's main top level function.  If I have an union type inside of that, we'll say let's not mess the COND inside of having pull out all of the structs that's one thing you want to refer to helper function.
	If you have sub item, if you pull out different pieces from compound type and one happens to be union type inside there, you could have a nest of COND, there's nothing inherently impossible about it.  But that's a good place to break it off and call separate helper function.
	Even if I have a structure, if I pulled out different fields, -- if some of the fields I pulled out were themselves more structures, I might want to say that's the time to go ahead and call it a help every function that just handles that sort of substructure, I guess you call it.  The structures in of this bigger structure.
	I can have a struct of structs.  I have object that contains some of those fields, other objects.
	So it would follow the same process, break things into helper functions appropriately.  Okay.
	Other thoughts?  Questions?  -- go hopefully finish offer the homework, I'm going to put up new one, that has D 2 L questions about, here is a product type, you know -- here is a data definition, including the fine struct, you can make me 2 examples of data, can you write the template for it, that sort of thing, that's on D 2 L and I'll have an actual problem for you to follow.
	I'll try to get that, try to have that multiple choice due Monday -- okay.  If you can't make it Monday, like I'll get it out by Wednesday, if you can't finish by Monday let me know.  I want people to hopefully finish multiple choice desire to learn part by next class so were ready for new concepts.
	A lot of reminding yourself what is syntax of COND, and easy when you see me do it and when you sit down you get stuck and you need to go back and forth with the notes a few times and then it will become straightforward.
	So -- in coming question -- for homework, 3 B, 2 functions you write and put them in the same file.
	So -- and hopefully homework 3 B is fun, not dealing with fancy data type, but introducing to images.  I'll simply say there -- window, and, so I have you do add (Inaudible) or require.  When you do add teach pack, go ahead and grab this 2 HTTP image Racket, do not grab the single HTTP, so second edition -- so you add that teach pack -- and once you do that, sort of, we have some time, okay I'll fix that -- circle 20 green solid, I think that's how it works.
	Expect mode second argument that's solid part.
	I'll use that fancy, escape control T to swap both expressions.
	In this case between the 2 symbols.
	Expression ahead of me is symbol and expression after cursor is symbol.  Swap those 2 symbols.
	Interesting you can call the function and you get back the answer and the answer is an actual image there.  And I can make square -- 40 outline blue.  We see the 2 different answers.
	Now the other things that interesting.  I can go ahead and, you can take plus, right?  Plus take twos numbers and returns a new number, doesn't change existing numbers, okay, of course not.  String append, can take 2 strings, didn't change the string but give you long string, Java brings new strings.
	-- string append is like plus, for strings.  It takes in 2 strings an gives back new string, sum of the 2 strings.  We can do the same thing with images, that's function is called beside.  I can say give me 2 images, I'll take this image, that image -- and run it -- and I get the third output result.  It's the beside of those 2 others.
	I can -- here define CIRC 1.  Define SQ 2 -- and I can also say, above of CIRC 1, SQ 2, CIRC 1-, CIRC 1, SQ 2 and run that.
	And now, it's, there's 2 images here, the first is 5 tall and notice after all of this, SQ 2 is still just a blue square, just like when I add numbers I don't change the numbers I pass in.  When I append strings I don't change those strings.
	Same thing, I have images and have way to add the images.
	Adding images is can be beside or above -- or I can -- put one image on top of another.  That's where that exercise is getting at and we'll use this to help draw pictures and make video game out of it.
	But, what I think is neat, first of all the fact that these things are values.  In fact I can go ahead and here -- copy and paste that into the middle of my window.
	And I'm going to comment that one out.
	And now I get I bunch of images above each other.  One above, this, this, this, and SQ 2.  We're not doing anything instead of realizing arithmetic can be applied to images.
	String append is like string arithmetic and above and beside, and overlay might be image arithmetic, you put in arithmetic and get a whole new image as answer.
	I think it's neat, call, unifies things.  That's programming is just -- doing arithmetic on richer and richer sets of data, doing plus, except for string, we have substring and other string operations an images -- different ways of doing images.
	That's all computing is, a lot of people say it assigning to variables but mathematicians never did that.  We'll get a simple model -- coming out of this approach.  Taking values and producing new values out of them and get good mileage.
	Okay.  Any other thoughts or questions?  I'll, fix Chase's comment, you'll be able to submit your quiz, you can take it twice, after you submit one you can see the score, not see the right answer but see the score on each problem.
	I should mention, you can have a correct answer that the auto grader doesn't catch, I tried to get them to catch all the common things I anticipate people doing, -- but -- unfortunately this first, previous homework I would like to have graded by not going to happen, I'm backed up with reports for the department.  So won't get that back until next week.
	The -- hopefully the, minor things.
	Indent well, hit tab on different lines in Dr. Racket, make sure it's indented the way Racket thinks it should be done.  Put spaces between, don't do something like -- having a space between open and closed paren here, or having a space after the beside before the circle, it runs without the space, but it just, don't tend to like that.  there is a style guide, on homework's page, if you want to look at that, you don't need to.
	Control I is a version of tab.
	-- and, I think that was on the homework, let's see what will homework mentions -- da-da-da, oh, so I did differently, I said require this, I like that one better, so do the instructions on homework, so require to HTTP image.
	So I can do that.
	So requiring another library.  So -- what is the purpose statement?  It's one sentence description of what the function is suppose to do.
	And the, let's look at some examples here.
	I can say, if you go back and watch the notes, whatever, you can say that's what we did.  That was the contract, purpose statement and so on.
	Here we have the contract, here is the purpose statement.  This part here is the head are, writing this much, think of name for parameter, -- the design recipe helps with getting you pass an empty screen, adding the check expects and that sort of thing.
	I sort of suggest making things stub function.  When I first did book toe string I returned the string ha ha, made sure check expects all failed, and then you don't need to turn that in.  I went and revised it and replaced with actual code, that's step I do that helps me reach the end more quickly by finding mistakes more quickly.
	So -- okay, sounds good, send e-mail if you have questions.
	Post on discussion board.
	I'll be looking for D 2 L quiz certainly on the define struct and hopefully you got familiarity with that before we meet on Monday, so we can pick up next week.
	Okay.
	Have a good week, I'll talk with you soon.
	I'll stop the recording.  I'll hang out if people have questions.