==== Log for ##SICP on irc.freenode.net ==== January 25th, 2009 from 10:00 PM to 11:12 PM. All times are GMT-0200. ==== Logged by nicou. http://nicou.org. ==== Feel free to repost. (10:00:08 PM) vixey left the room (quit: "There exists an infinite set!"). (10:00:10 PM) tfincannon [n=chatzill@75.147.136.46] entered the room. (10:00:18 PM) nicou: you know what would be really cool and hard to arrange? a schemebot (10:00:25 PM) nicou: like lambdabot but for scheme (10:00:37 PM) inimino: nicou: that would be cool, but why hard to arrange? (10:00:55 PM) nicou: well, probably not hard, but I wouldn't know how to (10:01:18 PM) inimino: I don't know either, maybe it's already been done though (10:01:26 PM) nicou: but it'd basically be and IRC client connected to a basic scheme interpreter (10:01:32 PM) tooz: http://github.com/offby1/rudybot/tree/master (10:01:49 PM) inimino: so, our meeting is now in session, right? (10:01:57 PM) nicou: yes (10:02:01 PM) nicou: it has officially started (10:02:30 PM) stu8ball: lambdabot has timeouts and stuff though (10:02:35 PM) joha1 [n=johan@59-171-104-224.rev.home.ne.jp] entered the room. (10:02:40 PM) mib_r651q3: Is 1.1 worth going over? I imagine most people entered the code into an interpreter and checked results against what they thought the output would be? (10:02:42 PM) stu8ball: although, that wouldn't be hard either (10:02:57 PM) nicou: yes, but whatever (10:03:03 PM) mariorz: q#scheme has sarahbot (10:03:15 PM) silentbicycle: section 1.1, pgs. 5 - 31, right? (10:03:25 PM) tooz: is sarahbot running on that rudybot code ? (10:03:35 PM) aamar: Did anyone have trouble getting the scheme interpreter working? (10:03:36 PM) mariorz: tooz: no (10:03:44 PM) mib_r651q3: silentbicycle: what's the last thing on page 31? (10:03:51 PM) mariorz: sisc (10:03:56 PM) mariorz: could not get it running though (10:04:10 PM) EwS: I am running drscheme and mzscheme (10:04:11 PM) bushymark: is everyone using a uniform interpreter? I installed the MIT implementation, but if there is one everyone is using, I would rather use that (10:04:16 PM) mib_r651q3: ews: me too. (10:04:19 PM) nicou: I'm using drscheme (10:04:21 PM) aamar: MIT scheme here (10:04:22 PM) tooz: i'm using mzscheme (10:04:22 PM) trefn left the room (quit: ). (10:04:24 PM) mariorz: mzscheme (10:04:30 PM) nicou: for section 1.1 it'll work just fine (10:04:36 PM) inimino: I'm not using an interpreter at all (10:04:43 PM) mib_r651q3: so if i have mzscheme, and make a .scm file, how can i see output without knowing how the print statement works? (10:04:52 PM) silentbicycle: mib_r651q3: pg. 31 is just the paragraph before "1.2 Procedures and the Processes They Generate" (10:04:54 PM) tfincannon: I am using Clojure (10:04:57 PM) mib_r651q3: i basically did everything in dr. scheme, which prints intermediate output. (10:04:58 PM) nicou: (display x) (10:05:05 PM) mib_r651q3: nicou: thx (10:05:07 PM) silentbicycle: I'm using chicken (10:05:16 PM) tooz: i've been loading it into the interpreter and then testing it (10:05:26 PM) tooz: mzscheme -f ex1-5.ss (10:05:30 PM) enoqu_: i was using MIT, then I switched to DrScheme.. its great (10:05:46 PM) silentbicycle: but AFAIK interpreter/compiler differences shouldn't affect anything for a while. (10:05:48 PM) mib_r651q3: tooz: ya i got that, was missing the (display x) part. (10:05:56 PM) inimino: I've just written the answers but not tested anything (10:06:14 PM) nicou: silentbicycle: no, for section 1.1 at least, everything should work correctly (10:06:14 PM) inimino: I don't think an interpreter is necessary for 1.1 (or 1.2 for that matter) (10:06:25 PM) nicou: inimino: just for checking (10:06:32 PM) inimino: nicou: right (10:06:38 PM) mib_r651q3: silentbicycle: ya, i stopped just before 1.2 started, so ending on pg 31 (10:07:01 PM) nicou: ok, I'll write the answers in order to check (10:07:18 PM) nicou: answers for ex 1.1.: 10 (10:07:20 PM) nicou: 12 (10:07:21 PM) nicou: 8 (10:07:22 PM) nicou: 3 (10:07:24 PM) nicou: 6 (10:07:30 PM) nicou: implementation dependent (10:07:31 PM) nicou: implementation dependent (10:07:33 PM) nicou: 19 (10:07:34 PM) nicou: #f (10:07:35 PM) nicou: 4 (10:07:37 PM) nicou: 16 (10:07:38 PM) nicou: 6 (10:07:39 PM) nicou: 16 (10:08:48 PM) inimino: that's what I have (10:09:13 PM) aamar: check (10:09:14 PM) inimino: my answers are up at: http://mjclement.com/projects/2009/SICP/chap_1/ (10:09:14 PM) stu8ball: I didn't keep my answer to that one. (10:09:35 PM) EwS: great (10:09:46 PM) EwS: didn't keep my answers either, but that looks ok (10:10:02 PM) nicou: I'll write them down later (10:11:16 PM) nicou: should we move on to the next one? (10:11:19 PM) EwS: any questions on 1.1? (10:12:04 PM) tooz: nope (10:12:17 PM) bushymark: not so far! (10:12:25 PM) mib_r651q3: lets do 1.2 (10:12:26 PM) nicou: man I've had a hard time with ex 1.1 (10:12:26 PM) chrisconley: moving on to 1.2 sounds good to me :) (10:12:33 PM) EwS: k (10:12:38 PM) nicou: ok (10:12:46 PM) mib_r651q3: nicou: did you? how so (10:12:53 PM) nicou: nah, jk (10:13:01 PM) nicou: so (10:13:10 PM) mib_r651q3: :P 1.2... (10:13:47 PM) nicou: I got (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7))) for 1.2 (10:14:04 PM) EwS: same (10:14:06 PM) chrisconley: yeah looks about the same as mine (10:14:07 PM) nicou: without the pretty printing the parenthesis really start bugging (10:14:32 PM) tooz: yeah i got the same (10:14:39 PM) stu8ball: Best to to check that against your own is: cat - 1.2 <<< '*paste*' (10:14:42 PM) inimino: yeah, I broke that one on two lines (10:14:51 PM) mib_r651q3: (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5)))) (* (- 6 2) (- 2 7))) (10:15:08 PM) Facedown: f (10:15:24 PM) Facedown: .. ( + 4 5 ( - ( - (+6 4/5) 3 ) 2 ) ) (* 3 (- 6 2) (- 2 7 ) ) (10:15:48 PM) inimino: "4/5" isn't Scheme (10:15:57 PM) nicou: mib_r651q3: I think you're missing a paren at the end of the first argument of the main / (10:15:59 PM) Facedown: doh (10:16:05 PM) paul_hfx: inimino, how now? (10:16:10 PM) inimino: other than that it looks right (10:16:11 PM) mib_r651q3: nicou: i am (10:16:11 PM) Facedown: it has to be / 4 5 (10:16:14 PM) paul_hfx: is it a PTL scheme-specific thing? (10:16:15 PM) Facedown: or whatever (10:16:16 PM) mib_r651q3: i'm not at home, just tried it again on the fly (10:16:16 PM) mib_r651q3: thx (10:16:24 PM) paul_hfx: mzscheme allows it (10:16:31 PM) inimino: paul_hfx: it should be (/ 4 5) (10:16:36 PM) stu8ball: "4/5" is output anyway, not code. (10:16:36 PM) mib_r651q3: i was also missing a 3 (10:16:43 PM) stu8ball: See alsa, any other REPL. (10:16:44 PM) silentbicycle: 4/5 could be a ratio (10:16:46 PM) stu8ball: also* (10:17:03 PM) aamar: mit scheme does output results in that form: (/ 4 5) ; => 4/5 (10:17:04 PM) silentbicycle: schemes which correctly implement the whole numeric tower should be able to do ratios. (10:17:09 PM) inimino: well, I'm just talking about what's been presented in the book, not any extensions (10:17:15 PM) aamar: But you can't write an expression that way, as far as I can see. (10:17:29 PM) silentbicycle: it's a requirement of the language from r5rs. (10:17:31 PM) aamar: n/m, it works in some schemes not others (10:17:32 PM) EwS: you could force floats (/ 4 5.0) -> 0.8 (10:17:35 PM) paul_hfx: it's not an expression, it's a fraction literal (10:17:44 PM) EwS: that's a behaviour of mzscheme and mit-scheme (10:18:02 PM) paul_hfx: ok, good to know (10:18:17 PM) mib_r651q3: ya, definitely good to know. now lets move on? any questions on 1.2? (10:18:25 PM) nicou: nope (10:18:29 PM) chrisconley: nope (10:18:32 PM) tooz: nope (10:18:46 PM) EwS: 1.3 (10:19:00 PM) nicou: well let's move on, we might have different solutions for 1.3, anybody wants to show his? (10:19:18 PM) stu8ball: 10 lines. Do I paste it here ? (10:19:20 PM) inimino: http://mjclement.com/projects/2009/SICP/chap_1/1.3 (10:19:21 PM) paul_hfx: http://mibbit.com/pb/7mGPtx (10:19:28 PM) nicou: yes, do (10:19:31 PM) stu8ball: k (10:19:33 PM) ebiester [n=ibsulon@ip70-190-102-15.ph.ph.cox.net] entered the room. (10:19:34 PM) stu8ball: (define (sum-of-squares a b c) (10:19:34 PM) stu8ball: (define (foo x y) (10:19:34 PM) stu8ball: (+ (* x x) (* y y))) (10:19:34 PM) stu8ball: (if (> a b) ;; a is biggest or second-biggest of the three (10:19:34 PM) stu8ball: (if (> b c) ;; b is biggest or second-biggest of the three (10:19:36 PM) stu8ball: (foo a b) (10:19:39 PM) stu8ball: (foo a c)) (10:19:41 PM) stu8ball: (if (> a c) ;; a is second-biggest of the three (10:19:43 PM) chrisconley: http://github.com/chrisconley/sicp-exercises/blob/a98c61036ed2cbc3d658b8e9d485979942736484/chapter1/ex1-03.ss (10:19:44 PM) stu8ball: (foo b a) (10:19:46 PM) stu8ball: (foo b c)))) (10:19:48 PM) mariorz: pastebin (10:19:49 PM) tooz: we should use paste bin (10:19:59 PM) mariorz: http://pastebin.com/m296edb42 (10:19:59 PM) inimino: pastebin++ (10:20:01 PM) nicou: lol ok pastebin (10:20:01 PM) chrisconley: yeah paste bin sounds good (10:20:04 PM) mib_r651q3: ya pastebin (10:20:07 PM) EwS: question paul_hfx : why [ ]] on the or and else? (10:20:11 PM) Facedown: ya pastebin (10:20:14 PM) inimino: unanimous for pastebin (10:20:22 PM) stu8ball: ok (10:20:25 PM) aamar: http://mibbit.com/pb/v8Yr5r (10:20:29 PM) mib_r651q3: mine is like marioz (10:20:39 PM) stu8ball: or sprunge.us , since we're dealign with text files. :) (10:20:48 PM) silentbicycle: http://pastebin.com/d391c173c -- somewhat shorter, but still cumbersome (10:20:57 PM) mib_r651q3: except i wouldn't use sqard as the function name ;) (10:21:01 PM) ebiester: Did anyone use max and min? (sorry I just popped in) (10:21:03 PM) ebiester: (define (largest-two x y z) (10:21:03 PM) ebiester: `(,(max x y) ,(max (min x y) z))) (10:21:14 PM) Facedown: oh (10:21:14 PM) paul_hfx: EwS: I just find it easier to read, might be a PTL scheme extension that allows it to be done though (10:21:17 PM) mib_r651q3: marioz: you use [ and ] (10:21:18 PM) Facedown: theres a native min/max function? (10:21:21 PM) mib_r651q3: what do those do? (10:21:22 PM) EwS: ok, thanks paul_hfx (10:21:23 PM) paul_hfx: EwS: DrScheme allows it for sure (10:21:26 PM) stu8ball: I was going to use max and min, but then didn't out of purity, i.e. only using the stuff covered in the book so far. (10:21:39 PM) silentbicycle: stu8ball: right, that tripped me up (10:21:48 PM) inimino: hm, paul_hfx I think your solution is a little better than mine (10:21:59 PM) tooz: i did a cond like chris (10:22:08 PM) mib_r651q3: paul_hfx: what are the [ brackets for? (10:22:16 PM) nicou: I did conditional checks for every possible case, I should improve that (10:22:32 PM) chrisconley: yeah i think my conditional still leaves one case out (10:22:41 PM) tooz: if they are all equal ? (10:22:47 PM) mariorz: mib_r651q3: yeah, didnt know you could use parenthesis, brackets are how conds are presented in the book (10:22:51 PM) tooz: x y z ? (10:22:51 PM) mariorz: no? (10:22:53 PM) mib_r651q3: i'm not sure what [ brackets are for, i only used ( and ) (10:23:04 PM) tooz: if you had <= i think that would fix that chris (10:23:16 PM) nicou: chrisconley: you can use <= instead of < and I think your problem would be fixed (10:23:22 PM) mariorz: scratch that (10:23:25 PM) paul_hfx: [ and ] are functionally equivalent to ( and ), but just for readability you can use [ and ] in some cases (10:23:32 PM) chrisconley: ahh yes, thanks! (10:23:41 PM) paul_hfx: but there are only certain places you can use [ and ], IIRC (10:23:46 PM) nicou: yes, it works, I've just tested it (10:23:48 PM) paul_hfx: like [+ 3 2] is invalid (IIRC) (10:23:56 PM) mariorz: is there something like PEP8 for scheme code? (10:23:57 PM) mib_r651q3: ok (10:24:02 PM) mib_r651q3: it makes sense in a cond to separate out the cases (10:24:03 PM) mib_r651q3: thx (10:24:28 PM) Facedown: if theres a native min/max, would the interpreter allow overriding of the identifier? (10:24:42 PM) nicou: this solution is a bit of a hack http://sicp.org.ua/sicp/Exercise1-3 (the first one) (10:24:44 PM) stu8ball: Yes, using define (10:24:45 PM) silentbicycle: facedown: yes (10:25:08 PM) inimino: chrisconley: we have about the same solution (with the same problem) (10:25:35 PM) mib_r651q3: nicou: that's pretty much what i did (10:25:48 PM) mib_r651q3: i agree, hacky, but i tried a few testcases until i was happy with it (10:25:54 PM) mib_r651q3: i like paul_hfx's (10:26:12 PM) silentbicycle: mariorz: I think people just let Emacs indent things. There are naming conventions within the language, e.g. the predicate? functions (10:26:20 PM) Fulax [n=cyprien@pdpc/supporter/student/cnicolas] entered the room. (10:26:24 PM) mib_r651q3: i actually did the second one sicp.org.ua, #1 is really really hacky (10:26:53 PM) stu8ball: #1 is nice. (10:27:55 PM) inimino: I prefer the second one (10:27:55 PM) Fulax left the room (quit: "Leaving"). (10:27:59 PM) tooz: ok are we good on 1.3 ? (10:28:06 PM) EwS: yup (10:28:07 PM) nicou: I think so, moving on to 1.4? (10:28:11 PM) aamar: yes (10:28:24 PM) mib_r651q3: is #1 worth understanding? (10:28:34 PM) offby1 [n=user@q-static-138-125.avvanta.com] entered the room. (10:28:42 PM) offby1 left the room ("ERC Version 5.3 (IRC client for Emacs)"). (10:28:46 PM) stu8ball: What was 1.4? I don't seem to have it saved. (10:28:46 PM) nicou: well let me see, it picks the biggest of the first two (10:29:01 PM) nicou: then the second biggest of the first two (10:29:05 PM) mariorz: silentbicycle: yeah ive noticed the preidcates? and the use of hyphens, is that pretty much it? (10:29:06 PM) silentbicycle: mib_r651q3: #1 is mostly opaque because of the naming, imho. (10:29:43 PM) mib_r651q3: i don't consider it "understandable", not sure why you would add that complexity. #2 makes sense (10:29:51 PM) nicou: if the second biggest of the first two is bigger than the last argument, we call it z (10:29:57 PM) mib_r651q3: i think i'll ignore it. (10:30:06 PM) nicou: else, z will be the last argument (10:30:35 PM) inimino: it's basically a complicated way of finding the largest two numbers (10:30:36 PM) nicou: and then we add up the biggest of the first two, and the biggest of the second and third arguments (10:30:40 PM) silentbicycle: mariorz: there are other conventions (arrow names like sxml->html-string, what OCaml would call html_string_of_sxml), but AFAIK there isn't an explicit scheme style guide. People copy name styles from r5rs, etc. (10:31:20 PM) nicou: it makes a lot of sense, but it's weird to put it that way. The book is about managing complexity anyway, it would be preferable to avoid adding any noise like that. (10:31:34 PM) mariorz: silentbicycle: okk (10:31:37 PM) mib_r651q3: ok, cool... (10:31:40 PM) mib_r651q3: 1.4? (10:31:45 PM) nicou: yes (10:31:49 PM) chrisconley: yeah (10:32:24 PM) inimino: on 1.4, I just wrote "The point of this question is that the operation (either + or -) used in the body of the define is returned by the if. (10:32:26 PM) silentbicycle: being able to do things like 1.4 is a nice consequence of the parenthetical syntax. (10:32:27 PM) inimino: " (10:32:50 PM) mib_r651q3: For 1.4 it shows that the result of an expression can be an operand. So if b is positive, then add b to a. If b is negative, subtract b from a (which is effectively adding, since subtracting a negative is adding) (10:32:55 PM) EwS: silentbicycle: yes, but also of the way scheme handles it, on clisp you need to use funcall (10:33:03 PM) nicou: we have (a-plus-abs-b 1 2) , we can substitute a-plus-abs-b by its definition: ((if (> 2 0) + -) 1 2), then we operate and simplify: (+ 1 2) = 3 (10:33:17 PM) chrisconley: yeah, basically a-plus-abs-b evaluates to (+ a b) or (- a b) (10:33:41 PM) nicou: depending on whether b is negative or positive, respectively (10:34:15 PM) inimino: yep (10:34:19 PM) paul_hfx: so basically, a + abs(b) (as the name implies) (10:34:28 PM) inimino: any questions on 1.4? (10:34:33 PM) nicou: nope (10:34:37 PM) EwS: no (10:34:37 PM) tooz: nop3 (10:34:45 PM) tooz: s/3/e/ (10:34:50 PM) nicou: l33t (10:34:56 PM) mib_r651q3: 1.5? (10:34:59 PM) inimino: moving on then, 1.5... (10:35:01 PM) nicou: yes, moving on (10:35:15 PM) mib_r651q3: applicative order: infinite loop. normal order: 0 (10:35:18 PM) inimino: this one was interesting (10:35:18 PM) trefn [n=tim@71-32-49-106.tcsn.qwest.net] entered the room. (10:35:20 PM) nicou: exactly (10:35:23 PM) inimino: yeah (10:35:24 PM) chrisconley: yep (10:35:24 PM) stu8ball: same (10:35:29 PM) mib_r651q3: inimino: was interesting for sure (10:35:37 PM) EwS: yup (10:35:40 PM) tooz: yeah (10:35:41 PM) chrisconley: it keeps evaluating (p) right? (10:35:47 PM) mib_r651q3: chrisconley: ya i think so. (10:35:47 PM) stu8ball: yeah (10:35:48 PM) inimino: mib_r651q3: actually, I wrote the reverse of that (10:35:58 PM) nicou: because in the applicative order, the argument (p) will have to be evaluated before applying, and since p is defined as p, it will yield an infinite loop (10:36:08 PM) mib_r651q3: inimino: really? (10:36:17 PM) mib_r651q3: in normal order the (p) will never be evaluated as far as i know (10:36:26 PM) nicou: if we evaluate the expression in normal order, the p won't ever be evaluated (10:36:26 PM) inimino: yeah, I guess I was wrong (10:36:47 PM) mariorz: i concur (10:36:55 PM) tooz: as do i (10:36:56 PM) mib_r651q3: for normal order, re-write it out without evaluating the (p) (10:36:59 PM) paul_hfx: yup (10:37:03 PM) mib_r651q3: it just sits there, waiting to be evaluated if necessary (10:37:13 PM) inimino: yeah, I reversed the terms in my answer (10:37:18 PM) mib_r651q3: cool.... (10:37:19 PM) mib_r651q3: 1.6? (10:37:27 PM) nicou: any questions? (10:38:16 PM) inimino: yes (10:38:25 PM) inimino: did anyone look into the history of these terms? (10:38:37 PM) nicou: normal order and applicative order? (10:38:39 PM) tooz: what terms ? (10:38:40 PM) mib_r651q3: nope, what is it? (10:38:43 PM) inimino: nicou: yes (10:38:58 PM) nicou: I would guess that applicative order stands for applying before evaluating, of course, as for "normal", I dunno (10:39:09 PM) inimino: I find it annoying when terms such as those are introduces without explanation of the history (10:39:14 PM) stu8ball: I didn't. 'Normal' just seems to mean weird stuff in sciences and mathematics, so I didn't question it. :P (10:39:32 PM) inimino: heh, alright (10:39:38 PM) tooz: like the perfectly normal beast in mostly harmless (10:39:39 PM) nicou: inimino: you could call it lazy or non-strict, that makes more sense I ugess (10:39:44 PM) nicou: guess (10:39:45 PM) stu8ball: lol (10:39:47 PM) stu8ball: tooz++ (10:39:58 PM) inimino: nicou: yeah (10:40:07 PM) Facedown: didnt some peeps do these in Haskell or whatever language (10:40:10 PM) Facedown: if so, can you link to it (10:40:29 PM) inimino: I'll look it up on Wikipedia and see if I can find out more. (10:40:35 PM) inimino: anyway, 1.6. (10:40:35 PM) nicou: http://en.wikipedia.org/wiki/Call-by-value#Call_by_value (10:40:57 PM) nicou: It doesn't say much about the term "normal", though. (10:41:23 PM) nicou: but there are a couple more evaluation strategies, like a memoized lazy evaluation (10:41:30 PM) inimino: yeah (10:41:50 PM) tooz: doesn't 1.6 have a similar problem as 1.5 because if is a special case ? (10:41:54 PM) chrisconley: Facedown: there's someone posting haskell solutions at http://hn-sicp.pbwiki.com/Exercises (10:42:10 PM) nicou: tooz: yes, it's a similar problem (10:42:12 PM) tooz: hmm i didn't actually write down the answer for this one (10:42:14 PM) jamie_ca: tooz: similar, yeah. (10:42:16 PM) tooz: i forgot to (10:42:38 PM) chrisconley: so with 1.6, can you never call a recursive procedure in a cond statement? (10:43:22 PM) chrisconley: do you always have to use if? (10:43:26 PM) mariorz: if is special form and doenst use applicative order? (10:43:27 PM) paul_hfx: chrisconley: cond is ok, because it's not a function (10:43:39 PM) paul_hfx: if and cond are special (10:43:48 PM) silentbicycle: it's a special form that doesn't evaluate its then-clause or else-clause unless needed. (10:43:52 PM) jamie_ca: yeah, I think cond is supposed to only run the first one that matches (10:44:00 PM) EwS: exactly (10:44:00 PM) nicou: well, the key is that sqrt-iter calls new-if, which has as one of its argument sqrt-iter, since it's applicative order evaluation, new-if has to have its arguments evaluated before itself, but its arguments depend on new-if, so it yields an infinite loop (10:44:00 PM) tooz: so if and cond are lazy (10:44:02 PM) jamie_ca: Alyssa's problem stems from wrapping the cond in a function (10:44:09 PM) inimino: http://mjclement.com/projects/2009/SICP/chap_1/1.6 (10:44:12 PM) paul_hfx: (fwiw, (and ...) and (or ...) are special forms also) (10:44:23 PM) mib_r651q3: infinite recursion... (10:44:34 PM) nicou: cond stops execution at the first one that matches, true, and if only executes the consequent if the predicate yields true, or the alternative if it yields false (10:44:52 PM) nicou: they are special forms, do not work like the applicative order (10:44:52 PM) inimino: (I hope someone will point out if my answer was wrong) (10:45:02 PM) chrisconley: i guess i'm not wrapping my head around the difference of calling cond directly and wrapping it in a function (10:45:16 PM) tooz: but new-if being a procedure will always execute the consequent ? (10:45:22 PM) mib_r651q3: inimino: i believe you are correct (10:45:27 PM) paul_hfx: inimino: looks right (10:45:42 PM) mib_r651q3: chrisconley: that new-if is a regular function (10:45:49 PM) chrisconley: ahh i get it (10:45:53 PM) nicou: tooz: it will evaluate the consequent because it's not a special form, always (10:45:54 PM) mib_r651q3: so the arguments are all evaluated (10:45:54 PM) chrisconley: duh-hehe (10:45:58 PM) mib_r651q3: regular if is spcial... (10:46:00 PM) tooz: got it (10:46:03 PM) mib_r651q3: i think that's the point here (10:46:04 PM) EwS: (10:46:33 PM) EwS: exactly (10:46:39 PM) nicou: ok, are we good? (10:46:43 PM) mib_r651q3: any questions? (10:46:44 PM) tooz: i'm good (10:46:45 PM) chrisconley: yeah good here (10:46:46 PM) EwS: 1.7? (10:47:02 PM) inimino: 1.7! (10:47:04 PM) nicou: 1.7 (10:47:19 PM) garodin [n=gar@bas1-montrealak-1128547499.dsl.bell.ca] entered the room. (10:47:43 PM) inimino: http://mjclement.com/projects/2009/SICP/chap_1/1.7 (10:47:53 PM) mib_r651q3: http://sicp.org.ua/sicp/Exercise1-7 - correct answer is in the comments (10:48:08 PM) stu8ball: http://sprunge.us/TdaE (10:48:31 PM) chrisconley: http://github.com/chrisconley/sicp-exercises/blob/4919e2e8e72e1ba246aedd4d8b2f9574666f7e9f/chapter1/ex1-07b.ss (10:48:39 PM) trefn left the room (quit: ). (10:48:44 PM) nicou: yes, all are fine (10:49:16 PM) nicou: what I did was pass only the current guess and the x, so that we could compute the next guess and find if the difference is "good enough" (10:49:30 PM) mib_r651q3: good enough should be something like this (10:49:33 PM) nicou: instead of the current guess and the previous guess (10:49:42 PM) mib_r651q3: http://www.mibbit.com/pb/Mu1b7P (10:49:53 PM) mariorz: (define (my-good-enough? guess x) (< (abs (- (square guess) x)) (abs (* x .0000000001)))) (10:50:18 PM) mariorz: this also fixes the problems without passing the old-gess (10:50:27 PM) nicou: (define (change-is-small? guess x) (10:50:27 PM) nicou: (< (abs (/ (- (improve guess x) guess) guess)) (10:50:28 PM) jamie_ca: I did like mariorz, just modify good-enough? to work on a scaled value of x, rather than an absolute value (10:50:57 PM) pasbesoin [i=62d4b524@gateway/web/ajax/mibbit.com/x-98e85483d4efba56] entered the room. (10:51:05 PM) inimino: I thought about that (10:51:12 PM) aamar: chrisconley: the exercise wants a version of good-enough that looks for small differences in guess vs. previous-guess compared to the value of guess (10:51:22 PM) mib_r651q3: i like this suggestion as well (10:51:40 PM) mib_r651q3: (define sqrt (square-root-iter (improve 1.0 x) 1.0 x))) (10:51:47 PM) tooz: http://github.com/emkay/sicp-exercises/blob/e995663dada1a736fc0c9a35f02b96e57791fe17/chapter1/ex1-7.ss (10:51:55 PM) mib_r651q3: where (improve 1.0 x) is the new guess assuming 1.0 was the original guess (10:52:00 PM) chrisconley: aamar: oops, missed that extra detail, thanks! (10:52:01 PM) paul_hfx: I used (< (abs (- 1 (/ x y))) 0.0001) where x is the guess and y is the last guess (10:52:17 PM) inimino: but then you compute a guess that you don't return (10:53:01 PM) nicou: yes, but we are not so interested in procedures effectiveness now (10:53:24 PM) inimino: true (10:53:58 PM) nicou: 1.8? (10:54:02 PM) mib_r651q3: i think everyone gets this question, just a few interpretations... (10:54:04 PM) tooz: 1.8 (10:54:06 PM) mib_r651q3: ya 1.8 (10:54:08 PM) inimino: yeah (10:54:09 PM) aamar: yes, 1.8 (10:54:30 PM) inimino: http://mjclement.com/projects/2009/SICP/chap_1/1.8 (10:54:32 PM) stu8ball: 1.8 is just the same thing with a different 'improve' (10:54:36 PM) stu8ball: for me (10:54:40 PM) tooz: yeah (10:54:41 PM) inimino: yep (10:54:41 PM) mariorz: yeah (10:54:43 PM) tooz: the only thing (10:54:43 PM) mib_r651q3: yup (10:54:51 PM) tooz: is i think i had the order of operations wrong (10:54:52 PM) paul_hfx: me as well http://mibbit.com/pb/FajiQO (10:54:53 PM) dmnd_ left the room (quit: ). (10:54:54 PM) nicou: http://pastebin.com/m5a252f1f (10:54:55 PM) mib_r651q3: i made mine with all (defines) inside the (define cuberoot ) (10:54:59 PM) tooz: but i still get the correct answer when testing (10:54:59 PM) mariorz: (define (cube-improve guess x) (/ (+ (/ x (sq guess)) (* guess 2)) 3)) (10:55:02 PM) mib_r651q3: i.e. lexical scoping (10:55:04 PM) tooz: http://github.com/emkay/sicp-exercises/blob/e995663dada1a736fc0c9a35f02b96e57791fe17/chapter1/ex1-8.ss (10:55:06 PM) chrisconley: http://github.com/chrisconley/sicp-exercises/blob/4919e2e8e72e1ba246aedd4d8b2f9574666f7e9f/chapter1/ex1-08.ss (10:55:23 PM) aamar: http://mibbit.com/pb/UijxWA (10:55:26 PM) chrisconley: mib_r651q3: yeah so did i (10:55:39 PM) stu8ball: It was during one of these root ones, the square root one I think, that you can't call * with more than two arguments. (10:55:53 PM) stu8ball: that I discovered that you can't* (10:56:09 PM) mariorz: mib_r651q3: can i see? (10:56:20 PM) mib_r651q3: mariorz: i dont have it on me, i'm not at home (10:56:26 PM) mib_r651q3: but the ones pasted here are identical (10:56:32 PM) nicou: so the only difference is the improve procedure: (/ (+ (/ x (square guess)) (* 2 guess)) (10:56:37 PM) mariorz: ah (10:56:38 PM) mib_r651q3: oh wait, they aren't (10:56:39 PM) mib_r651q3: one sec (10:56:42 PM) silentbicycle: http://pastebin.com/d3b976cee (10:57:10 PM) ebiester: you have to change good-enough? as well - cube instead of square (10:57:13 PM) mib_r651q3: i dont see any pasted definitions in here using lexical scoping (10:57:20 PM) inimino: right, ebiester (10:57:22 PM) chrisconley: mariorz: i scoped my defines if you want to take a look (though my good_enough? procedure isn't correct) (10:57:26 PM) silentbicycle: stu8ball: you should be able to call * with more than two args (10:57:31 PM) mib_r651q3: but basically all the (defines) are inside the (define cuberoot x) definition. (10:57:32 PM) stu8ball: oh. (10:57:39 PM) stu8ball: I was using scheme48 at the time. (10:57:42 PM) mib_r651q3: the book talks about it... (10:58:01 PM) nicou: mib_r651q3: yes, the packaged definitions (10:58:03 PM) mariorz: chrisconley: yeah im unsure what you guys mean (10:58:03 PM) stu8ball: oh. Works now. (10:58:04 PM) silentbicycle: stu8ball: I just tried it in scheme48... hm. (10:58:17 PM) chrisconley: http://github.com/chrisconley/sicp-exercises/blob/4919e2e8e72e1ba246aedd4d8b2f9574666f7e9f/chapter1/ex1-08.ss (10:58:21 PM) mib_r651q3: hang on, i should be able to hack it up (without testing) (10:58:32 PM) nicou: ebiester: you're right (10:58:33 PM) silentbicycle: it'd arguably be more conceptually elegant to use fold over a list and leave * as a binary function, but whatever (10:58:37 PM) mib_r651q3: chrisconley: that's what i meant :) (10:58:43 PM) silentbicycle: it's not like scheme has automatic currying either (10:59:06 PM) mib_r651q3: silentbicycle: what are you talking about? (10:59:09 PM) inimino: but by analogy with +... (10:59:13 PM) stu8ball: All I heard there was bla bla bla maths and CS. (10:59:15 PM) stu8ball: :) (10:59:18 PM) stu8ball: I'll learn someday. (10:59:23 PM) mib_r651q3: i'm curious (10:59:24 PM) nicou: silentbicycle: but the n-product is syntactic sugar that comes in handy (10:59:24 PM) mariorz: ah yeah ok (10:59:32 PM) inimino: anyway, that wasn't the point of the exercise ;-) (10:59:47 PM) inimino: I assumed people would use or define cube (10:59:48 PM) silentbicycle: ok. the way scheme does it here is (* 1 2 3 4 5) becomes (* 1 (* 2 3 4 5)) -> ... (* 1 (* 2 (* 3 (* 4 5)))), I assume (10:59:50 PM) mariorz: chrisconley: cool, thx (10:59:55 PM) Facedown left the room (quit: Connection timed out). (11:00:05 PM) nicou: silentbicycle: or maybe it's a foldl ;) (11:00:08 PM) stu8ball: But is * not a primitive? (11:00:21 PM) mib_r651q3: oh, i thought (* ) takes a variable number of arguments (11:00:25 PM) mib_r651q3: without considering the implementation (11:00:30 PM) silentbicycle: whereas in ocaml or haskell * would explicitly be a binary function and that'd be called "product" or something, which would multiply a list (11:00:49 PM) nicou: silentbicycle: right. scheme is less mathy (11:00:54 PM) mib_r651q3: k... (11:00:57 PM) silentbicycle: and be built on a fold, and currying would mean that (* 6) would actually return a function that (11:01:14 PM) nicou: (lambda (x) (* x 6)) (11:01:15 PM) silentbicycle: multiplies its sole argument by six. (* 2) would return a doubling function. etc. (11:01:16 PM) inimino: once you have (+ a b c) it would be odd not to have the analogue for multiplication (11:01:36 PM) mib_r651q3: i don't understand "fold" and "currying" yet, but this is kinda off topic. (11:01:43 PM) silentbicycle: agreed, sorry. (11:01:45 PM) inimino: yes (11:01:54 PM) nicou: you're right. (11:01:56 PM) nicou: so (11:01:57 PM) mib_r651q3: thanks for the explanation attempt, but ya i'll pick it up elsewhere in this book i hope (11:02:05 PM) mib_r651q3: so, done? (11:02:05 PM) silentbicycle: right (11:02:07 PM) nicou: in 2.3 (11:02:08 PM) silentbicycle: in chapter 2 (11:02:10 PM) chrisconley: any questions on 1.8? (11:02:14 PM) mib_r651q3: thx (11:02:17 PM) nicou: they talk about foldr and foldl (11:02:28 PM) tooz: nope (11:02:35 PM) nicou: we're done? (11:02:40 PM) chrisconley: how was the pace for this section? (11:02:41 PM) tooz: so when is the next meeting ? (11:02:41 PM) mib_r651q3: ya (11:02:44 PM) inimino: I guess we're done :-) (11:02:50 PM) chrisconley: should we stick with two weeks/section (11:02:51 PM) chrisconley: ? (11:02:53 PM) nicou: anyone has any questions on the whole section? (11:02:56 PM) mib_r651q3: how was everyone with # of problems in given time? i imagine the pace picks up... (11:02:58 PM) EwS: it was really good (11:03:00 PM) tooz: christ that sounds good to me (11:03:02 PM) tooz: err (11:03:05 PM) tooz: chris (11:03:08 PM) inimino: I think the pace is good, esp once it picks up (11:03:11 PM) chrisconley: yeah i think it picks up (11:03:14 PM) tooz: yeah (11:03:19 PM) nicou: so it took us about an hour, but this is section 1.1, it will get much harder (11:03:22 PM) paul_hfx: yeah, that sounds like a good pace (11:03:27 PM) chrisconley: cool, we'll stick with two weeks (11:03:29 PM) nicou: so (11:03:29 PM) mib_r651q3: so do we wanna keep it at 2 weeks per .1 section? (11:03:31 PM) nicou: in two weeks (11:03:34 PM) nicou: same time? (11:03:36 PM) mariorz: sounds good (11:03:41 PM) tooz: yeah this is a good time (11:03:44 PM) mib_r651q3: works for me... (11:03:44 PM) paul_hfx: works for me (11:03:48 PM) mib_r651q3: thanks everyone (11:03:50 PM) EwS: is it not next week ? (11:03:50 PM) chrisconley: is anybody interested in meeting in one week? (11:03:53 PM) EwS: for section 1.2? (11:03:55 PM) tooz: this is the most aggreable group ever (11:03:59 PM) inimino: we should probably ask on the mailing list about people who didn't make the meeting because of the time (11:04:00 PM) paul_hfx: out of curiosity, how many people are actually in PST? (11:04:05 PM) tooz: i am (11:04:07 PM) EwS: me (11:04:09 PM) chrisconley: i'm in est (11:04:10 PM) tooz: in PST rather (11:04:10 PM) stu8ball: Or rather, keep it at 2 weeks per 0.1 sections until someone feels the need to lengthen/whatever it. (11:04:10 PM) mib_r651q3: chrisconley: i would be... but if the pace picks up then i don't wanna overdo it and end up quitting. (11:04:12 PM) ebiester: I'm in MST, close enough (11:04:19 PM) nicou: should we conduct some kind of poll in the mailinglist? (11:04:19 PM) silentbicycle: yeah, probably some people won't show up until later (11:04:21 PM) mariorz: pst+2 (11:04:31 PM) ebiester: pst + 1 (11:04:31 PM) nicou: about the time for the meetings? (11:04:32 PM) paul_hfx: cool, bay area mostly? I'm in SF (11:04:34 PM) chrisconley: mib_r651q3: cool (11:04:35 PM) mikem: PST+17 here :S (11:04:39 PM) chrisconley: i'm est (11:04:42 PM) EwS: paul_hfx: san francisco too (11:04:42 PM) silentbicycle: EST here, this time is good for me (11:04:43 PM) db_databus: PST (11:04:55 PM) garodin left the room (quit: Remote closed the connection). (11:04:58 PM) inimino: PST+1 here too (11:05:07 PM) mib_r651q3: mountain here, Canada... (11:05:21 PM) mib_r651q3: this time works well, close enough to PST (11:05:23 PM) tooz: ok i am off (11:05:23 PM) aamar: sf here (11:05:23 PM) mib_r651q3: PST+1 (11:05:25 PM) nicou: I think we should post a poll somewhere so that we can find more accurately the time for the meetings that suits most people (11:05:31 PM) tooz: later peoples (11:05:32 PM) stu8ball: I'd say we should have the poll thing in here rather than the list, since the only people affected by how often the meetings are are going to be the people who come to the meetings anyway. (11:05:33 PM) chrisconley: nicou: agreed (11:05:40 PM) garodin [n=gar@bas1-montrealak-1128547499.dsl.bell.ca] entered the room. (11:05:41 PM) inimino: nicou: yeah (11:05:54 PM) silentbicycle: agreed. (11:05:55 PM) nicou: great, I'll see what I can do (11:05:55 PM) mib_r651q3: so do we keep the time or change it? (11:05:59 PM) chrisconley: this is a good time for everybody here because we're all here :) (11:06:00 PM) inimino: obviously there's some little problem of selection bias in polling at the meeting ;-) (11:06:00 PM) mib_r651q3: keep? (11:06:11 PM) stu8ball: heh (11:06:13 PM) mib_r651q3: inimino: haha a slight problem (11:06:14 PM) silentbicycle: two weeks is probably good, because after a few sections it'll get harder (11:06:22 PM) chrisconley: would anybody not be able to make it if we pushed up the meeting time ? (11:06:30 PM) stu8ball: I wouldn't. (11:06:31 PM) silentbicycle: and that's probably more the pace we want to keep (11:06:31 PM) ebiester: Normally, I'd prefer earlier or later myself. (11:06:31 PM) mib_r651q3: silentbicycle: ya that's what i'm thinking as well (11:06:38 PM) nicou: btw, could anybody tell me what I have to do to get in the mailing list? (11:06:46 PM) inimino: "pushed up" meaning made earlier? (11:06:48 PM) mariorz: push up is later? (11:06:49 PM) stu8ball: One hour earlier than 4 PST would suit me best, but that's just me. (11:06:49 PM) mib_r651q3: nicou: go to the google groups page and subscribe i believe (11:06:54 PM) chrisconley: groups.google.com/group/hacker-news-reads-sicp (11:07:02 PM) stu8ball: I assumed pushed up meant later. (11:07:04 PM) chrisconley: sorry, push up is earlier (11:07:08 PM) stu8ball: oh (11:07:12 PM) stu8ball: Then pushing up suits me. (11:07:14 PM) nicou: oh, thanks, I've never been in a mailing list, I thought the google group was something different (11:07:24 PM) mib_r651q3: if the time changes, will someone please send out an e-mail? i'd be okay with a bit earlier or a bit later... i'm pretty free on Sundays. (11:07:35 PM) inimino: ("pushed back" would be later, but I think these might be Americanisms) (11:07:36 PM) mib_r651q3: nicou: you can set it to email you, when you subscribe (11:07:41 PM) chrisconley: yeah, you can just join the group and it should ask you how much email you want to get (11:07:46 PM) mib_r651q3: later all (11:07:49 PM) mib_r651q3 left the room. (11:07:50 PM) nicou: mib_r651q3: thanks a lot (11:07:57 PM) inimino: you can also subscribe using only email (11:08:03 PM) nicou: great, thanks (11:08:20 PM) nicou: I think that for section 1.2 two weeks should be more than enough (11:08:23 PM) chrisconley: nicou: did you say earlier you would put the meeting log up somewhere? (11:08:51 PM) nicou: so we'll see in two weeks, and I'll post a question about the time, I would like to know who created ##SICP too (11:09:12 PM) nicou: chrisconley: I'll upload it to my website and post a link in the mailing list (11:09:14 PM) inimino: though it's not well documented, I think the address is hacker-news-reads-sicp-subscribe@googlegroups.com (11:09:15 PM) stu8ball: chrisconley did (11:09:25 PM) nicou: stu8ball: thanks (11:09:26 PM) chrisconley: nicou: thanks! (11:09:34 PM) nicou: chrisconley: no prob (11:09:52 PM) chrisconley: stu8ball: i didn't create ##SICP :) (11:09:58 PM) stu8ball: oh (11:10:04 PM) stu8ball: My memory must suck. (11:10:09 PM) chrisconley: i created ##hn-sicp and royally screwed it up - hehe (11:10:11 PM) stu8ball: But you did create ##hn-sicp ? (11:10:13 PM) stu8ball: ah (11:10:14 PM) stu8ball: yes (11:10:23 PM) chrisconley: then we moved to #SICP ( i think vixey set that up) (11:10:40 PM) chrisconley: i'm not sure how we got from #SICP to ##SICP :) (11:10:51 PM) stu8ball: I joined #SICP by accident the other day. There were still a couple of people in there. (11:10:54 PM) nicou: who uses #SICP? (11:11:07 PM) nicou: > The topic for #SICP is: MOVED TO ##SICP (11:11:08 PM) stu8ball: People who don't turn their computers off. (11:11:08 PM) nicou: lol (11:11:17 PM) inimino: freenode reserves #xxx for the "official" xxx channel (11:11:26 PM) stu8ball: Hot. (11:11:38 PM) ***inimino thinks a "foo" would have been more apropos (11:11:51 PM) nicou: oh I see. I don't mind the double sharp at all :) (11:12:01 PM) chrisconley: ok guys, off to dinner (11:12:06 PM) nicou: or octothorpe or whatever (11:12:08 PM) nicou: later (11:12:12 PM) stu8ball: hash (11:12:14 PM) paul_hfx: later nicou (11:12:18 PM) chrisconley: see you in two weeks here and on the google group before then - see ya! (11:12:23 PM) inimino: later chrisconley, thanks (11:12:24 PM) stu8ball: bye (11:12:44 PM) nicou: hash , number sign, crosshatch, fence, gate ,grid ,gridlet, mesh, etc (11:12:55 PM) nicou: ok, thanks all, see ya in two weeks