EBoard 17: List composition and decomposition

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

Approximate overview

  • Administrative stuff [10 min]
  • About grade reports [10 min]
  • Questions [15 min]
  • Lab [40 min or so]
  • Turn in lab [5 min]

Administrative stuff

  • Happy almost February 29th!

Academic/Scholarly

  • Thursday, 2024-02-29, 11:00-noon, JRC 101. Scholars’ Convocation: Peter Michael Osera Grinnell Talk
  • Thursday, 2024-02-29, 7:00pm, Science 3819. Mentor Session: SoLA review.
  • Tuesday, 2024-03-05, noon, Some PDR. CS Table.

Cultural

  • Monday, 2024-03-04, Sebring Lewis. Des Moines Metropolitan Opera: Beauty and the Beast
  • Thursday, 2024-03-07, JRC 101, 8:00-9:30 pm. Writers@Grinnell: Carl Phillips
  • Thursday–Saturday, 2024-03-07 to 2024-03-09, 7:30 p.m. Songs of the Scarlet and Wayback (play).
  • Saturday, 2024-03-09, Harris Cinema, ??:?? Met Opera: Verdi’s La Forza del Destino.

Peer

  • Friday, 2024-03-01, 7pm in JRC 101. Spa Night.
  • Saturday, 2024-03-02, 2pm, in Sebring Lewis. Orchestra, Bartok. Vegetables. More!
  • Sunday, 2024-03-03, 1–3pm, in JRC 225. Fiber Arts Club.

Wellness

  • Tuesday, 2024-03-05, noon-1pm, BRAC P103. HIIT and Strength Fitness Class.
  • Tuesday, 2024-03-05, 12:15–12:50, Bucksbaum 131. Yoga in the Museum.
  • Tuesday, 2024-03-05, 4pm, BRAC P103 (Multipurpose Dance Studio): Yoga.

Misc

Other good things (no tokens)

Upcoming work

Reading Grade Reports

CSC151-01 2024Sp Grade report for Leumas Yksleber (yksleber)
============================================================

Grades as of 2024-02-28

This is an experimental grade report.  Grades are not yet intended
to be completely accurate; nonetheless, the report should give you
a general sense as to where you stand in the course.  Feel free to
send me comments, corrections, and questions.

Notation:
  [ ]: Not completed to an acceptable level
  [.]: Not completed to an acceptable level
  [I]: Not completed to an acceptable level
  [X]: Completed satisfactorily
  [x]: Completed satisfactorily
  [S]: Completed satisfactorily
  [/]: 1/2 credit (on labs writeups)
  [E]: Excellent (on Mini-Projects)
  [M]: Meets expectations (on Mini-Projects)
  [R]: Recommended redo (on Mini-Projects)

Readings (10 of 13)
-------------------

[X] Readings for Class 02: Getting Started
[X] Readings for Class 03: Composing and decomposing images
[X] Readings for Class 04: Procedures
[ ] Readings for Class 05: Mental models of computing
[X] Readings for Class 06: Basic types
[X] Readings for Class 08: Colors
[X] Readings for Class 09: Pair Programming
[ ] Readings for Class 10: Transforming things (procedures, colors, images)
[X] Readings for Class 11: Boolean values, predicates, and conditionals
[X] Readings for Class 13: List basics
[X] Readings for Class 15: Processing lists
[X] Readings for Class 16: Software engineering fundamentals
[ ] Readings for Class 17: List composition and decomposition

Labs (10 of 11)
---------------

[X] Lab Writeup from Class 02: An Introduction to Racket
[X] Lab Writeup from Class 03: Image composition and decomposition
[X] Lab Writeup from Class 04: Procedures
[X] Lab Writeup from Class 06: Numbers
[X] Lab Writeup from Class 07: Strings
[X] Lab Writeup from Class 08: RGB colors
[X] Lab Writeup from Class 09: Pair programming
[X] Lab Writeup from Class 10: Transforming images
[X] Lab Writeup from Class 12: Boolean values and conditionals
[ ] Lab Writeup from Class 14: List basics
[X] Lab Writeup from Class 15: More fun with lists

Mini-Projects (1 Es, 1 Ms, and 1 Rs)
------------------------------------

[E] Mini-Project 1 Redo: Playing with image composition and decomposition
[R] Mini-Project 2 Original: Polygons
[M] Mini-Project 3 Original: Image transformations

Learning Assessments (5 of 8)
-----------------------------

[S] LA: Tracing (Phase 1)
[S] LA: Decomposition (Phase 1, Quiz Week 1)
[S] LA: Basic types (Phase 1, SoLA 1)
[S] LA: Collaboration (Phase 1, SoLA 1)
[ ] LA: Procedural abstraction (Phase 1)
[ ] LA: Cut and compose (Phase 1)
[ ] LA: Conditionals (Phase 2)
[S] LA: Program style (Phase 2, Quiz Week 5)

Metacognitive reflections (8 of 9)
----------------------------------

[S] Pre-reflection for MP1
[S] Post-reflection for MP1
[S] Pre-reflection for SoLA 1
[S] Post-reflection for SoLA 1
[S] Pre-reflection for MP2
[ ] Post-reflection for MP2
[S] Pre-reflection for MP3
[S] Post-reflection for MP3
[ ] Post-reflection for MP4
[S] Pre-reflection for MP4
[ ] Pre-reflection for SoLA 2
[ ] Post-reflection for SoLA 2

Final Computations
------------------

Readings:   (10 / 13)
Labs:       (10 / 11)
MPs:        (1 Es, 1 Ms, and 1 Rs)
LAs:        (5 / 8)

Metas:      8 / 9
Missed:     5 (3 reading, 1 lab, 1 meta)

“What grade am I getting?”

  • If you have five or more LAs done, you’re probably in good shape, as long as you’re feeling more confident about at least two of them. (22/24 for an A).
  • If you have at least one E you’re doing fine on MPs. If you’re mostly at Ms, you’re also doing fine, but you should look for ways to get to Es. Ask questions. If you have a lot of I’s (or missings), we should probablyl talk.
  • Be careful on missed things. You get to miss six things. After that, it starts to affect your grade.
  • Tokens not yet computed.

Questions

Grade reports

What happens with late assignments?

The wonder of tokens. Up to late deadline is one token.

First redo on an I MP is a token.

Second redo on any MP is a token.

A missed class in which you did not notify me is two tokens. (You do not have to say why you missed class; you must just acknowledge that you missed class.)

Will you provide an opportunity for me to put in more tokens. I’ve turned in everything late.

Yes. Expect a new form soon.

What about missing reading responses and such?

You get to miss up to six. After that, it affects your grade.

You pay a token to turn them in by the late due date.

The following happened in my life: …. Can I have an extension?

Yes.

Can you choose how your tokens are spent?

No. Too much overhead.

Administrative

Did Sam win all the prizes at Casino Night?

No.

MP4

When do we use testing?

You use testing on the problems that say “write a test” (or three tests).

How do I create different sets of images with the same procedure (stack)?

Ideally, by giving it different sets of parameters.

What should stack do when given a singleton list?

For an M: Anything.

For an E: Give just that image.

What should stack do when given an empty list?

For an M: Anything.

For an E: Anything.

For your sense of satisfaction: A 0x0 transparent rectangle.

How complicated does the freestyle need to be?

For an M, not very complicated. You can use the extant procedures.

For an E, you need to write more procedures like those from each section (i.e., another way to turn a shape into a list of shapes, then a list of shapes, then a list of lists of shapes; another way to turn each shape in each of those structures into a different shape; and another way to combine these shapes in alternating ways).

What is (list-of (list-of shape?))?

It checks to see whether its parameter is a list of lists of shapes.

> (procedure? (list-of (list-of shape?)))
#t
> (shape? thing)
#t
> ((list-of shape?) thing)
#f
> ((list-of shape?) (list thing thing))
#t
> ((list-of (list-of shape?)) thing)
#f
> ((list-of (list-of shape?)) (list thing thing))
#f
> ((list-of (list-of shape?)) (list (list thing thing)))
#t

list-of is kind of like cut in that it builds new procedures. (In this case, predicates.)

Do I need to use cut with reduce?

Not always. You just need a two-parameter procedure that you create in many different ways. cut is one of them. You could write a separate procedure. You could use a lambda expression. You could use one that already exits.

Can we use helper procedures?

Definitely! Ideallly, you document them.

Lists

Is there a simpler way to do cadddddddddddr if the list is super long? I suppose list-ref or something else could do the trick, so why is cadr important to have?

list-ref is better if you’re going fairly far into the list.

There’s also a limit on how many a’s and d’s you can have in the c*r. I think it’s about six in DrRacket.

cadr is much shorter than (list-ref lst 1). We can also use it in composition and map and such.

Can you go over cddr caar cdar and cadr?

Sure!

(cddr x) is the same as (cdr (cdr x))

> (cddr (list 'a 'b 'c 'd 'e))
'(c d e)
> (cddr (list 'a))
. . cddr: contract violation
  expected: (cons/c any/c pair?)
  given: '(a)

(cadr x) is the same as (car (cdr x)) - drop one element, take the first element.

> (cadr (list 'a))
. . cadr: contract violation
  expected: (cons/c any/c pair?)
  given: '(a)

(caar x) is the same as (car (car x)) - take the first element, then take the first element of that. This is for nested lists, and the first element of the nested list must be a list.

> (caar (list (list 'a 'b) (list 'c 'd)))
'a
> (caar (list 'a 'b 'c))
. . caar: contract violation
  expected: (cons/c pair? any/c)
  given: '(a b c)

(cdar) is the same as (cdr (car x)) - take the first element, then drop the first element from what we just took. Note: The first element of our list must be itself a list (as in the case of caar).

> (cdar (list (list 'a 'b) (list 'c 'd)))
'(b)
> (cdar (list 'a 'b))
. . cdar: contract violation
  expected: (cons/c pair? any/c)
  given: '(a b)
> (cadar (list (list 'a 'b) (list 'c 'd)))
'b

If you understand the nesting of a particular list, these can be particularly useful.

You should not need them for MP4.

Can you go over the difference between slightly nested (also singly nested) and doubly nested lists?

Plain list of shapes contains only shapes.

(list shape1 shape2 shape3)

A slightly nested list of shapes contains shapes and/or lists of shapes.

(list shape1 (list shape2 shape3))

A doubly nested list of shapes contains (a) shapes and/or (b) lists of shapes and/or (c) lists of lists of shapes (more or less).

(list shape1 (list shape2 (list shape 3)))

Lab

Don’t worry if you see things like '(5 . 4). That’s a signal from DrRacket that you’ve built something that’s not quite a list, but that it’s still wiling to let you work with.

You can still call car and cdr on these dotted things. Why? Because the designers of Racket (and Scheme (and Lisp)) decided that you can call cons on any two values, and you can call car and cdr on anything you’ve built from cons.