■ 🕑 1. SICP : Let's Read! │ > SICP Book: │ https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-4.html │ │ > SICP Lectures: │ https://www.youtube.com/playlist?list=PLE18841CABEA24090 │ > Racket Scheme │ https://racket-lang.org/download/ │ > SICP Racket │ https://docs.racket-lang.org/sicp-manual/Installation.html │ │ Let's embrace the tree structure of Pohon BBS. │ │ Top level comments for chapters of the book, │ replies to top level comments for discussions of the chapter. │ │ Comment #2 will be for general help installing Scheme │ Comment #3 will be for random Scheme discussion that doesn't │ fit into chapter discussion. │ │ Ready, start, go! │ ├─■ 🕑 2. │ General Scheme troubleshooting / installation help / etc goes under this │ comment.... │ ├─■ 🕑 3. │ │ Random Scheme / Lisp / programming discussion that doesn't fit into │ │ chapter discussion goes here.... │ │ │ ├─■ 🕑 5. phatcat power level formula (first scheme test) │ │ (define phatcat_powerlevel 1200) │ │ (define unlocked_potential 500) │ │ (define (phatcat_bulky_transformation x y) (* 1.2 (+ x y))) │ │ (phatcat_bulky_transformation phatcat_powerlevel unlocked_potential) │ │ │ │ │ ├─■ 🕑 10. outputs color based on stats (hopefully) │ │ (define (clouds_color strength intelligence Defense) │ │ (define red strength) │ │ (define blue intelligence) │ │ (define green defence) │ │ (list red green blue))) % gives RGB color (idk how to/ │ │ if its even possible for lisp to output a color) │ │ │ ├─■ 🕑 11. some sample lisp code │ │ (define pi 3.14159265) │ │ (define (square x) (* x x)) │ │ │ │ (define (volume-of-cone radius height) │ │ (* pi (square radius) (/ height 3))) │ │ │ │ (define my-cone-volume (volume-of-cone 1 2)) │ │ │ │ my-cone-volume │ │ => 2.09 │ │ │ └─■ 🕑 12. │ Famous article by a guy who used Lisp to become a billionaire : │ │ > Graham, Paul. "The Roots of Lisp." (2001) 15pp │ https://wiki.eecs.yorku.ca/course_archive/2014-15/W/6339/_media/jmc.pdf │ │ discusses how 7 primitives became the meta language │ ├─■ 🕑 4. Chapter 1 │ │ SICP chapter 1 │ │ > Building Abstractions with Procedures │ │ │ │ https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-9.html#%_chap_1 │ │ │ ├─■ 🕑 13. exercise 1.3 │ │ │ (define (square x) │ │ │ (* x x)) │ │ │ (define (sum-squares x y) │ │ │ (+ (square x) (square y))) │ │ │ │ │ │ (define (sum-greater-squares x y z) │ │ │ (if (> x y) │ │ │ (if (> y z) │ │ │ (sum-squares x y) │ │ │ (sum-squares x z)) │ │ │ (if (> x z) │ │ │ (sum-squares y x) │ │ │ (sum-squares y z)))) │ │ │ │ │ │ (sum-greater-squares 1 2 3) │ │ │ (sum-greater-squares 4 2 3) │ │ │ (sum-greater-squares 5 1 0) │ │ │ │ │ │ │ │ └─■ 🕑 14. Excercise 1.3 │ │ │ My attempt at exercise 1.3. it took me a long time as most of my attempts made code that excluded anything that wasn't the maximum number, so i guess finding the "middle" number is what makes this challenging. my first attempts were checking each variable against the others individually (mistake). if x>y then output x otherwise 0, if x>z output x otherwise 0 then multiply both outputs, repeat for each variable (rather silly in retrospect). After this i decided to only compare to the third variable if the first check failed and directly compute the square if the variable wasn't the minimum. Code below: │ │ │ │ │ │ #lang sicp │ │ │ (define (sicp_ex_1.3 x y z) │ │ │ (+ │ │ │ (if (< x y) (if (< x z) 0 (* x x)) (* x x)) │ │ │ (if (< y x) (if (< y z) 0 (* y y)) (* y y)) │ │ │ (if (< z y) (if (< z x) 0 (* z z)) (* z z)))) │ │ │ │ │ │ (sicp_ex_1.3 1 2 3) │ │ │ result was 13 so it worked │ │ │ │ │ ├─■ 🕑 15. corrected exercise 1.3 │ │ │ Updated to catch PhatCat's fix -- if x, y, and z are the same │ │ │ value, the code does not work │ │ │ │ │ │ (define (square x) │ │ │ (* x x)) │ │ │ (define (sum-squares x y) │ │ │ (+ (square x) (square y))) │ │ │ │ │ │ (define (sum-greater-squares x y z) │ │ │ (if (> x y) │ │ │ (if (> y z) │ │ │ (sum-squares x y) │ │ │ (sum-squares x z)) │ │ │ (if (> x z) │ │ │ (sum-squares y x) │ │ │ (if (= x y z) │ │ │ (sum-squares x x) │ │ │ (sum-squares y z))))) │ │ │ │ │ └─■ 🕑 16. fix ex 1.3 │ │ │ summed all 3 squares if x y z were the same. added a check to just force one variable to zero if all the numbers were equal so theres probably a more elegant solution :P. Code: │ │ │ │ │ │ #lang sicp │ │ │ │ │ │ (define (square x) (* x x)) │ │ │ │ │ │ (define (sicp_ex_1.3 x y z) │ │ │ (+ │ │ │ (if (= x y) 0 (if (= x z) 0 │ │ │ (if (< x y) (if (< x z) 0 (square x)) (squarex)))) │ │ │ (if (< y x) (if (< y z) 0 (square y)) (square y)) │ │ │ (if (< z y) (if (< z x) 0 (square z)) (square z)))) │ │ │ │ │ │ (sicp_ex_1.3 1 2 3) │ │ │ (sicp_ex_1.3 2 2 2) │ │ │ (sicp_ex_1.3 2 1 0) │ │ │ │ │ └─■ 🕑 17. epic phail │ │ Fixed the fix │ │ │ │ #lang sicp │ │ │ │ (define (square x) (* x x)) │ │ │ │ (define (sicp_ex_1.3 x y z) │ │ (+ │ │ (if (= x y z) 0 │ │ (if (< x y) (if (< x z) 0 (square x)) (square x)))) │ │ (if (< y x) (if (< y z) 0 (square y)) (square y)) │ │ (if (< z y) (if (< z x) 0 (square z)) (square z))) │ │ │ │ (sicp_ex_1.3 1 2 3) │ │ (sicp_ex_1.3 2 2 2) │ │ (sicp_ex_1.3 2 1 0) │ │ │ └─■ 🕑 18. exercise 1.3 │ [(define (square a) │ (* a a)) │ │ (define (smallest x y z) │ (if (< x y) │ (if (< x z) x z) │ (if (< y z) y z))) │ │ (define (procedure x y z) │ (- (+ (square x)(square y)(square z))(square (smallest x y z)))) │ │ (procedure 7 10 10)] │ ├─■ 🕑 6. Chapter 2 │ > Building Abstractions with Data │ https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-13.html#%_chap_2 │ ├─■ 🕑 7. Chapter 3 │ > Modularity, Objects, and State │ │ https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-19.html#%_chap_3 │ ├─■ 🕑 8. Chapter 4 │ > Metalinguistic Abstraction │ https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-25.html#%_chap_4 │ └─■ 🕑 9. Chapter 5 > Computing with Register Machines