09-27-2013 HW p

posted Sep 27, 2013, 5:38 AM by Samuel Konstantinovich   [ updated Oct 3, 2013, 5:17 AM ]
Goal: If statements practice.

Do Now:
1. How do we check if a number is even in scheme?

2. Write out an if/then/else command in English. 
e.g. "If ??? then ??? otherwise ???"

3. Can you replace one of the two actions you just wrote with another if? Make a valid sentence.

1. Write a function (makeEven x) , assume x is an integer.
When x is even it evaluates to x
When x is odd, it evaluates to x+1

2. Write a function (checkSign x) , assume x is a real number.
When x is positive return 'positive   (notice the ' , this makes it a word not a variable and is totally fine)
When x is negative return 'negative
When x is neutral return 'neutral
Note- returning a value: means the function evaluates to that value

3. Write a function (generateOp x ) 
When the parameter is 0: return +  ( it says <procedure:+> )
When the parameter is 1: return - 
Otherwise return *.

Homework: Complete the 3 problems and rewrite in lambda notation. Bring in a printed copy Monday.