Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Languages

Similar presentations


Presentation on theme: "Programming Languages"— Presentation transcript:

1 Programming Languages
Meeting 11 November 15/16, 2016

2 Short Exam 2

3 Planning Ahead November 22/23: No formal class meetings. Project 2, Part 1 due by 9:00 pm, November 22. November 29/30: Regular class meeting December 6/7: Regular class meeting. Project 2, Part 2 due by class time. December 14/15: Final Exam

4 Project 2: A Vector-Matrix System
Step 1: Affirm your team members by Thursday, November 17.

5 Project 2 (2) Step 2: Submit your LISP implementation of nine primitives and six functionals defined in lecture and to be used as the building blocks of the project Attach two text files to an message to me, the first named primitive.lsp and the second named functional.lsp Due by 9:00 pm, Tuesday, November 22 I will load these files and test them. Remember that the function definitions must use functional principles: no assignment statements, no loops, only cond for the if-then-else structure

6 Project 2 (3) Step 3: Develop and test the LISP code for the vector and matrix functions as specified in the project handout. Step 4: Submit your LISP code in a file named matrix.lsp which you attach to an message. The project description lists the other files you need to submit. Due December 6 or 7, 2016 I will load your file and my primitives and functionals and test your functions against a variety of inputs.

7 Programming in LISP Our approach; our rules No loops
No assignment statements No built-in LISP functions other than those used to define the primitives and functionals, and those are used only in those definitions. Hints: Think recursively Think in parallel Think with composition

8 Defining Functionals Constant Construction Apply-to-all Apply-to-all1
Reduce

9 Your Turn Example 1: The function IG, which generates a list of the first n positive integers Example 2: A LISP function that computes the sum of the squares of the first n positive integers Example 3: A LISP function that computes the sum of the squares of the first n positive odd integers

10 Your Turn (2) Example 4: A LISP function that returns the second element of a list, if it exists Example 5: LISP code to implement the function rotate, which rotates a list k positions. For example, (rotate 2 ‘(A B C D)) returns (C D A B)

11 Your Turn (3) Example 6: LISP code for the function member? which returns true if x is one of the top level elements of the list y and false otherwise.

12 An Experiment One way of implementing infinite precision integer arithmetic is to represent an integer as a list of digits. For example is ( ). Develop a set of LISP functions that performs integer addition when integers are represented this way. Add a set of LISP functions that performs integer multiplication.


Download ppt "Programming Languages"

Similar presentations


Ads by Google