Announcement #
- TL1 doc
- Disk issues, update page soon
- Session from last time on web page
- Issues with accounts
git branch clean-start main
- new-homework and the plan
Plan #
Here we will work through the beginning of HW1 and use it as a platform for the ideas and also tooling/practices such as:
- git
- creating and using a repository
- package
- basic practice
- command line driver
- creating a stub that satisfies the requirements
- structuring data and behavior
- classes/methods or similar
- types
- basic type thinking
Primary focus is on digging in to the ideas to get you started in a good direction.
Review Results of Puzzle 2 and Puzzle 3 #
- Check-in any changes
def puzzle2_3(predicate, transform, foldable): accumulator = [] for item in foldable: if predicate(item): accumulator.append(transform(item)) else: accumulator.append(item) return accumulator # wrapping function: identity # initial accumulator: [] # step function def make_step(predicate, transform_true, transform_false=identity): def step(acc, item): if predicate(item): acc.append(transform_true(item)) else: acc.append(transform_false(item)) return acc return step make_step(lambda x: x % 2 == 0, lambda x: x + 1) # finalizer: identity
Sub-task #1: Defining Folds #
-
A data structure to store the Fold’s data
-
A method to construct a fold given that data
-
A (generic) function
fold: Fold v w r -> Foldable v -> r
-
Unpacking the type
-
A simple view
-
What might this look like in R/Python
-
What does fold do? (cf. Puzzle 2) Look at the pattern
Defining Monoids #
-
Strategy: Carrier with no data, used to interpret the data.
-
The essence: generic operations and dispatch
Discuss dispatch, message passing, objects very briefly
-
Implementation (refer to the supplied files)
Monoidal Folds #
- What needs to be specified here
- Late binding of the
Fold
value. Explain and motivate. - Transformation
- foldTree puzzle (if time allows)