ML Lecture 9
Announcements:
- Questions on Lab3, Lab4
More List Topics
- The operator :: lets you build a list out of a value and an existing
list. It simply puts the value into the list as the first element (the
head). This operator is called cons for historical reasons
- The operator @ also builds a list, but out of two lists. It just concatenates
them together, just as they are.
Exam-taking strategies
- My job: to determine how much you know
- Your own goal: to maximize your points
- Your job: to show me how much you know
- Can say too little, or too much
- Usually a bad idea to just do problem 1, then problem 2, etc.
- First, read through the exam quickly -- just check each problem out
- While doing this, look at how many points each is worth
- Next, do the problems that look easy to you first
- Then do the hard (for you) problems
- Very important concept: partial credit
- A partly correct answer will get some points
- If you can't figure out a problem, don't leave it blank. That's the
worst thing you can do (unless you ran out of time)
- Try to solve part of the problem.
Programming examples
- Go over good solutions to assignments in class, for Lab1 and Lab2.
- Do some list processing examples
Carrying values or a result through recursive calls
- Examples of recursion we've seen so far tend to accumulate a result.
For example, we've summed up all the elements in a list, or multiplied
them, etc.
- We've done this by using the recursive call in an expression
- Some problems simply need for you to find a certain value, or determine
where in a list a certain value is
Searching in a list
- Generally, two base cases
- One where the thing you search for is found (i.e. you reach the element
in the list that matches)
- One where it is not found (i.e., you reach the end of the list)