Pohon BBS: recent postsAnonymoushttps://bbs.gikopoi.com/recent2026-09-14T14:41:55+00:00Excercise 1.8https://bbs.gikopoi.com/thread/1788895112/#1:4:222026-09-14T14:41:55+00:002026-09-14T14:41:55+00:00
This one was just implementing the formula and then<br>%%replacing the old one in the "improve" procedure%%<br><br>%%(define (improve guess x)%%<br> %%(/%%<br> %%(+%%<br> %%(/ x (square guess))%%<br> %%(* guess 2))%%<br> %%3)%%
PHATCATTTThttps://bbs.gikopoi.com/thread/1788895112/#1:4:19:212026-09-14T02:07:37+00:002026-09-14T02:07:37+00:00
the tolerance I specified was kinda wide, which made the big number calculation off by a good amount (oops!). After reducing the tolerance to 0.000000000001 (rest of the code kept the same) i get the same result as my calculator (Casio fx-991EX). Dr racket seems to have rounded the small square roots output to 1e-7, im not sure if this is a fault in my code or just computer stuff (can anyone confirm?)<br><br>%% also i noticed that if im just comparing the guesses,i dont need to square them and then divide. I also had redundant (abs ) functions in the code so heres an improvement%%<br><br>%%(define (good-enough? guess x)%%<br>%%(< %%<br> %%(abs %%<br> %%(- %%<br> %%(/ %%<br> %%guess%%<br> %%(improve guess x)) 1)) 0.000000000001))%%<br><br>(sqrt 0.00000000000001) ;very small number test<br>(sqrt 1000000000000000) ;very large number test<br><br>outputs:<br>1e-7<br>31622776.601683907
New replyhttps://bbs.gikopoi.com/thread/1788895112/#1:4:19:202026-09-14T01:53:51+00:002026-09-14T01:53:51+00:00
%%where 0.001 was the tolerance to see if the guess was good enough%%
Excercise 1.7https://bbs.gikopoi.com/thread/1788895112/#1:4:192026-09-14T01:50:23+00:002026-09-14T01:50:23+00:00
The full code is VERY long and has multiple things needing to be defined so ill only post what was changed from the procedure defined in SICP. My thought process was: <br>need to compare guesses, so need to know guess-1 and guess-2<br>modify the improve definition to "save" the old guess? (oh no...)<br>OR <br>%%just use (improve guess x) itself as the guess 2%%<br><br>then<br>%%;modified from 1.1.7 for Exercise 1.7%%<br>%%(define (good-enough? guess x)%%<br>%%;(< (abs (- (square guess) x)) 0.001));old/original code [from SICP]%%<br>%%(< ;check if guess is within tolerance%%<br> %%(abs ; stops it from breaking if it gives a negative number%%<br> %%(- ;small difference between subsequent guesses => fraction ~1, so fraction-1 ~0%%<br> %%(/%%<br> %%(abs (square guess))%%<br> %%(abs (square (improve guess x)))) 1)) 0.001))%% <br>...<br>(sqrt 0.00000000000001) ;very small number test<br>(sqrt 1000000000000000) ;very large number test<br><br>answers were correct
HomePage revisionhttps://bbs.gikopoi.com/thread/1717870466/#1:112026-09-13T16:35:36+00:002026-09-13T16:35:36+00:00
----<br>**Special pages:** [All Pages](/w/all) , [Recent Changes](/w/recent) , [Popularity](/w/popular), [Random](/w/random), [Atom feed](/feed.atom)<br><br>----<br>Welcome to WikiWikiWiki, an<br>[open source](https://github.com/153/wikiwikiwiki/) project sponsored by the<br>GikoPoi community.<br><br>We are the original c2 WikiWiki [[cloan]] for the VipQuality community, being<br>a continuation of 4x13's ThisWiki. This is meant to be a wiki that can be<br>edited by nearly anyone who wants to, with little to no friction! The tone<br>is meant to be informal. After solving the CAPTCHA, check out the MarkUp<br>guide, and then have at it.<br><br>Please keep in mind that WikiWikiWiki is NOT a WikiWiki'Wiki. Go to<br>[Meatball Wiki](http://meatballwiki.org/wiki/) if you are into that kind<br>of thing. We are something more like TanasinnWiki back in its glory days. <br><br>Wiki discussion: [Pohon BBS](https://bbs.gikopoi.com/tags/wiki/)<br><br>Advice for writing: WritingPhilosophy
New replyhttps://bbs.gikopoi.com/thread/1710882439/#1:122026-09-10T08:23:05+00:002026-09-10T08:23:05+00:00
%%testing different implementation of spoilers%%<br>%% test %%%<br>%%test test%%<br>%% %%<br>%% test%%
exercise 1.3https://bbs.gikopoi.com/thread/1788895112/#1:4:182026-09-09T20:55:03+00:002026-09-09T20:55:03+00:00
%%%<br>[(define (square a)<br> (* a a))<br><br>(define (smallest x y z)<br> (if (< x y)<br> (if (< x z) x z)<br> (if (< y z) y z)))<br><br>(define (procedure x y z)<br> (- (+ (square x)(square y)(square z))(square (smallest x y z))))<br><br>(procedure 7 10 10)]<br>%%%
New replyhttps://bbs.gikopoi.com/thread/1710882439/#1:10:112026-09-09T16:32:09+00:002026-09-09T16:32:09+00:00
%%%<br>test spoiler again<br> <br>one two<br> <br>three four <br>%%%
New replyhttps://bbs.gikopoi.com/thread/1710882439/#1:102026-09-09T16:31:09+00:002026-09-09T16:31:09+00:00
%%%<br>test spoiler<br><br>test<br>%%%
epic phailhttps://bbs.gikopoi.com/thread/1788895112/#1:4:13:14:16:172026-09-09T15:35:08+00:002026-09-09T15:35:08+00:00
Fixed the fix<br><br>%%#lang sicp%%<br><br>%%(define (square x) (* x x))%%<br><br>%%(define (sicp_ex_1.3 x y z)%%<br>%% (+%%<br>%% (if (= x y z) 0%%<br>%% (if (< x y) (if (< x z) 0 (square x)) (square x))))%%<br>%% (if (< y x) (if (< y z) 0 (square y)) (square y))%%<br>%% (if (< z y) (if (< z x) 0 (square z)) (square z)))%%<br> <br>%%(sicp_ex_1.3 1 2 3)%%<br>%%(sicp_ex_1.3 2 2 2)%%<br>%%(sicp_ex_1.3 2 1 0)%%
fix ex 1.3https://bbs.gikopoi.com/thread/1788895112/#1:4:13:14:162026-09-09T15:27:28+00:002026-09-09T15:27:28+00:00
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:<br><br>%%#lang sicp%%<br><br>%%(define (square x) (* x x))%%<br><br>%%(define (sicp_ex_1.3 x y z)%%<br>%% (+%%<br>%% (if (= x y) 0 (if (= x z) 0%%<br>%% (if (< x y) (if (< x z) 0 (square x)) (square%% %%x))))%%<br>%% (if (< y x) (if (< y z) 0 (square y)) (square y))%%<br>%% (if (< z y) (if (< z x) 0 (square z)) (square z))))%%<br> <br>%%(sicp_ex_1.3 1 2 3)%%<br>%%(sicp_ex_1.3 2 2 2)%%<br>%%(sicp_ex_1.3 2 1 0)%%
corrected exercise 1.3https://bbs.gikopoi.com/thread/1788895112/#1:4:13:152026-09-09T15:22:45+00:002026-09-09T15:22:45+00:00
%%%<br>Updated to catch PhatCat's fix -- if x, y, and z are the same<br>value, the code does not work<br><br>(define (square x) <br> (* x x)) <br>(define (sum-squares x y) <br> (+ (square x) (square y))) <br> <br>(define (sum-greater-squares x y z) <br> (if (> x y) <br> (if (> y z) <br> (sum-squares x y) <br> (sum-squares x z)) <br> (if (> x z) <br> (sum-squares y x)<br> (if (= x y z)<br> (sum-squares x x)<br> (sum-squares y z)))))<br>%%%
Spoiler hack (temporary)https://bbs.gikopoi.com/thread/1704245584/#1:492026-09-09T05:15:06+00:002026-09-09T05:15:06+00:00
I am too lazy to make a proper "spoiler field" (similar to markdown's<br>code fences) to spoiler-ify multiple lines of text right this second, so if <br>you need to make an entire post a spoiler post, do it exactly like this:<br><br>%%%<br>The text you want to hide across multiple<br>lines -- the entire body of a post<br>%%%<br><br>That's 3 %'s at the very start of a post,<br>immediately press enter to break the line,<br>everything else,<br>enter,<br>3 %'s again with nothing following. <br><br>Later I'll probably just add a [ ] Spoiler checkbox but I've been up for<br>something like 30 hours and now is not the time for that. Be patient! <br>%%enjoy and use responsibly!%%
New replyhttps://bbs.gikopoi.com/thread/1710882439/#1:92026-09-09T02:00:21+00:002026-09-09T02:00:21+00:00
%%%<br>%%%<br>test test<br>test<br>test<br>test<br>%%%<br>%%%
New replyhttps://bbs.gikopoi.com/thread/1710882439/#1:82026-09-09T01:58:36+00:002026-09-09T01:58:36+00:00
%%%<br>Testing the laziest<br>possible implementation<br>of multi-line spoilers:<br>first line is EXACTLY %%%, newline,<br>last line is EXACTLY %%%, nothing else<br>%%%
New replyhttps://bbs.gikopoi.com/thread/1710882439/#1:72026-09-09T01:57:31+00:002026-09-09T01:57:31+00:00
%%%<br>test<br>%%%
Excercise 1.3https://bbs.gikopoi.com/thread/1788895112/#1:4:13:142026-09-09T01:43:46+00:002026-09-09T01:43:46+00:00
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:<br><br>%%#lang sicp%%<br>%%(define (sicp_ex_1.3 x y z)%%<br>%% (+%%<br>%% (if (< x y) (if (< x z) 0 (* x x)) (* x x))%%<br>%% (if (< y x) (if (< y z) 0 (* y y)) (* y y))%%<br>%% (if (< z y) (if (< z x) 0 (* z z)) (* z z))))%%<br>%% %% <br>%%(sicp_ex_1.3 1 2 3)%%<br>%%result was 13 so it worked%%
exercise 1.3https://bbs.gikopoi.com/thread/1788895112/#1:4:132026-09-08T21:50:10+00:002026-09-08T21:50:10+00:00
%% (define (square x) %%<br>%% (* x x)) %%<br>%% (define (sum-squares x y) %%<br>%% (+ (square x) (square y))) %%<br>%% %%<br>%% (define (sum-greater-squares x y z) %%<br>%% (if (> x y) %%<br>%% (if (> y z) %%<br>%% (sum-squares x y) %%<br>%% (sum-squares x z)) %%<br>%% (if (> x z) %%<br>%% (sum-squares y x) %%<br>%% (sum-squares y z)))) %%<br>%% %%<br>%% (sum-greater-squares 1 2 3) %%<br>%% (sum-greater-squares 4 2 3) %%<br>%% (sum-greater-squares 5 1 0) %%<br>
New replyhttps://bbs.gikopoi.com/thread/1710882439/#1:62026-09-08T21:48:46+00:002026-09-08T21:48:46+00:00
test<br><br>%%%<br>test<br>test<br>test<br>%%%
New replyhttps://bbs.gikopoi.com/thread/1788895112/#1:3:122026-09-08T20:11:17+00:002026-09-08T20:11:17+00:00
Famous article by a guy who used Lisp to become a billionaire :<br><br>> Graham, Paul. "The Roots of Lisp." (2001) 15pp <br>https://wiki.eecs.yorku.ca/course_archive/2014-15/W/6339/_media/jmc.pdf<br><br>discusses how 7 primitives became the meta language
some sample lisp codehttps://bbs.gikopoi.com/thread/1788895112/#1:3:112026-09-08T19:51:10+00:002026-09-08T19:51:10+00:00
(define pi 3.14159265)<br>(define (square x) (* x x))<br><br>(define (volume-of-cone radius height)<br> (* pi (square radius) (/ height 3)))<br><br>(define my-cone-volume (volume-of-cone 1 2))<br><br>my-cone-volume<br>=> 2.09
outputs color based on stats (hopefully)https://bbs.gikopoi.com/thread/1788895112/#1:3:102026-09-08T19:37:11+00:002026-09-08T19:37:11+00:00
(define (clouds_color strength intelligence Defense)<br>(define red strength)<br>(define blue intelligence)<br>(define green defence)<br>(list red green blue))) % gives RGB color (idk how to/<br> if its even possible for lisp to output a color)
Chapter 5https://bbs.gikopoi.com/thread/1788895112/#1:92026-09-08T19:30:51+00:002026-09-08T19:30:51+00:00
> Computing with Register Machines<br><br>https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-30.html#%_chap_5
Chapter 4https://bbs.gikopoi.com/thread/1788895112/#1:82026-09-08T19:29:38+00:002026-09-08T19:29:38+00:00
> Metalinguistic Abstraction<br>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
Chapter 3https://bbs.gikopoi.com/thread/1788895112/#1:72026-09-08T19:28:36+00:002026-09-08T19:28:36+00:00
> Modularity, Objects, and State<br><br>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