2009 Dec 14 01:03:39 bbiab 2009 Dec 14 01:06:04 ok 2009 Dec 14 01:21:49 -*- inimino is back 2009 Dec 14 01:22:05 aamar: you still around? 2009 Dec 14 01:22:18 sorry about that 2009 Dec 14 01:22:26 hey, no problem 2009 Dec 14 01:23:31 should we get started? 2009 Dec 14 01:23:49 I only got to 4.41 this time... 2009 Dec 14 01:23:54 Sure, let's start. 2009 Dec 14 01:24:25 I got just a little further... some of these were quite slow going 2009 Dec 14 01:25:11 I spent a while trying to get some older answers actually working inside the M-eval and L-eval interpreters. 2009 Dec 14 01:25:25 Useful, helpful, but there were a few things that didn't work out of the box. 2009 Dec 14 01:25:41 4.30, right? 2009 Dec 14 01:25:44 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L589-610 2009 Dec 14 01:26:34 ah, cool 2009 Dec 14 01:26:35 yeah 2009 Dec 14 01:27:10 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.30 2009 Dec 14 01:28:24 I wasn't quite sure about this one either 2009 Dec 14 01:28:32 I'm not really sure if my answer is correct 2009 Dec 14 01:28:38 okay, same answer for (a) 2009 Dec 14 01:28:56 In b, (p1 1) -> (1 2) for you. 2009 Dec 14 01:29:34 yeah 2009 Dec 14 01:30:09 so that set! gets "forced" before the x returns? I wasn't sure why that would happen. 2009 Dec 14 01:30:27 I think so 2009 Dec 14 01:30:41 eval runs through the sequence 2009 Dec 14 01:31:05 I'm not sure I remember the specific function names that get called 2009 Dec 14 01:31:15 eval-sequence I think 2009 Dec 14 01:31:42 yeah 2009 Dec 14 01:31:55 eval-sequence calls eval for each expression 2009 Dec 14 01:32:07 (set! ...) then gets apply'd 2009 Dec 14 01:32:20 which does the actual assignment 2009 Dec 14 01:33:03 the difference in (p2 1) is that the set! call is an argument 2009 Dec 14 01:33:10 arguments get deferred 2009 Dec 14 01:33:32 okay, that seems right 2009 Dec 14 01:34:55 anything else on 4.30? 2009 Dec 14 01:35:23 did you test this one? 2009 Dec 14 01:35:36 no, didn't get it working 2009 Dec 14 01:35:44 oh well 2009 Dec 14 01:35:50 I think we're good on this one. 2009 Dec 14 01:35:57 I tried running a few later on, with mixed results 2009 Dec 14 01:36:10 alright 2009 Dec 14 01:36:16 skipped 4.31 :( 2009 Dec 14 01:36:19 looks like we both skipped it 2009 Dec 14 01:36:43 looked interesting but kind of a lot of work :) 2009 Dec 14 01:36:50 yeah 2009 Dec 14 01:37:03 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L615-621 2009 Dec 14 01:37:19 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.32 2009 Dec 14 01:37:26 oh yeah, I couldn't think of anything here 2009 Dec 14 01:37:42 ok 2009 Dec 14 01:37:52 looks like about the same answer 2009 Dec 14 01:37:55 the footnote really gives it away; not sure how much there is to add 2009 Dec 14 01:37:59 yeah, me neither 2009 Dec 14 01:38:14 I thought of trying to do some example with a tree but nothing really came to mind 2009 Dec 14 01:38:33 "infinite tree" isn't really something I have a lot of examples of off the top of my head 2009 Dec 14 01:39:14 4.33? 2009 Dec 14 01:39:22 Yes 2009 Dec 14 01:39:28 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L623-629 2009 Dec 14 01:40:33 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.33 2009 Dec 14 01:40:40 oh, I didn't make mine recurse on car 2009 Dec 14 01:40:51 I suppose it should 2009 Dec 14 01:41:21 and I should have used pair? instead of null? 2009 Dec 14 01:42:03 Interestingly, don't see an implementation of pair? in the new structure. 2009 Dec 14 01:42:06 well, they only mentioned lists specifically 2009 Dec 14 01:42:30 yes, I think mine works for pairs 2009 Dec 14 01:42:32 and lists 2009 Dec 14 01:43:16 yours will use the car of the underlying scheme, though? 2009 Dec 14 01:43:27 erm, I mean the cons 2009 Dec 14 01:44:00 Hm. 2009 Dec 14 01:44:33 the cons-in-underlying-scheme and the cons-using-procedures would have to be both available somehow in the interpreter itself 2009 Dec 14 01:45:21 oh, unless you used the derived-expression model 2009 Dec 14 01:45:26 as in cond->if 2009 Dec 14 01:45:29 which it wouldn't if you just typed in the new definition of cons 2009 Dec 14 01:45:56 hm, yes 2009 Dec 14 01:46:44 though "car" still needs to be car-in-underlying-scheme 2009 Dec 14 01:46:58 so I don't know if that works. 2009 Dec 14 01:47:50 hm 2009 Dec 14 01:48:06 okay, I think implementing proc-cons as you describe is the way to go. 2009 Dec 14 01:48:19 I guess if car and cdr can be replaced maybe it would make sense to be able to override quote too 2009 Dec 14 01:48:35 but quote has to be a special form 2009 Dec 14 01:48:46 macros? :) 2009 Dec 14 01:50:03 alright, next one? 2009 Dec 14 01:50:15 not likely :) 2009 Dec 14 01:50:19 ok 2009 Dec 14 01:50:33 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L631-641 2009 Dec 14 01:51:08 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.34 2009 Dec 14 01:52:53 I think those are similar 2009 Dec 14 01:53:32 one other thing that occurred to me is that some sequences may take a very long time to generate the next item 2009 Dec 14 01:53:39 including maybe never terminating 2009 Dec 14 01:53:44 yes, similar 2009 Dec 14 01:54:10 I suppose that's true, but that's also true of any value to be displayed; sequences aren't special in that way. 2009 Dec 14 01:54:21 and maybe it wouldn't be a problem because the program that consumes it is guaranteed to never force an item that won't terminate, but the display routine wouldn't know that 2009 Dec 14 01:54:24 I guess that's true 2009 Dec 14 01:54:37 anything that is lazy has this issue 2009 Dec 14 01:56:19 yes, the only solution is to avoid printing 2009 Dec 14 01:56:43 or use a thread or something 2009 Dec 14 01:56:57 a thread? 2009 Dec 14 01:57:22 spawn a thread, force the value there, if it doesn't return in some number of seconds time it out 2009 Dec 14 01:57:28 oh, got it 2009 Dec 14 01:57:44 display it as "[slow]" after a timeout 2009 Dec 14 01:57:47 you could even display the values in real time as they are calculated I guess 2009 Dec 14 01:57:47 ok, sure 2009 Dec 14 01:57:48 yeah 2009 Dec 14 01:57:56 [waiting...] 2009 Dec 14 01:58:01 yeah 2009 Dec 14 01:58:04 agreed 2009 Dec 14 01:58:48 next one? 2009 Dec 14 01:58:51 okay 4.35? 2009 Dec 14 01:58:54 k 2009 Dec 14 01:58:59 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.35 2009 Dec 14 01:59:43 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L643-647 2009 Dec 14 02:00:26 looks like I needed a <= instead of < 2009 Dec 14 02:00:43 and I forgot about using require here 2009 Dec 14 02:01:43 you used (amb ...) in a way I did not expect 2009 Dec 14 02:02:34 (amb)? 2009 Dec 14 02:02:42 no, that part makes sense. 2009 Dec 14 02:02:55 just another way of implementing require 2009 Dec 14 02:03:11 yeah 2009 Dec 14 02:03:28 but you're recursing as so: (amb 1 (amb 2 (amb 3))) 2009 Dec 14 02:03:32 the other use of amb is the same? 2009 Dec 14 02:03:54 yes 2009 Dec 14 02:04:34 there will be another 'amb' invocation once the first one 'toggles over' 2009 Dec 14 02:04:52 Hm... not following... let me try these out 2009 Dec 14 02:04:56 that part is the same between our answers isn't it? 2009 Dec 14 02:06:44 no, don't think so 2009 Dec 14 02:06:52 hm 2009 Dec 14 02:06:55 no, you're right 2009 Dec 14 02:07:38 ok, just need to get this straight in my head for a sec :) 2009 Dec 14 02:08:29 okay, got it... 2009 Dec 14 02:08:44 ok 2009 Dec 14 02:09:01 I wrote an-integer-between based on an analogy with an-integer-starting-from without really understanding how the latter worked 2009 Dec 14 02:09:11 Now I get it, sorry for the false alarm. 2009 Dec 14 02:09:16 cool 2009 Dec 14 02:09:24 I think these are pretty much equivalent, except that yours gets the bounds right 2009 Dec 14 02:10:29 yep 2009 Dec 14 02:10:33 okay, next one? 2009 Dec 14 02:11:10 sure 2009 Dec 14 02:11:21 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.36 2009 Dec 14 02:11:37 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L653-661 2009 Dec 14 02:12:06 hm, I wrote i ≤ j ≤ k where I should have written i < j < k 2009 Dec 14 02:14:17 hm... 2009 Dec 14 02:14:27 your solution should work 2009 Dec 14 02:14:32 and it's much simpler 2009 Dec 14 02:14:37 very different approaches... still reading yours 2009 Dec 14 02:15:31 I thought of one way of limiting the selection of k based on i and j, but the first idea I had wouldn't have worked, so I tried to do something more general 2009 Dec 14 02:16:21 Yeah, it does seem like you have to bound k, otherwise my approach doesn't do it. 2009 Dec 14 02:16:53 yeah, the idea of making j lower than i hadn't occurred to me 2009 Dec 14 02:19:45 I find your solution really interesting... 2009 Dec 14 02:19:51 Were you able to run these? 2009 Dec 14 02:20:05 I didn't try running them 2009 Dec 14 02:20:35 I think the one in the middle would work, though 2009 Dec 14 02:20:42 the last one would require interpreter support 2009 Dec 14 02:21:10 yes, the one with (amb in-this-plane higher-plane), right? 2009 Dec 14 02:21:32 yes 2009 Dec 14 02:23:08 ;The object ok, passed as the first argument to car, is not the correct type. 2009 Dec 14 02:23:55 'ok gets returned from defines 2009 Dec 14 02:24:50 hm 2009 Dec 14 02:25:16 oh... crap 2009 Dec 14 02:25:29 I put (define (a-pair j) at the end of the function 2009 Dec 14 02:25:35 you can't do that in Scheme 2009 Dec 14 02:25:35 ah, that's it 2009 Dec 14 02:27:33 so I am getting some repititions 2009 Dec 14 02:27:39 repetitions 2009 Dec 14 02:28:03 what's being repeated? 2009 Dec 14 02:28:25 here's the sequence 2009 Dec 14 02:29:05 (4 5 6) (4 5 6) (5 6 7) (4 5 7) (5 6 8) (4 5 7) (6 7 8) (4 5 7) 2009 Dec 14 02:29:31 sorry, mistyped the beginning 2009 Dec 14 02:29:40 (4 5 6) (4 5 7) (5 6 7) 2009 Dec 14 02:29:47 wow 2009 Dec 14 02:29:58 I wonder what happened to (1 2 3) 2009 Dec 14 02:30:25 this all came from a call of (any-increasing-triple-from 4) 2009 Dec 14 02:30:30 sorry, should have made that explicit! 2009 Dec 14 02:30:32 oh, ok 2009 Dec 14 02:31:10 looks like the (4 5 7) branch is just plain stuck 2009 Dec 14 02:31:33 If I call (any-increasing-triple-from 1), (1 2 4) is the branch that keeps repeating. 2009 Dec 14 02:32:11 This is very similar to those ch.3 problems. 2009 Dec 14 02:32:54 yeah 2009 Dec 14 02:33:23 I think it must me some subtle misunderstanding on my part of how amb works with backtracking exactly 2009 Dec 14 02:33:56 Yes, it's hard to debug without reading through all the code from later in the chapter. 2009 Dec 14 02:34:47 I'd guess there's some small change which would make this work. 2009 Dec 14 02:35:21 should we continue for now? 2009 Dec 14 02:35:38 yeah, lets go on 2009 Dec 14 02:35:56 I'll see if I can make that work once we've worked through the amb implementation 2009 Dec 14 02:36:05 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L663-665 2009 Dec 14 02:36:17 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.37 2009 Dec 14 02:36:41 ok, looks the same 2009 Dec 14 02:36:59 okay, let's go to the next one 2009 Dec 14 02:37:39 I skipped this one: http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.38 2009 Dec 14 02:37:43 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L668-695 2009 Dec 14 02:38:06 okay, removing the single requirement was trivial anyway 2009 Dec 14 02:38:39 hm, interesting, though 2009 Dec 14 02:38:49 when I did this later in 4.41 I got a different answer 2009 Dec 14 02:39:36 interesting 2009 Dec 14 02:39:54 probably my 4.41 is completely wrong 2009 Dec 14 02:39:56 anyway 2009 Dec 14 02:39:57 my solutions are just from me trying to work it out in my head 2009 Dec 14 02:40:09 oh, you didn't run this one? 2009 Dec 14 02:40:18 I should have -- but didn't -- check my work, since distinct? was not implemented 2009 Dec 14 02:40:27 yeah, I found that annoying 2009 Dec 14 02:40:32 that's why I didn't do this one 2009 Dec 14 02:40:34 I ran pieces of it. 2009 Dec 14 02:40:42 but not the whole thing 2009 Dec 14 02:42:37 okay for 4.39? 2009 Dec 14 02:42:51 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L696-699 2009 Dec 14 02:43:39 your three extra solutions look correct 2009 Dec 14 02:43:44 ok 2009 Dec 14 02:44:12 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.39 2009 Dec 14 02:44:53 looks similar 2009 Dec 14 02:44:58 hm, mostly the same, but one thing I didn't change... 2009 Dec 14 02:45:12 I wanted to benchmark these but when things didn't run easily I gave up on it 2009 Dec 14 02:45:48 I thought about moving distinct? down, but it also screens out so many cases, I thought it might be useful to keep higher up. 2009 Dec 14 02:46:07 You know, this is a good case where benchmarking is the way to test it. 2009 Dec 14 02:46:13 yeah I wasn't sure about that either 2009 Dec 14 02:46:15 I didn't try out mine either. 2009 Dec 14 02:46:39 I will try it out after writing a reasonable version of distinct? 2009 Dec 14 02:46:43 I guess I could have done the math to guess where distinc? should go 2009 Dec 14 02:46:49 there's an implementation of it in a footnote 2009 Dec 14 02:47:09 Let's go to 4.40 2009 Dec 14 02:47:11 ok 2009 Dec 14 02:47:24 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.40 2009 Dec 14 02:47:37 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L701-725 2009 Dec 14 02:47:52 oh, thanks for mentioning... didn't see that footnote 2009 Dec 14 02:49:04 these are a little different 2009 Dec 14 02:49:15 I ordered mine alphabetically 2009 Dec 14 02:49:36 I see 2009 Dec 14 02:49:57 are yours ordered in any particular way? 2009 Dec 14 02:50:08 I was trying to see if you did something clever with the ordering 2009 Dec 14 02:50:12 And you condensed some of the requirements with (amb)... 2009 Dec 14 02:50:20 yes 2009 Dec 14 02:50:50 Yes, I tried to put the most restrictive items first. 2009 Dec 14 02:51:09 I got rid of distinct?, and some of the redundant requirements 2009 Dec 14 02:51:22 I.e. if you start with 3125 cases, each level of (let) should eliminate as great a fraction as possible before introducing the next let 2009 Dec 14 02:51:35 yeah, that makes sense 2009 Dec 14 02:52:04 Not that I'm sure I ordered them correctly in all cases. 2009 Dec 14 02:52:04 so cut out fletcher first because that is the only that eliminates two entire floors before anything else is settled 2009 Dec 14 02:52:48 sounds reasonable 2009 Dec 14 02:53:19 I'd be interested to see how much faster these run than the naive implementation 2009 Dec 14 02:53:30 I guess it's pretty dramatic 2009 Dec 14 02:54:59 should with start with 4.41 next time? 2009 Dec 14 02:55:14 even the naive version is really fast 2009 Dec 14 02:55:26 yes, let's pick up with 4.41 2009 Dec 14 02:55:58 ok 2009 Dec 14 02:56:42 through to the end of 4.3? 2009 Dec 14 02:56:50 that's 4.54 2009 Dec 14 02:56:55 that's 4.54, right? 2009 Dec 14 02:56:56 sure 2009 Dec 14 02:56:58 yeah 2009 Dec 14 02:57:01 ok, cool 2009 Dec 14 02:57:04 Looks manageable 2009 Dec 14 02:57:09 yeah I think so 2009 Dec 14 02:59:00 I skipped 4.43 and 4.45 2009 Dec 14 02:59:13 btw, my answer to 4.38 wasn't quite right -- I missed one solution 2009 Dec 14 02:59:24 ah 2009 Dec 14 02:59:30 so the total number of solutions are 5 (including the original one) 2009 Dec 14 02:59:37 my 4.41 was definitely wrong, it only found two solutions 2009 Dec 14 02:59:57 Okay cool, so we'll see if next time we can beat that 2009 Dec 14 03:00:11 sounds good 2009 Dec 14 03:00:15 see you then 2009 Dec 14 03:02:31 see you!