2009 Jun 22 00:02:38 hey 2009 Jun 22 00:02:48 hey inimino 2009 Jun 22 00:02:50 mariorz: you around? 2009 Jun 22 00:03:12 yea, hey guys 2009 Jun 22 00:03:31 hey 2009 Jun 22 00:04:07 should we get started? 2009 Jun 22 00:04:23 yeah sounds good 2009 Jun 22 00:04:27 ok 2009 Jun 22 00:05:08 great 2009 Jun 22 00:05:46 alright 2009 Jun 22 00:06:09 http://inimino.org/~inimino/projects/2009/SICP/chap_3/3.1 2009 Jun 22 00:06:12 any good pastie-type resource with scheme syntax highlighting? 2009 Jun 22 00:06:19 hm 2009 Jun 22 00:06:39 http://pastie.org/519683 2009 Jun 22 00:07:46 http://github.com/mariorz/sicp/blob/d28f6dec513bd9b966f36cebb5ec16cca89a399f/3.ss#L9 2009 Jun 22 00:08:14 bib making some tea 2009 Jun 22 00:08:57 same answers 2009 Jun 22 00:09:14 yeah, same 2009 Jun 22 00:10:31 3.2 ? 2009 Jun 22 00:11:01 ok 2009 Jun 22 00:11:22 http://pastie.org/519685 -- 3.2 2009 Jun 22 00:11:30 http://inimino.org/~inimino/projects/2009/SICP/chap_3/3.2 2009 Jun 22 00:14:28 I forgot to handle reset-count 2009 Jun 22 00:14:29 ok, yours and mine are the same except for reset 2009 Jun 22 00:14:39 ok all seem alike except aamar is missing reset 2009 Jun 22 00:14:41 yea 2009 Jun 22 00:14:43 yeah 2009 Jun 22 00:14:55 http://github.com/mariorz/sicp/blob/d28f6dec513bd9b966f36cebb5ec16cca89a399f/3.ss#L37 2009 Jun 22 00:15:17 3.3? 2009 Jun 22 00:15:21 sure 2009 Jun 22 00:15:31 http://inimino.org/~inimino/projects/2009/SICP/chap_3/3.3 2009 Jun 22 00:15:54 http://github.com/mariorz/sicp/blob/d28f6dec513bd9b966f36cebb5ec16cca89a399f/3.ss#L65 2009 Jun 22 00:16:48 http://pastie.org/519689 - 3.3 2009 Jun 22 00:16:55 mariorz: that looks the same 2009 Jun 22 00:17:15 though github is doing something weird to the layout apparently 2009 Jun 22 00:17:21 man github still sucks with the identation 2009 Jun 22 00:18:07 pastie.org is slow to load here 2009 Jun 22 00:18:25 there it goes 2009 Jun 22 00:18:39 hm, will try pastebin instead... 2009 Jun 22 00:19:28 so in the password-mismatch case, if you return just "Incorrect password" it will fail, because it expects to call a function with one argument for the amount. 2009 Jun 22 00:19:53 yeah 2009 Jun 22 00:20:51 good point 2009 Jun 22 00:21:14 so I guess the use of lambda, or an error, are better there 2009 Jun 22 00:21:39 alright, 3.4? 2009 Jun 22 00:21:45 ah 2009 Jun 22 00:22:12 ok 2009 Jun 22 00:22:22 http://scheme.pastebin.com/m64e8cecf -- 3.4 2009 Jun 22 00:22:52 pastebin's colors can be hard to read; let me know if it causes problems. 2009 Jun 22 00:23:03 http://inimino.org/~inimino/projects/2009/SICP/chap_3/3.4 2009 Jun 22 00:23:24 http://pastebin.com/m2b7dfd3b 2009 Jun 22 00:24:29 heh, yeah pastebin is ugly, but nothing Ctrl-+ can't fix 2009 Jun 22 00:26:37 hm, mine fails on the "consecutive times" part 2009 Jun 22 00:26:55 it just calls the cops after 7 wrong attempts 2009 Jun 22 00:27:13 hmm 2009 Jun 22 00:27:21 mine does too 2009 Jun 22 00:27:21 same with mariorz 2009 Jun 22 00:28:01 easily fixed :) 2009 Jun 22 00:28:03 yeah 2009 Jun 22 00:28:15 good catch though 2009 Jun 22 00:28:29 alright, 3.5? 2009 Jun 22 00:29:01 ooh, this one was fun 2009 Jun 22 00:29:17 http://scheme.pastebin.com/m66c7a9 -- 3.5 2009 Jun 22 00:29:22 http://inimino.org/~inimino/projects/2009/SICP/chap_3/3.5 2009 Jun 22 00:29:30 http://pastebin.com/m74462cec 2009 Jun 22 00:29:50 damn 2009 Jun 22 00:30:01 i forgot to find pi 2009 Jun 22 00:30:45 hmm 2009 Jun 22 00:30:53 looks I didnt get this one at all 2009 Jun 22 00:31:59 I think you were right to multiply by area -- I should have included that. 2009 Jun 22 00:33:21 i forgot to get the the absolute 2009 Jun 22 00:33:53 inimino's looks otherwise similar to what I did 2009 Jun 22 00:33:55 but complete 2009 Jun 22 00:34:16 yeah these all look similar 2009 Jun 22 00:35:06 and yeah aamar needs to mult by area 2009 Jun 22 00:35:12 I was kind if surprised how many trials it took to get the first few digits 2009 Jun 22 00:35:15 fixed: http://scheme.pastebin.com/m5b15d67a 2009 Jun 22 00:35:27 i didnt test mine 2009 Jun 22 00:35:44 inimino: many? 2009 Jun 22 00:35:47 probably okay to assume x2 > x1, y2> y1, as the random-in-range call does that anyway 2009 Jun 22 00:35:50 this is not a recommended method for calculating the first 1000 digits of pi ;) 2009 Jun 22 00:36:18 mariorz: yeah I used 1 million and only got 2009 Jun 22 00:36:28 3.14292 2009 Jun 22 00:36:36 mariorz: may be a problem with the way you use reg-test 2009 Jun 22 00:36:37 which isn't very close 2009 Jun 22 00:36:50 aamar: what is it? 2009 Jun 22 00:37:10 monte-carlo needs a function called 2009 Jun 22 00:37:28 but you are invoking reg-test, which in turn invokes p 2009 Jun 22 00:37:49 sorry, what I mean is that monte-carlo needs a function passed in as its second argument 2009 Jun 22 00:38:16 needs more lambda :) 2009 Jun 22 00:38:27 so p will be evaluated, and instead of passing a function, you'll just pass in #t or #f 2009 Jun 22 00:38:30 ok youre right 2009 Jun 22 00:38:42 mine will just evaluate the expression 2009 Jun 22 00:39:18 yeah, it looks like reg-test should return a lambda 2009 Jun 22 00:39:42 then I think that solution looks correct 2009 Jun 22 00:39:44 like this? 2009 Jun 22 00:39:45 http://pastebin.com/m79d057da 2009 Jun 22 00:40:05 I think that does it. 2009 Jun 22 00:40:20 probably help to spell "monte-carlo" correctly ... 2009 Jun 22 00:40:23 -*- offby1 whistles innocently 2009 Jun 22 00:40:27 maybe an en extra paren at the end too 2009 Jun 22 00:40:27 :P 2009 Jun 22 00:41:01 hey offby1 2009 Jun 22 00:41:22 but yeah, ok I think those are all workable now 2009 Jun 22 00:41:28 3.6? 2009 Jun 22 00:41:50 ok 2009 Jun 22 00:42:04 http://scheme.pastebin.com/m30f681e8 -- 3.6 2009 Jun 22 00:42:06 http://inimino.org/~inimino/projects/2009/SICP/chap_3/3.6 2009 Jun 22 00:43:04 http://scheme.pastebin.com/m65ad1102 2009 Jun 22 00:44:06 inimino -- I think yours and mine works similarly 2009 Jun 22 00:44:16 yeah, agreed 2009 Jun 22 00:44:56 actually I think they are the same but for variable names 2009 Jun 22 00:45:17 i think mine is wrong as it's not working 2009 Jun 22 00:45:26 mariorz -- I'm not sure how the random-seed part works 2009 Jun 22 00:45:27 not sure what was thinking, think i meant to get back ot this one 2009 Jun 22 00:45:33 ok 2009 Jun 22 00:46:10 i remember some primitives werent available in mzscheme and started messing with this other ones 2009 Jun 22 00:46:36 not sure whats that number even 2009 Jun 22 00:46:40 maxint maybe 2009 Jun 22 00:46:41 mariorz: I think you're setting the seed in every 'generate 2009 Jun 22 00:47:37 yeah, that's something like 2^31 - 1 2009 Jun 22 00:48:45 if you moved random-seed out of the cond I think it's basically right 2009 Jun 22 00:50:15 also want to change the (random 214...) call to something like (rand-update x) 2009 Jun 22 00:50:33 the reset branch looks right as is 2009 Jun 22 00:50:47 there is no rand-update i think 2009 Jun 22 00:51:25 i need to take a better look at the mzschme primitives 2009 Jun 22 00:51:47 I also had no rand-update primitive, but the text seemed to assume one, so I created a fake one in my answer. 2009 Jun 22 00:51:48 maybe it's initialized the first time you use it 2009 Jun 22 00:52:23 yeah, I just assumed one 2009 Jun 22 00:52:35 well tis clearly wrong as it doesnt work 2009 Jun 22 00:52:38 (and didn't test my code) 2009 Jun 22 00:53:46 MIT/GNU Scheme doesn't have these either, I think the text suggested that they wouldn't be there 2009 Jun 22 00:54:29 should we continue on? 2009 Jun 22 00:54:44 yeah, ill recheck later 2009 Jun 22 00:54:47 yeah, sure 2009 Jun 22 00:55:02 http://inimino.org/~inimino/projects/2009/SICP/chap_3/3.7 2009 Jun 22 00:55:47 http://pastebin.com/m44052b0b 2009 Jun 22 00:56:01 again I guess mine should return a lambda to accommodate the expected manner of use 2009 Jun 22 00:57:23 http://scheme.pastebin.com/m238d7be5 -- 3.7 2009 Jun 22 00:58:20 wow 2009 Jun 22 00:58:33 I think inimino's approach is the expected solution here. 2009 Jun 22 00:58:41 I remember that one! 2009 Jun 22 00:58:58 mariorz and I did something similar 2009 Jun 22 00:59:35 I took the "you may want to..." as an invitation not to, I guess 2009 Jun 22 00:59:56 heh 2009 Jun 22 01:00:05 -*- mariorz golf claps for inimino 2009 Jun 22 01:00:20 ha 2009 Jun 22 01:00:27 hehe 2009 Jun 22 01:01:20 I like the use of setting passwork-ok? to an appropriate function 2009 Jun 22 01:02:26 I think that's the first example of using mutable state to store a function, which is an elegant solution 2009 Jun 22 01:02:43 experiment; seemed to work okay 2009 Jun 22 01:03:44 ok, 3.8? 2009 Jun 22 01:03:49 ok 2009 Jun 22 01:03:58 http://inimino.org/~inimino/projects/2009/SICP/chap_3/3.8 2009 Jun 22 01:04:26 http://pastebin.com/m322e62ee 2009 Jun 22 01:04:50 http://pasternak.superalloy.nl/pastes/2379 2009 Jun 22 01:05:20 ;; * _ Exercise 3.8 2009 Jun 22 01:05:20 (define nil ()) 2009 Jun 22 01:05:22 (define f 2009 Jun 22 01:05:23 (let ((state nil)) 2009 Jun 22 01:05:26 (lambda (signal) 2009 Jun 22 01:05:28 (if (eq? state nil) 2009 Jun 22 01:05:29 (set! state signal)) 2009 Jun 22 01:05:31 (/ state 2)))) 2009 Jun 22 01:05:34 (+ (f 0) (f 1)) ; => 1 2009 Jun 22 01:05:36 sorry, messing around with a new irc client 2009 Jun 22 01:05:47 better watch out, lest I get banned from freenode. 2009 Jun 22 01:06:31 coincidently I had my first aproximation with freenode politics 2009 Jun 22 01:06:37 profoundly name 2009 Jun 22 01:06:39 lame* 2009 Jun 22 01:07:01 ok, aamar's works 2009 Jun 22 01:07:16 oh yeah, you did used to use mibbit didn't you? 2009 Jun 22 01:07:52 er whoops, that was mariorz's I was reading 2009 Jun 22 01:08:13 nah but I know the developer a little bit 2009 Jun 22 01:08:16 anyway I believe it works, and it looks like we had about the same idea 2009 Jun 22 01:08:19 oh, axod? 2009 Jun 22 01:08:24 I did used to use mibbit 2009 Jun 22 01:08:26 snooped on the discussions 2009 Jun 22 01:08:49 yah him 2009 Jun 22 01:09:04 hangs out at #startups 2009 Jun 22 01:09:41 looks like aamar's should work too 2009 Jun 22 01:09:58 yeah, that whole mibbit/freenode thing was interesting 2009 Jun 22 01:10:08 I don't have an opinion on it 2009 Jun 22 01:11:17 okay, 3 different solutions, all should work 2009 Jun 22 01:11:24 yep 2009 Jun 22 01:11:41 i felt it was pretty lame to just block out a client like that 2009 Jun 22 01:11:53 oops, have to leave somewhat early today 2009 Jun 22 01:12:03 and some of the arguments where like "your client substitues amaozon links for your affiliate links" 2009 Jun 22 01:12:19 stuff that wasnt really their job to police as network operators 2009 Jun 22 01:12:34 aamar: oh, like immediately? 2009 Jun 22 01:12:55 Yeah, have to head out in 3 minutes. 2009 Jun 22 01:13:03 alright 2009 Jun 22 01:13:12 Have to admit, I didn't understand the diagramming all that well. 2009 Jun 22 01:13:24 we'll see you in 2 weeks then? 2009 Jun 22 01:13:28 Gave it a shot, but wouldn't be surprised if I got them all wrong. 2009 Jun 22 01:13:33 next weekend is ICFP 2009 Jun 22 01:13:44 I didnt do any of the following 2009 Jun 22 01:13:55 ok, cool 2009 Jun 22 01:13:56 ok, yeah I think there was room for variation in these answers 2009 Jun 22 01:13:59 I'll be there 2009 Jun 22 01:14:00 did i miss some key insight or was that basically scope? 2009 Jun 22 01:14:05 (not at ICFP) 2009 Jun 22 01:14:06 alright aamar 2009 Jun 22 01:14:15 icfp? 2009 Jun 22 01:14:33 hehe, you'll be here in two weeks right? 2009 Jun 22 01:14:36 nvm 2009 Jun 22 01:14:37 gl 2009 Jun 22 01:16:07 how about 3.3 for next time, it looks pretty long? 2009 Jun 22 01:16:29 so maybe just as far as we can get into that, and the rest of the 3.2 exercises? 2009 Jun 22 01:16:42 sounds ambitious but good 2009 Jun 22 01:16:47 lets give it a shot 2009 Jun 22 01:17:06 alright, cool 2009 Jun 22 01:17:18 3.2 is diagrams no? 2009 Jun 22 01:17:36 didnt get the feeling they woudl be suitable for irc consuption 2009 Jun 22 01:18:06 yeah there are some diagrams 2009 Jun 22 01:18:43 I did some one as an SVG, and the others just text 2009 Jun 22 01:18:55 mostly descriptive prose 2009 Jun 22 01:19:13 I found them helpful to work through 2009 Jun 22 01:24:29 alright, see you then! 2009 Jun 22 01:26:31 later inimino