Functional Problem Solving (CSC 151 2014S) : EBoards

CSC151.02 2014S: Extra Session 1


Admin

Questions

How would you suggest that I do the lab writeup more concisely?

(define sum-of-grades (+ grade1 grade2 grade3 grade4 grade5))
(define average-grade (/ sum-of-grades 5))
(define min-grade (min grade1 grade2 grade3 grade4 grade5))
(define max-grade (max grade1 grade2 grade3 grade4 grade5))
(define weighted-average (/ (- sum-of-grades min-grade max-grade) 3))

Can you clarify the difference between a parameter and a variable*?

A parameter names an input to our program or subroutine. A variable names a value computed or built along the way. In the code above, we could think about grade1, grade2, etc as the inputs to the grade calculation, and sum-of-grades, min-grade, and max-grade as variables we compute along the way.


Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-2014 Janet Davis, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials are copyright by John David Stone or Henry Walker and are used with permission.)

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.