This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
cs330_f2016:racketbasics [2016/08/10 16:04] morse [Notes:] |
cs330_f2016:racketbasics [2021/06/30 23:42] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
====Objective:==== | ====Objective:==== | ||
Line 8: | Line 9: | ||
Download the latest version of DrRacket from [[http://racket-lang.org]] and install it on your computer. Versions are available for Windows, Mac OS X, and Linux. | Download the latest version of DrRacket from [[http://racket-lang.org]] and install it on your computer. Versions are available for Windows, Mac OS X, and Linux. | ||
+ | |||
+ | Please also take a look at [[cs330_f2016:turnin|how to turn in your assignments]]. | ||
---- | ---- | ||
+ | |||
====Deliverables:==== | ====Deliverables:==== | ||
For this lab, you will need to implement the following functions and data structures in Racket: | For this lab, you will need to implement the following functions and data structures in Racket: | ||
+ | * ''sum-coins'' | ||
+ | * ''degrees-to-radians'' | ||
+ | * ''sign'' | ||
+ | * ''new-sin'' | ||
=== sum-coins === | === sum-coins === | ||
Line 18: | Line 26: | ||
(define (sum-coins pennies nickels dimes quarters) ...) | (define (sum-coins pennies nickels dimes quarters) ...) | ||
</code> | </code> | ||
- | where ''pennies'', ''nickels'', ''dimes'', and ''quarters'' are all non-negative numbers and the value returned is the total value of the coins. | + | where ''pennies'', ''nickels'', ''dimes'', and ''quarters'' are all non-negative numbers and the value returned is the total value of the coins in cents. |
=== degrees-to-radians === | === degrees-to-radians === | ||
Line 38: | Line 46: | ||
where ''angle'' is a number representing either degrees or radians, type is either '''degrees'' or '''radians'' (a symbol) indicating how ''angle'' is represented, and the value returned is the sin of ''angle''. | where ''angle'' is a number representing either degrees or radians, type is either '''degrees'' or '''radians'' (a symbol) indicating how ''angle'' is represented, and the value returned is the sin of ''angle''. | ||
- | ---- | + | Hint: use ''symbol=?'' to test for symbol equality: ''(symbol=? x 'degrees)''. |
+ | ---- | ||
====Notes:==== | ====Notes:==== | ||
You **do not** need to bulletproof the code to enforce proper inputs. | You **do not** need to bulletproof the code to enforce proper inputs. | ||
Your code only needs to return correct values given correct inputs. | Your code only needs to return correct values given correct inputs. | ||
+ | |||
+ | ---- | ||
====Hints:==== | ====Hints:==== | ||
- | Try using the | + | Try clicking on the Step button to walk through your code and watch the equivalent sequence of substitutions that are performed. |
+ | |||