-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code refactored for beginners, with extensive comments and docstrings #4
base: master
Are you sure you want to change the base?
Conversation
also added comments to help orient new users
shapes: box, x, diamond, george segment-lists allow compound shapes to be drawn using concat; see diamond-x fcns: flip-horiz, flip-vert; rotate, rotate180, rotate270; below
Abstracted split-up, split-right into higher-level split function.
Source code refactored, with comments and docstrings added, to make it easy for beginners to get up to speed quickly. Does not implement image-painter. To give yourself a chance to complete the exercise as ‘thattommyhall’ intended, delete the bodies of the following functions: add-vec sub-vec scale-vec flip-horiz rotate below path right-split (uncomment by removing “#_”) up-split (uncomment by removing “#_”) split Just evaluate this file to see the “goal” function, square-limit, draw itself. This version uses the “higher-level” versions of right-split and up-split. If you decide to write the code for up-split and derive the higher-level function ‘split’, you will need to comment out or remove the versions of right-split and up-split that follow split in the source code and un-comment the versions that precede split in the source code. Enjoy, and please give me feedback if you find my version helpful!
Hey @gw666, I can't merge it as it has answers in it :-) I did a talk about the escher stuff for a user group a few weeks ago, which closes some of the exposition gap from just the slides, I'll send the video round soon. I actually was unsure about using clojure vectors for the project (at the cost of some data abstraction), I like that you added make-vec but kept using the destructuring (if you were to swap out vecs for for instance more efficient tuples you would have to do at least that). Have a look if you can swap out your make-vec for one that returns a tuple https://github.com/ztellman/clj-tuple and see if everything still works. Have a look at the interpreter project, there is a video for that coming soon too. |
Hi, Tommy, Thanks for getting back to me. I really appreciate it. In the little time I have, I've found a composable way to add multicolor pictures and have been thinking about ways to make the basic picture change over time. It's simple stuff, I'm sure, but I'm learning to think in terms of composition and abstraction. Two questions:
As always, many thanks for your work! Best wishes, Gregg On Mar 14, 2015, at 6:09 PM, thattommyhall [email protected] wrote:
|
Yes to a clean docstring PR, helps with understanding. I think the 'see if you can easily migrate to clj-tuple' is an interesting extension, so dont want to do it already (you need to change the bits where you return a value so still need to do a make-vec function, rather than returning a vec) (defn add-vec [[x1 y1] [x2 y2]]
[(+ x1 x2) (+ y1 y2)]) |
Interesting discussion with @shterrett in the room for the blackjack project, exactly the same tension between using the abstraction given in Clojure's defrecord and/or destructuring vs the create set/get pattern advocated in the book |
@gw666 If you want another fun bit of abstraction/composition, check this out https://www.youtube.com/watch?v=Mfsnlbd-4xQ |
Hi--I completely changed things around to make the code to my liking. I apologize for the inadequacies of my commit stream--I'm still learning good git usage.
Feel free to take any part(s) of it you desire. Thanks.
Gregg
PS: It would be nice to get a brief note back from you. I feel I'm dumping code into the void. GW