Functional Problem Solving (CSC 151 2016S) : EBoards

CSC151.02 2016S, Class 41: Project Kickoff


Overview

Preliminaries

Admin

Reminders

Upcoming Work:

Extra Credit

Academic / Artistic

Peer

Regular Peer

Misc

Not so Far in the Future

Questions

Can we talk our way through number three.

What is the problem? Draw a snowflake-like object.

Inputs: turtle, side-length, number-of-sides, depth

Depth: How many sizes of shapes to make

This is a recursive task. We made the side length smaller at every step. But we can also think about this as recursing over depth.

What's your base case?

One possible base case: 1 deep

    repeat sides times
      move forward by side length
      turn counter-clockwise by the approriate angle (90 degrees
        for a square)

Recursive case

    repeat side times
      move forward by side length
      RECURSE
      turn counter-clockwise by the appropriate angle

Problem: Let's try it.

Observation: It looks like we need to keep track of whether we are rotating clockwise or counter clockwise. The recursive call is in the opposite direction.

Suggestion: Helper (local) that keeps track of level, side length, and clockwise/counter-clockwise.

Do we really need both iteration (repeat) and recursion to solve this?

It works best that way.

Is 1 really the best base case?

No. Use 0 as the base case. Do nothing in that case.

    (cond
      [(zero? depth)]
      [else
       (repeat ...
               ...)])

About the project, revisited

Group composition

What skills will you need in your team?

Also need skills as a whole

Time to form groups

Playing and brainstorming