slac207 / cs207project

MIT License
0 stars 4 forks source link

Create a LazyOperation class in file lazy.py #8

Closed sanoke closed 7 years ago

sanoke commented 7 years ago

Task (from Project Spec 3) Create a new file called lazy.py.

Inside, create a new class called LazyOperation, which will be our thunk. The constructor should take one required argument function and then arbitrary positional and keyword arguments (this is the *args and **kwargs syntax, if you remember). The constructor doesn't need to do anything but store them internally for now.

This follows what we did in the lecture.

Write a @lazy decorator now.

Add in a lazy_add() and a lazy_mul() and use these to write tests for lazy.py.

If you've done it correctly, you should be able to run something like this:

isinstance( lazy_add(1,2), LazyOperation ) == True
brennan-ae commented 7 years ago

Added in pull request (#10)

sanoke commented 7 years ago

@brennan-ae I'm assuming that b/c this issue is closed, we're able to run

isinstance( lazy_add(1,2), LazyOperation ) == True

...? I haven't tested this myself yet, although I will (it's further down on my To Do list).