https://github.com/tiger40490/repo1/tree/py1/py/algo_combo_perm uses python q[ yield ] to implement classic generators of
Key features and reasons why we should try to memorize it
briefcode, not too dense (cryptic), .. helps us remember.
- reliability —
briefmeans fewer hiding place for a bug. I added automated tests for basic quality assurance. Published solution
- versatile — one single function to support multiple classic generators.
- yield functions’ suspend-resume feature is particular powerful and possibly a power drill. This is my first opportunity to learn it.
- instrumentation — relatively easy to add prints to see what’s going on.
- halo — yield-based generator functions are a halo and also a time-saver
- elegant —
brief, simple, relatively easy to understand
- recursive — calling itself recursively in a loop therefore fairly
- useful in take-home assignments
- identity-aware — The second time you call myYieldFunc(44), it would usually return the same generator object as the first time you call it with that same argument (i.e. 44). If that generator object has reached end of it’s execution, then you won’t get any more output.
— How I might try to memorize it
- If needed, we just need to reproduce it quickly from memory a few times
- I added comments to help me understand and memorize it