EBoard 16: Pause for breath - review of basics and functions (Section 3)

Please follow the standard start-of-class routine.

Warning! You are being recorded (and transcribed) (provided the technology is working correctly).

Approximate overview

  • Administrative stuff
  • Q&A
  • Project or Review

Administrative stuff

Introductory Notes

  • As I indicated in email, I am using this week for review (for some students) and a project (for others). I hope this helps everyone get caught up in the class.
    • There is no shame in needing help or asking questions.
  • Making this change meant that I needed to cut two learning assessments. We will still cover the topics (documentation and program style), but I won’t test you on them.
  • There are no new LA topics this week!
  • LA times this Friday (across all sections). Feel free to take LAs during any of these tims. (You may attempt each of this week’s LAs only once.)
    • 7:30–8:00, 8:50–9:20, 10:20–11:30, 3:30–4:30.

Peer educators

There’s been some confusion on the types of peer educators for CSC-151, their roles and responsibilities, and the names we associate with each.

  • Mentors. The peer educators who help out during classes .
    • Mentor Sessions. The sessions they run twice per week. These sessions are intended to help you better master the material and prepare for LAs.
  • Evening Tutors. The peer educators who hang out in this room or 3815 Sunday through Thursday night. They can help with homework and answer questions about various topics.
    • Evening Tutor Hours. The times they are here.
  • Individual Tutors. Peer educators who meet with individual students or small groups once per week to go over whatever those students need help with. We generally won’t assign individual tutors unless (a) you ask for one, (b) you’ve been attending mentor sessions and turning in work, and (c) you meet with SamR.

Some common notes from MP2

  • Style and following conventions are important.
    • Documentation belongs immediately above the documented functions.
    • Documentation has a standard form.
    • Indent with Ctr-I.
    • Break lines apart sensibly.
  • If you’re going to submit something you know is incomplete, please let the grader know.
    • A note at the top that says “I realize that I don’t have good (any?) answers to these problems” makes their jobs easier.
  • All question marks should be replaced, both in code and documentation.

Upcoming work

Upcoming activities

Scholarly

  • Monday, 5 October 2026, 4:15–5:15 p.m., HSSC 1325. AI and the Future of Democracy Highest Recommendation
  • Tuesday, 6 October 2026, Noon–1:00 p.m., JRC 224C (I think). CS Table: Google Zero
  • Wednesday, 7 October 2026, 4:30–5:30 p.m., GCMoA. Robert Gehorsam: The Transformation of Art and Technology: How They Feed Each Other’s Creativity. New
  • Thursday, 8 October 2026, 11:00 a.m.–noon, JRC 101. Scholars’ Convocation: Alan Schrift: From the Origins of the Grinnell College Center for the Humanities to the Past and Current Crises of the Humanities

In this talk, Robert Gehorsam ’76 will reflect on his own career in media and digital technologies to explore how artists and technologists shape both creativity and technological innovation for each other. Technology is not only something that happens to artists and their processes, it is often created as a result of an artist’s desire to create something new. We’ll look at how digital technologies have shaped existing forms such as film and music, but also explore how the digital world can give rise to entirely new forms such as virtual reality and games.

Bio: Robert Gehorsam ’76 (Religious Studies and English) has had a career that spans book publishing, the computer game industry, educational technology, and policy. He currently co-leads two organizations — a convening entity that explores the intersections of culture, society, networks, and societal well-being, and a new initiative centered on technology and democratic innovation. He is a co-author of The Carbon Almanac, a best-selling book on climate change, and currently teaches a short course at the Wilson Center on Entrepreneurship and Social Change.

Artistic/Cultural

  • Any day. Visit the GCMOA for at least 30 minutes.
  • Musical show thingy on Friday.

Multicultural

  • Friday, 9 October 2026, 4:10–5:00 p.m., HSSC N1170 Middle of Everywhere (Uganda)
  • Saturday, 10 October 2026, 3:00–5:00 p.m., JRC 101. Walking Tacos with SOL

Peer

Musical, theatric, sporting, academic, and similar events involving this section’s students are welcome.

Wellness

  • Monday, 5 October 2026, 8:00–9:00 p.m., Prayer Garage. Meditation Group
  • Tuesday, 6 October 2026, 4:30–6:00 p.m., Bear P103. Wellness Yoga
  • Tuesday, 6 October 2026, 5:00–8:00 p.m., HSSC North Atrium. Therapy Dogs
  • Wednesday, 7 October 2026, 11:00 a.m.–1:00 p.m., JRC 1st Floor Lobby. The return of Mom Hugs
  • Thursday, 8 October 2026, 11:00 a.m.–3:00 p.m., Goodnow 2nd. Visit the Ombuds for Ombuds Day
    • Get swag.
    • Bring a question for better swag.
    • Tell Deborah that I sent you.
  • Monday, 12 October 2026, 8:00–9:00 p.m., Prayer Garage. Meditation Group
  • Wednesday, 14 October 2026, 4:15–5:45 p.m., Undisclosed Location. Forest Bathing

Misc

  • Tuesday, 6 October 2026, 4:15–5:15 p.m., HSSC 1231. Semester at CERA information program
  • Wednesday, 7 October 2026, 8:00–9:00 p.m., Science 3820. Mentor Session
  • Thursday, 8 October 2026, 4:00–5:15 p.m., Noyce 3821.
    CS Major Information Session
    • We should have snacks beforehand.
  • Thursday, 8 October 2026, 8:00–9:00 p.m., Science 3820. Mentor Session

Other good things

These do not earn tokens, but are worth your consideration.

  • Friday, 9 October 2026, 7:00–9:00 p.m., Darby. Volleyball vs. Knox
  • Saturday, 10 October 2026, 1:00–3:00 p.m., Darby. Volleyball vs. Illinois

Questions

Administrative questions

Review

  • Goal of the course: Give you practice in designing and writing computational solutions to problems that are amenable to computational solution. Such solutions will involve writing expressions, functions, and a few related things, such as definitions.
  • We are using an artifical language, Scheme, to write our solutions.
  • Three basics when you learn a language.
    • Syntax.
    • Vocabulary.
    • Semantics. “Noun Verb Noun.”
  • We need to make sure we learn these for Scheme.

Expressions

  • Scheme has two basic kinds of expressions.
    • Basic values, such as 2, "Hello", #\a
    • Compound expressions, usually involving the application of a function to some arguments. (+ 2 3). More generally, we write (fun exp1 exp2 ...).
    • Unfortunately, Scheme is not uniform. There are a few other times we write parentheses in Scheme that do not involve function applications.
      • (lambda (params) ...)
      • (define NAME EXP)
    • The rest of the time, when you write an open parenthesis, Scamper will assume that the next thing is a function.
      • Can you add parentheses around values, such as (-5)? NO!
      • You can’t even add extra parentheses around an expression that computes a basic value. ((+ 2 3)).
    • Can functions appear anywhere other than after an open paren?
      • With o, l-s, r-s - functions that build functions.
      • With map, filter, sort, and the other big-picture list functions. [Wed/Fri]

Types

  • What goes in expressions others than functions? More expressions! Also basic values. We have encountered many kinds of values, we use the term “types” for kinds of values. What types have you seen?
    • Numbers, including integers - Use for math
    • Strings - Use for processing “words” and text
    • Characters - the building blocks of strings
    • Lists - Used to collect groups of values and to process multiple values “simultaneously”
    • RGB colors - Used in creating “interesting” images
    • HSV colors - Used in creating “interesting” images
    • Shapes - Used in creating “interesting” images
    • Booleans - Used in making decisions in our programs
  • When we learn new types, we should try to identify four basic issues
    • Why we have them
    • How Scamper/Scheme represents them to us. E.g., we know that a string is always within double quotation marks (and that certain characters get preceded by a backslash).
    • How to build them. For strings …
      • Typing according to the standard syntax, e.g., "Hello"
      • (make-string n char) - Makes a string by combining n copies of char.
      • (number->string number) - convert a number to a string (also many others, such as rgb->string)
      • (list->string list-of-characters)
      • (string ch1 ch2 ch3 ... chn)
    • Things you can do with the type
      • (substring str start finish) - extract the portion of the string from positions start (inclusive) to finish (exclsive)
      • (append str1 str2 ...) - join strings together
      • (string-split str splitter) - split the string into a list of strings, breaking at every instance of splitter
      • (string-reverse str) - reverse the string
      • (string-length str) - Find out how many characters are in the string.
      • (string-upcase str)
      • …
  • Note: We may have to memorize some vocabulary.

Definitions

  • Definition statements associate names with values.
  • The have the form (define NAME EXPRESSION)
  • They have the meaning “Evaluate the expression. Henceforth, whenever you see the name, you replace it with the value of the expression.”
    • Note: A new definition with the same name will change what value is used
  • Note that I called these “define statements” rather than “define expressions”. That’s because
    • We cannot use them most places we use expressions. In particular, we can’t use them within other define statements.
    • They don’t return any value.

Evaluation

  • Note that we have to evaluate expressions, not just for define statements but for other computation, too.
  • Policies for evaluating expression
    • When you see a name associated with a previous define, replace it with the corresponding value.
    • Evaluate the arguments to a functions before applying the function. (Generallly do those left to right.)
(define a 4)
    (/ (* a 3) (- a 7))
--> (/ (* 4 3) (- 4 7))
--> (/ 12 (- 4 7))
--> (/ 12 -3)
--> -4

Important: Tracing is just following the rules for evaluating expressions.

(define x "Hello")
    (string-append "[" (string-upcase x) (make-string 3 #\.) (substring x 1) "]")
--> (string-append "[" (string-upcase "Hello") (make-string 3 #\.) (substring "Hello" 1) "]")
--> (string-append "[" "HELLO" (make-string 3 #\.) (substring "Hello" 1) "]")
--> (string-append "[" "HELLO" "..." (substring "Hello" 1) "]")
--> (string-append "[" "HELLO" "..." "ello" "]")
--> "[HELLO...ello]"

Functions: What are they?

  • A function is something used to process data.
  • A function takes a set of inputs (parameters), computes with them, and produces an output.
  • We define them in Scheme as follows
(define NAME
  (lambda (PARAMS)
    EXPRESSION))
(define scale-grade
  (lambda (grade)
    (+ 3 (* 2 grade))))

Do we have a model for how we evaluate function calls? For example, how do we know what (scale-grade 40) is? We substitute the argument(s) in for the parameters, and then evaluate the body in the normal way.

    (scale-grade 40)
--> (+ 3 (* 2 40))
--> (+ 3 80)
--> 83

(scale-grade (+ 10 8 7 6 -3)) --> (scale-grade 28) --> (+ 3 (* 2 28)) --> (+ 3 56) --> 59 ```

Lessons from today:

  • Where you place parens is important. Scheme assumes it will see a function immediately after an open paren (with a few exceptions).
  • It’s hard to solve problems unless you know the vocabulary well.
  • We trace the evaluatioin of expressions because it matches the way Scamper normally evaluates them, so we can answers and better understand what is happening.
    • Substitute in variables.
    • Evaluate arguments before applying functions.
    • Apply functions by substituting (evaluated) arguments for parameters.

Detour: Can we use two lambdas in one define? Yes, but it’s complicated. (lambda (params) exp) IS an expression.