From kristina at MIT.EDU Mon May 17 11:04:46 2004 From: kristina at MIT.EDU (Kristina Lundqvist) Date: Mon, 17 May 2004 11:04:46 -0400 Subject: [Unified-mailman] Re: Quiz CP 1 Solutions In-Reply-To: <1084728728.40a7a5987dd40@webmail.mit.edu> Message-ID: <5.2.1.1.2.20040517110325.034fdf98@po14.mit.edu> Hi Synthia and Unified: The solutions to the first quiz can now be found at http://web.mit.edu/16.unified/www/SPRING/Computers/Documents/Quiz.1.solution.pdf Enjoy! ..IKL At 13:32 2004-05-16 -0400, you wrote: >Hi Professor Lundqvist, > >Can you post the solutions to the first computers quiz on the Unified webpage? > >It would be much appreciated. > >Thanks, >Synthia Tonn From howiek at MIT.EDU Mon May 17 15:05:24 2004 From: howiek at MIT.EDU (Howard Kleinwaks) Date: Mon, 17 May 2004 15:05:24 -0400 Subject: [Unified-mailman] propulsion tests and grade reports are available Message-ID: In the ta office. If we're not inside, check the whiffle ball field... -Howie From howiek at MIT.EDU Mon May 17 16:28:20 2004 From: howiek at MIT.EDU (Howard Kleinwaks) Date: Mon, 17 May 2004 16:28:20 -0400 Subject: [Unified-mailman] finals info Message-ID: Students, Here's some helpful info for the final: Its on Wednesday, 5/19 at 9am in WALKER. Computers is first, Signals is second. Professor Lundqvist will provide the cheat sheet for the computers exam. You are allowed one double-sided sheet of paper for the signals exam. Good luck, -Howie From kristina at MIT.EDU Mon May 17 17:03:56 2004 From: kristina at MIT.EDU (Kristina Lundqvist) Date: Mon, 17 May 2004 17:03:56 -0400 Subject: [Unified-mailman] CP code for recitation 5 Message-ID: <5.2.1.1.2.20040517170222.036405a8@po14.mit.edu> Attached is the code used in Recitation 5. /Kristina Lundqvist --- I. Kristina Lundqvist, Ph.D. Charles S. Draper Assistant Professor of Aeronautics and Astronautics Massachusetts Institute of Technology 77 Massachusetts Avenue, 33-406 Cambridge, MA 02139 phone: +1 617-452-2550 fax: +1 617-253-7397 kristina at mit.edu http://www.mit.edu/~kristina http://esl.mit.edu/index.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.mit.edu/pipermail/unified-mailman/attachments/20040517/92c788fc/attachment.htm -------------- next part -------------- -- Recitation 5 -- demo_infix_evaluation.adb -- demonstrate generic integer stack -- instantiation and usage with Ada.Text_Io; with Ada.Integer_Text_Io; with Ada.Strings; use Ada.Integer_Text_Io; use Ada.Text_Io; use Ada.Strings; with Stack; -- assume a FULLY paranthesised expression procedure demo_infix_evaluation is package Stack_is new Stack( Size => 10, Item => Integer); package Stack_Character is new Stack( Size => 10, Item => Character); My_Expression : String(1..20); My_Expression_Length : integer; Op1, Op2 : Integer; Operand : Character; function Is_Operand(Op : Character) return Boolean is begin if Op in '1'..'9' then return True; else return False; end if; end Is_Operand; function Is_Operator (Op : Character) return Boolean is begin if Op = '+' or Op = '-' or Op = '*' or Op = '/' then return True; else return False; end if; end Is_Operator; begin Ada.Text_Io.Put("Please enter an expression: "); Ada.Text_Io.Get_Line(My_Expression, My_Expression_Length); for I in 1 .. My_Expression_Length loop if Is_Operand(My_Expression(I)) then Stack_Integer.Push(Character'Pos(My_Expression(I))-Character'Pos('0')); end if; if Is_Operator(My_Expression(I)) then Stack_Character.Push(My_Expression(I)); end if; if My_Expression(I) = ')' then Stack_Integer.Pop(Op2); Stack_Integer.Pop(Op1); Stack_Character.Pop(Operand); case Operand is when '+'=> Stack_Integer.Push(Op1+Op2); when '-'=> Stack_Integer.Push(Op1-Op2); when '*'=> Stack_Integer.Push(Op1*Op2); when '/'=> Stack_Integer.Push(Op1/Op2); when others => null; end case; end if; end loop; Ada.Text_Io.Put("The result is :"); Stack_Integer.Pop(op1); Ada.Text_Io.Put_Line(Integer'Image(op1)); end demo_infix_evaluation; -------------- next part -------------- -- Recitation 5 -- exception_example_one.adb with Ada.Text_Io; use Ada.Text_Io; with Ada.Float_Text_Io; use Ada.Float_Text_Io; package body Exeception_Example_One is package Week_Day_Io is new Enumeration_Io (Week_Days); use Week_Day_Io; procedure Safe_Get_Day ( Out_Day : out Week_Days; Min : in Week_Days := Work_Days'First; Max : in Week_Days := Work_Days'Last ) is -- procedure for the safe input of enumeration values Local_Day : Week_Days; -- local input var Good_Day : Boolean := False; -- loop control begin -- safe_get_day while not Good_Day loop begin -- while block Put("Enter an day between "); Put( Min ); Put(" and "); Put( Max ); Put(" "); Get( Local_Day ); -- this point is reached only when input is a day code if (Local_Day < Min) or (Local_Day > Max) then raise Data_Error; else Good_Day := True; end if; -- this point is reached if input is a valid day code -- between min and max exception when Data_Error => Put_Line("Invalid day!. Good days are "); for This_Day in Week_Days range Min .. Max loop Put( This_Day ); Put(" "); end loop; New_Line; Skip_Line; -- tidy up terminal end; -- protected while block end loop; -- this point can only be reached when valid value input Skip_Line; -- tidy up terminal handling Out_Day := Local_Day; -- export input value end Safe_Get_Day; procedure Safe_Get_Float( Out_Float : out Float; Min, Max : in Float ) is Local_Float : Float; -- local input var Good_One : Boolean := False; -- loop control begin -- Safe_Get_Float while not Good_One loop begin -- protected block of code Put("Enter a float in range "); Put( Min, Exp => 0 ); Put( " to "); Put( Max, Exp => 0 ); Put( " "); Get( Local_Float ); -- this point can only be reached if the get -- did not raise the exception -- now tested against limits specified Good_One:=((Local_Float>=Min) and (Local_Float<=Max)); if not Good_One then raise My_Error; -- Loal_Float < Min OR Local_Float > Max end if; exception when Data_Error => Put_Line("DATA ERROR. Invalid input, pls try again "); new_line; Skip_Line; when My_Error => Put_Line("MY ERROR. Invalid input, pls try again"); new_line; Skip_Line; end; -- protected block of code end loop; -- this point can only be reached when valid value input Skip_Line; -- tidy up terminal handling Out_Float := Local_Float; -- export input value end Safe_Get_Float; end Exeception_Example_One; -------------- next part -------------- -- Recitation 5 -- exception_example_two.adb with Ada.Text_Io; use Ada.Text_Io; with Ada.Float_Text_Io; use Ada.Float_Text_Io; package body Exeception_Example_Two is package Week_Day_Io is new Enumeration_Io (Week_Days); use Week_Day_Io; procedure Safe_Get_Day ( Out_Day : out Week_Days; Min : in Week_Days := Work_Days'First; Max : in Week_Days := Work_Days'Last ) is -- procedure for the safe input of enumeration values Local_Day : Week_Days; -- local input var Good_Day : Boolean := False; -- loop control begin -- safe_get_day while not Good_Day loop begin -- while block Put("Enter an day between "); Put( Min ); Put(" and "); Put( Max ); Put(" "); Get( Local_Day ); -- this point is reached only when input is a day code if (Local_Day < Min) or (Local_Day > Max) then raise Data_Error; else Good_Day := True; end if; -- this point is reached if input is a valid day code -- between min and max exception when Data_Error => Put_Line("Invalid day!. Good days are "); for This_Day in Week_Days range Min .. Max loop Put( This_Day ); Put(" "); end loop; New_Line; Skip_Line; -- tidy up terminal end; -- protected while block end loop; -- this point can only be reached when valid value input Skip_Line; -- tidy up terminal handling Out_Day := Local_Day; -- export input value end Safe_Get_Day; procedure Safe_Get_Float( Out_Float : out Float; Min, Max : in Float ) is Local_Float : Float; -- local input var Good_One : Boolean := False; -- loop control begin -- Safe_Get_Float while not Good_One loop begin -- protected block of code Put("Enter a float in range "); Put( Min, Exp => 0 ); Put( " to "); Put( Max, Exp => 0 ); Put( " "); Get( Local_Float ); -- this point can only be reached if the get -- did not raise the exception -- now tested against limits specified Good_One:=((Local_Float>=Min) and (Local_Float<=Max)); if not Good_One then raise My_Error; -- Loal_Float < Min OR Local_Float > Max end if; exception when Data_Error => Put_Line("DATA ERROR. Invalid input, pls try again "); new_line; Skip_Line; when My_Error => Put_Line("MY ERROR."); new_line; Skip_Line; raise My_Error; -- re-raise the exception! end; -- protected block of code end loop; -- this point can only be reached when valid value input Skip_Line; -- tidy up terminal handling Out_Float := Local_Float; -- export input value end Safe_Get_Float; end Exeception_Example_Two; -------------- next part -------------- -- Recitation 5 -- stack.adb -- package body for stack implementation package body Stack is type Table is array (Positive range <>) of Item; Space : Table (1 .. Size); Index : Natural := 0; procedure Push (E : in Item ) is begin if Index >= Size then raise Overflow; end if; Index := Index + 1; Space(Index) := E; end Push; procedure Pop (E : out Item ) is begin if Index = 0 then raise Underflow; end if; E := Space(Index); Index := Index - 1; end Pop; end Stack; -------------- next part -------------- -- Recitation 5 -- test_example_one.adb with Exeception_Example_One, Ada.Text_Io; use Exeception_Example_One, Ada.Text_Io; procedure Test_Example_One is My_Day : Exeception_Example_One.Week_Days; My_Num : Float; begin Safe_Get_Day (My_Day); New_Line(3); Safe_Get_Float(My_Num, 1.0, 19.2); end Test_Example_One; -------------- next part -------------- -- Recitation 5 -- test_example_two.adb, tests exception_example_two.ad[bs] with Ada.Text_Io; with Exeception_Example_Two; use Exeception_Example_Two; procedure Test_Example_Two is My_Day : Exeception_Example_Two.Week_Days; My_Num : Float; begin Safe_Get_Day (My_Day); Ada.Text_Io.New_Line(2); Safe_Get_Float(My_Num, 1.0, 19.2); Ada.Text_Io.New_Line(2); Ada.Text_Io.Put("Will this line be printed if My_Error takes place?"); --exception --when My_Error => --Ada.Text_Io.Put_Line("MY ERROR. Now Handled in Calling Program!"); end Test_Example_Two; -------------- next part -------------- -- Recitation 5 -- exception_example_one.ads --------------------------------------------- -- package specification to demo exceptions ------------------------------------------------- with Ada.Exceptions; use Ada.Exceptions; package Exeception_Example_One is My_Error : Exception; type Week_Days is (Sat, Mon, Tue, Wed, Thu, Fri, Sun); subtype Work_Days is Week_Days range Mon .. Fri; subtype Weekend_Days is Week_Days range Sat .. Sun; procedure Safe_Get_Day ( Out_Day : out Week_Days; Min : in Week_Days := Work_Days'First; Max : in Week_Days := Work_Days'Last ); procedure Safe_Get_Float( Out_Float : out Float; Min, Max : in Float ); end Exeception_Example_One; -------------- next part -------------- -- Recitation 5 -- exception_example_two.ads --------------------------------------------- -- package specification to demo exceptions ------------------------------------------------- with Ada.Exceptions; use Ada.Exceptions; package Exeception_Example_Two is My_Error : Exception; type Week_Days is (Sat, Mon, Tue, Wed, Thu, Fri, Sun); subtype Work_Days is Week_Days range Mon .. Fri; subtype Weekend_Days is Week_Days range Sat .. Sun; procedure Safe_Get_Day ( Out_Day : out Week_Days; Min : in Week_Days := Work_Days'First; Max : in Week_Days := Work_Days'Last ); procedure Safe_Get_Float( Out_Float : out Float; Min, Max : in Float ); end Exeception_Example_Two; -------------- next part -------------- -- Recitation 5 -- stack.ads generic Size : Positive; type Item is private; package Stack is procedure Push (E : in Item ); procedure Pop (E : out Item ); Overflow, Underflow : exception; end Stack; From kristina at MIT.EDU Mon May 17 17:51:49 2004 From: kristina at MIT.EDU (Kristina Lundqvist) Date: Mon, 17 May 2004 17:51:49 -0400 Subject: [Unified-mailman] CP Lecture 21 - code examples Message-ID: <5.2.1.1.2.20040517175043.035eeb28@po14.mit.edu> Attached is code used in CP lecture 21. ..IKL -------------- next part -------------- A non-text attachment was scrubbed... Name: generic_sort.zip Type: application/zip Size: 4042 bytes Desc: not available Url : http://mailman.mit.edu/pipermail/unified-mailman/attachments/20040517/7aa84178/attachment.zip From kristina at MIT.EDU Mon May 17 18:40:09 2004 From: kristina at MIT.EDU (Kristina Lundqvist) Date: Mon, 17 May 2004 18:40:09 -0400 Subject: [Unified-mailman] CP : PSET 13 -- Solutions Message-ID: <5.2.1.1.2.20040517183857.03566618@po14.mit.edu> --- I. Kristina Lundqvist, Ph.D. Charles S. Draper Assistant Professor of Aeronautics and Astronautics Massachusetts Institute of Technology 77 Massachusetts Avenue, 33-406 Cambridge, MA 02139 phone: +1 617-452-2550 fax: +1 617-253-7397 kristina at mit.edu http://www.mit.edu/~kristina http://esl.mit.edu/index.html -------------- next part -------------- A non-text attachment was scrubbed... Name: Home Work 13 solutions.doc Type: application/msword Size: 64512 bytes Desc: not available Url : http://mailman.mit.edu/pipermail/unified-mailman/attachments/20040517/d3d1d835/attachment.doc From kristina at MIT.EDU Mon May 17 19:57:06 2004 From: kristina at MIT.EDU (Kristina Lundqvist) Date: Mon, 17 May 2004 19:57:06 -0400 Subject: [Unified-mailman] CP: short Inductive proof handout Message-ID: <5.2.1.1.2.20040517195519.0358fff0@po14.mit.edu> --- I. Kristina Lundqvist, Ph.D. Charles S. Draper Assistant Professor of Aeronautics and Astronautics Massachusetts Institute of Technology 77 Massachusetts Avenue, 33-406 Cambridge, MA 02139 phone: +1 617-452-2550 fax: +1 617-253-7397 kristina at mit.edu http://www.mit.edu/~kristina http://esl.mit.edu/index.html -------------- next part -------------- A non-text attachment was scrubbed... Name: inductive proof examples.doc Type: application/msword Size: 23040 bytes Desc: not available Url : http://mailman.mit.edu/pipermail/unified-mailman/attachments/20040517/72f3cfd1/attachment.doc From kristina at MIT.EDU Tue May 18 19:42:36 2004 From: kristina at MIT.EDU (Kristina Lundqvist) Date: Tue, 18 May 2004 19:42:36 -0400 Subject: [Unified-mailman] CP: crib sheet for final quiz Message-ID: <5.2.1.1.2.20040518193850.03566f80@po14.mit.edu> Dear students, Please find attached the crib sheet for tomorrow's CP exam. Once again, best of luck Kristina Lundqvist --- I. Kristina Lundqvist, Ph.D. Charles S. Draper Assistant Professor of Aeronautics and Astronautics Massachusetts Institute of Technology 77 Massachusetts Avenue, 33-406 Cambridge, MA 02139 phone: +1 617-452-2550 fax: +1 617-253-7397 kristina at mit.edu http://www.mit.edu/~kristina http://esl.mit.edu/index.html -------------- next part -------------- A non-text attachment was scrubbed... Name: final quiz.crib sheet.doc Type: application/msword Size: 68608 bytes Desc: not available Url : http://mailman.mit.edu/pipermail/unified-mailman/attachments/20040518/60db0743/attachment.doc From chipd at MIT.EDU Wed May 19 07:43:24 2004 From: chipd at MIT.EDU (Carl C Dietrich) Date: Wed, 19 May 2004 07:43:24 -0400 Subject: [Unified-mailman] Final Unified Quizzes in WALKER at 9am Message-ID: <1084967004.40ab485cbc480@webmail.mit.edu> See you there. & Good luck! -Carl From chipd at MIT.EDU Wed May 19 08:34:12 2004 From: chipd at MIT.EDU (chipd) Date: Wed, 19 May 2004 08:34:12 -0400 Subject: [Unified-mailman] RE: Final Unified Quizzes in WALKER at 9am In-Reply-To: <005b01c43d97$0a1c0120$b500a8c0@CX623899C> References: <1084967004.40ab485cbc480@webmail.mit.edu> Message-ID: <5.2.1.1.2.20040519083300.014a4aa0@po10.mit.edu> some students thought it would be lots of fun for me to come up with another pun but try as I might, to be creative and bright I couldn't come up with another one See you there. -Carl At 07:47 AM 5/19/2004 -0400, you wrote: >What? No rhyme? No limerick? No joke? Carl, we're heartbroken! It's >the final! > >Maybe Howie will come up with something... > >Though looking at the time, I can understand how the creative juices >aren't flowing quite yet... > >:) > >-----Original Message----- >From: Carl C Dietrich [mailto:chipd at MIT.EDU] >Sent: Wednesday, May 19, 2004 7:43 AM >To: unified at mit.edu >Subject: Final Unified Quizzes in WALKER at 9am > > > >See you there. >& >Good luck! > >-Carl From kristina at MIT.EDU Thu May 20 09:57:16 2004 From: kristina at MIT.EDU (Kristina Lundqvist) Date: Thu, 20 May 2004 09:57:16 -0400 Subject: [Unified-mailman] CP quiz - solutions Message-ID: <5.2.1.1.2.20040520095441.01a1cb38@po14.mit.edu> Students: The solution to the CP quiz can now be found at: http://web.mit.edu/16.unified/www/SPRING/Computers/Documents/Quiz.2.solution.pdf Enjoy the beautiful weather and the summer ..Kristina Lundqvist --- I. Kristina Lundqvist, Ph.D. Charles S. Draper Assistant Professor of Aeronautics and Astronautics Massachusetts Institute of Technology 77 Massachusetts Avenue, 33-406 Cambridge, MA 02139 phone: +1 617-452-2550 fax: +1 617-253-7397 kristina at mit.edu http://www.mit.edu/~kristina http://esl.mit.edu/index.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.mit.edu/pipermail/unified-mailman/attachments/20040520/cd143c7c/attachment.htm