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

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 times. (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.

Multicultural

  • Friday, 9 October 2026, 4:10–5:00 p.m., HSSC N1170 Middle of Everywhere (Somewhere)
  • 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

  • Format: I’m going to talk a lot and also ask a lot of questions.
  • Goal of course: Learn how to design, write and express solutions to computational problems (small ones, in this course).
  • To write solutions, you must be able to write expressions, define functions, and do some related things (such as write definitions).
  • We use a formal/artificial language for writing these expressions and functions. (Scheme)
  • Scheme shares three important characteristics with natural language
    • Syntax - a set of rules for how you write things.
    • Vocabulary - words we use when we write things (need some memorization and/or references)
    • Semantics - Meanings associated with the things we write.
  • You’ll need to follow these to succeed in Scamper.
  • Expressions: Ways to express the computation of values
    • Basic expressions (values): 4, "hello", #\space
    • Compound expressions: Apply a function to some input.
      • Syntax for compound expressions: (function inputs)
    • Note: Although parentheses normally mean “this is the application of a function”, there are a few cases in which they do not mean that.
      • (define NAME VALUE)
      • (lambda (PARAMS) ...)
    • Can we use parentheses to group things, like we do in math? (-5)? No! The open paren signals “this is a function”.
    • Do we ever put functions somewhere other than immediately after an open paren? One is in define. Another is in the list functions, like filter, map, apply. Also l-s, r-s, o. [Wed/Friday]
  • Working with basic values requires some understanding of what kind of value it is (e.g., number, characters), since those guide what we can do with them. We call “kinds of values” “types”. What types do we know?
    • Numbers, including integers, used for calculations
    • Strings, (sequences of characters) used for representing text
    • Characters, used for representing the individual pieces of strings
    • Boolean, true/false values, used for making decisions with if and similar statements
    • RGB values, used for representing colors in the images/drawings we make
    • HSV values, used for representing colors in the images/drawings we make
    • Lists, sequences of values, used when we need to collect values (also to do lots of actions at once)
    • Shapes, used to make pretty (and not-so-pretty) pictures
  • When we learn a new type, we should ask ourselves a set of questions
    • We do we have the type? E.g., strings are used to represent text.
    • How do we write or create values in the type? E.g., for strings …
      • Put quotation marks around some characters (w/o the #), “Hello”.
      • (number->string num) - Create a string that corresponds to a number.
      • (SOMETYPE->string SOMETYPE) - Convert a value in a particular type to a string.
      • (list->string list-of-characters) - Create a string from a list of characters.
      • (make-string length char) - Make a string consisting of that number of copies of the given character.
      • (string char1 char2 char3 ...)
    • How does the computer represent/show values of the type? For strings: quotation marks around the component characters. Certain characters, such as quotation marks, have a backslash before them.
    • What can we do with values in this type?
      • (string-append str1 str2 str3 ...) - join strings together
      • (string-length str) - find out how many characters are in the string
      • (string-split str splitter) - split the string into a list of strings, splitting whenever we see splitter
      • (substring str start end) - extract a portion of the string starting at position start and ending immediately before position end. Note: 0-based.
      • (substring str start) - extract a portion of the string starting at position start and ending at the end of the string.
  • We can also name things with define statements, using the form (define NAME EXPRESSION).
    • (define prof "SamR") - basic value
    • (define grade (/ (+ 90 80 100) 3)) - compound expression/function call
    • Why is this a “statement” not an “expression”?
      • It behaves a bit differently than expressions, which have functions and inputs.
      • The first parameter is not interpreted/evaluated.
      • Expressions have values, define statements do not.
      • Expressions can appear within other expressions, define statements cannot.
      • The define statement changes the “state” of our program; that is, it affects the following expressions/statements.
  • Semantics of define: Evaluate the expression. Until the name is redefined, use the value of the expression in place of the name whenever we see the name.
    • (string-append prof " is so confusing")
  • How do we (or how does Scamper) evaluate simple expressions (w/o l-s and other complexities)?
    • Evaluate all the arguments before applying the function.
    • Usually evaluate arguments from left to right
(define c 3)
(define d 4)

    (+ (* c c) (- d (+ c d)))
--> (+ (* 3 3) (- 4 (+ 3 4)))
--> (+ 9 (- 4 (+ 3 4)))
--> (+ 9 (- 4 7))
--> (+ 9 -3)
--> 6

Remember: There should (almost) always be an operation/function after the open parenthesis.

Remember: You can only have one expression in a define.

(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]"

We often name things to simplify complex expressions. We also do so to build more complex things from simple things.

Moving on to functions.

What is a function?

  • An expression that you can insert values into.
  • Something you can call on.
  • Something that takes inputs, does some computation, and produces an output.

Something we define with a lambda (or other things).

Syntax:

(define NAME
  (lambda (PARAMETERS) ; the inputs (the things we insert)
    EXPRESSION)) ; tells us how to compute a value

Example:

(define scale-grade
  (lambda (grade)
    (+ 2 (* 2 grade))))

Meaning of a function application.

  • (fun arg1 arg2 ...).
  • What is the meaning of this, given that fun is defined with a lambda?
    • Substitute each argument for the corresponding parameter
    • Evaluate using the normal rules
    (scale-grade 32)
--> (+ 2 (* 2 32))
--> (+ 2 64)
--> 66
    (scale-grade (+ 7 5 10 5 20 -6))
--> (scale-grade 41)
--> (+ 2 (* 2 41))
--> (+ 2 82)
--> 84
    (scale-grade (scale-grade 10))
--> (scale-grade (+ 2 (* 2 10)))

Lessons from today

  • Memorize vocabulary! (and types)
  • Parens have particular meanings, usually “apply this function”
  • We use tracing to figure out how Scheme is going to evaluate the expressions and functions we write. Three rules
    • Substitute the values of variables for the variables
    • Evaluate all the inputs (arguments) from left to right
    • To apply a function, substitute arguments for parameters and continue.