---
title: Eboard 04  Writing your own procedures
number: 4
section: eboards
held: 2019-02-01
link: true
---
CSC 151 2019S, Class 04:  Writing your own procedures
=====================================================

_Overview_

* Preliminaries
    * Notes and news
    * Upcoming work
    * Extra credit
    * Friday PSA
    * Questions
* Quiz
* Lab Prep
* Lab

Preliminaries
-------------

### News / Etc.

* Happy Friday!  I'm glad that you all got through the weather okay.
* Snarky comment from my child: "How I know my father is a geek: He
  went to Atlanta the week of the Super Bowl and spent the whole time
  inside a hotel at a CS conference."
    * But it was an awesome conference.  I talked to or heard from
      policy wonks, lawyers, economists, gov't folks, philosophers,
      advocates, and more (plus computer scientists).
* Apologies for the delay in grading HW1.
* Mentor sessions: Wednesday 8-9, Thursday 8-9, Sunday 5-6.  CS Commons.

### Upcoming work

* Readings (available online), due before class Monday.
    - [Data types](../readings/data-types)
    - [Numeric values](../readings/numbers)
    - [Characters and strings](../readings/strings)
    - [Symbolic values](../readings/symbols)
    - [List basics](../readings/list-basics)
    - [Text and text files](../readings/text-files)
* [Assignment 3](../assignments/assignment03) due Tuesday night.
    * Your partner is whoever was identified in the email.
* Lab writeup due before class Monday: Exercise 2d.  `snowman-with-hat`

### Extra Credit

#### Extra credit (Academic/Artistic)

* Curator's Talk for _Dread and Delight_.
  Friday, 1 February 2019, 4pm.
* Opening Reception for _Dread and Delight_.
  Friday, 1 February 2019, 4:15pm. 
* Neo Futurists, Flanagan Theatre.
  Friday, 1 February 2019, 7:30 pm, 
* Met Opera Live in HD, Harris Cinema.
  Saturday, 2 February 2019.  Get extra credit for getting a nap.
* _Once Upon a Time Wolf_ (tickets required), Bucksbaum.
  Friday, 8 February, 7pm.
* _Once Upon a Time Wolf_ (tickets required), Bucksbaum.
  Saturday, 9 February, 7pm

#### Extra credit (Peer)

* Swim and Dive, Osgood Natatorium.
  Saturday, 2 February 2019, 2pm
* Men's BBall, NewDarby.
  Saturday, 2 February 2019, 3pm.

#### Extra credit (Wellness)

* HIIT training, 10am Saturday, Dance Studio, Bear.  (Around from the
  Nat, second floor.)  (If five minutes is all you can survive, that's
  fine.)

#### Extra credit (Misc)

### Other good things

* Men's Tennis, Sat, 9am, Fieldhouse.
* Men's Tennis, Sat, 2pm, Fieldhouse.
* Happy Birthday dear (anonymous student)

### Friday PSA

* Be good to yourselves, be good to others.

### Questions

What happens when I can't take a quiz on the normal day?

> If you know in advance, we negotiate another day (typically Thursday or
  Monday).

> If you don't know in advance, you take it the next day that you are in
  class.

Can I have an individual tutor?

> Probably.  Make sure that you use the mentor sessions.  You'll also need
  to have a quick chat with me and with Sarah Dahlby Albright, our Peer
  Education coordinator.

How do I tell the value of what I've defined in the definitions?

> Type the name

> Type things that extract values (e.g., `(image-width rect)`)

Composition didn't work in the bottom panel?

> You need to require the `loudhum` library.

I can't require loudhum on my computer.

> Yup.  The magic incantations `/home/rebelsky/bin/csc151/setup`
  installed it in MathLAN.  I will provide more complicated instructions
  for other computers.

What about the images library?

> That's part of standard Racket, so it's always available (as long as
  you require it).

How do you make a variable out of a user input?

> We're not using that model right now.

What might we write on flash cards?

> Front: What is the format of a "standard" procedure in Racket?
  Back: `(define proc (lambda (params) body))`.

> Front: What is `(string-append "apple" "banana")`?
  Back: "applebanana", with no space.

> Front: What are the seven basic parts of an algorithm?
  Back: Built-in values (and operations).  Conditionals.  Sequencing.
  Variables (also identifiers), Repetition. Subroutines.  Input/output.

> Front: What do we use variables for?
  To name values, leading to clarity in our program.

What is the most important thing we've learned this far?

> You are wonderful people.  Please take care of yourselves.

> Seven parts of an algorithm.

> Getting the syntax right takes time.

> Scheme expressions have the form `(procedure-name parameter parameter)`, 
  as in `(+ 2 3)`.  The operation/procedure comes first.  The paren
  almost always signals that the next is a procedure.  `(2 + 3)` will
  yield "2 is not a procedure".  The exception  is when we have an
  apostrophe (tick), before the open paren, in which case we're just
  defining (or reading) a list.

> Scheme expressions are (usually) evaluated inside-out.

Can we draw a curve or line?

> Yes, <https://docs.racket-lang.org/teachpack/2htdpimage.html>

Which comes first, width or height?

> width is like x, so it comes first.

Will we always spend so much time on Q&A at the beginning of class?

> Probably not.  But it's early enough in the semester that it's
  worthwhile.

Quiz
----

Ten minutes.

Reminder: A chance for you and me to see what is and is not making sense.

If you finish early, check your answers or sit and meditate quietly.
(After all, we have so little time for quiet reflection in life.)

You may also leave to use the restroom or fill up your water bottle
or something similar.

Lab prep / Self checks
----------------------

How did you write `subtract3` using `lambda`?

        (define subtract3
           (lambda (n)
             (- n 3)))

How did you write `subtract3` using `o`?

* Assume `sub1` is defined.

        (define subtract3 (o sub1 sub1 sub1))


How did you write `subtract3` using `section`?

        (define subtract3 (section - <> 3))

Which do you prefer?

* The first one, it's more intuitive and looks more familiar (Students)
* The third, it's short and it's how I approach the world: Take an
  existing procedure that does something I want, and specialize it.
  (Instructor)

Lab
---

Writeup: 2d.  Send to csc151-01-grader.  Subject: "CSC151.01 Writeup for class 4 (Your Names)"

Debrief (if time)
-----------------

Apologies for a too-long lab (or a too-long Q&A session).

Some issues with naming ...

        (define color-square
          (lambda (color)
            (square 10 'solid color))) -> Use whatever value given to color-square

        (color-square "blue") -> Use "blue" verbatim, which DrRacket knows 
        (color-square 'blue) -> Use 'blue verbatim, which DrRacket knows
        (color-square blue) -> Look for the value of the variable blue


