2009 Dec 28 00:58:50 hey aamar 2009 Dec 28 00:58:56 hey inimino 2009 Dec 28 00:59:29 how's it going? 2009 Dec 28 00:59:53 good, how are you doing? 2009 Dec 28 00:59:56 happy holidays! 2009 Dec 28 01:00:28 happy holidays to you too :) 2009 Dec 28 01:01:23 I did not get the last four exercises done 2009 Dec 28 01:03:56 I got through 4.49 2009 Dec 28 01:03:59 So about the same. 2009 Dec 28 01:04:24 cool 2009 Dec 28 01:04:55 budgeted quite a bit of time -- some of these took a while! 2009 Dec 28 01:05:11 yeah, indeed 2009 Dec 28 01:05:11 Or I'm getting old. 2009 Dec 28 01:05:16 hehe 2009 Dec 28 01:05:48 I think you're too young for senility. 2009 Dec 28 01:06:09 hopefully for a little while longer 2009 Dec 28 01:06:31 should we start? 2009 Dec 28 01:06:39 sure 2009 Dec 28 01:06:52 these took me quite a bit of time too, I think it just means there is more learning going on 2009 Dec 28 01:07:33 4.41 was where we left off? 2009 Dec 28 01:07:54 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L732-779 2009 Dec 28 01:08:16 ah, I think so 2009 Dec 28 01:08:48 I remember noting that my 4.41 was wrong, but I never fixed it 2009 Dec 28 01:12:16 it's wrong because it only finds two solutions to the looser problem, but your solution to an earlier problem showed that there were more than two solutions 2009 Dec 28 01:13:17 ok, let me take a look there 2009 Dec 28 01:14:19 yours looks good, and I think is a more straightforward implementation 2009 Dec 28 01:14:42 Right ok, 5 solutions. 2009 Dec 28 01:14:51 I didn't test mine in that situation. 2009 Dec 28 01:15:04 (i.e. in the 4.38 version with one fewer restrictions) 2009 Dec 28 01:15:06 mine is more trying to implement something like amb without amb, yours is more direct 2009 Dec 28 01:15:12 I'll try it and see if it obtains good answers. 2009 Dec 28 01:16:08 I think it will 2009 Dec 28 01:16:36 It's an interesting approach 2009 Dec 28 01:17:18 it does get the right answer at first -- so it seems there are some branches it's not trying. 2009 Dec 28 01:17:54 yes 2009 Dec 28 01:17:57 I'm not sure why 2009 Dec 28 01:18:18 Oh, maybe it's only branching at the outer-most layer. 2009 Dec 28 01:18:51 hm, that looks consistent with the results 2009 Dec 28 01:19:47 ah, I think that's right 2009 Dec 28 01:19:59 my try implementation is not quite right, I think 2009 Dec 28 01:20:05 we could tinker for a bit to confirm, or go to the next one for now? 2009 Dec 28 01:20:38 well, this turns out to be basically part of the evaluator presented later in the chapter, just lifted into the program (incorrectly) 2009 Dec 28 01:21:07 I think the benifit comes from getting through the rest of the chapter more than debugging this first try 2009 Dec 28 01:21:12 yes, it is fairly similar, but I didn't get quite far enough in it to intuit what's different. 2009 Dec 28 01:21:27 but I might come back to it and see if I can determine exactly the error... 2009 Dec 28 01:21:32 I think it's related to: 2009 Dec 28 01:21:43 (let ((result (proc test-value))) 2009 Dec 28 01:21:43 (if result 2009 Dec 28 01:21:43 (list result (lambda () (try (cdr values) proc))) 2009 Dec 28 01:22:07 if it finds a result in a branch, it doesn't look for any more results in that branch 2009 Dec 28 01:22:24 it needs to somewow bubble the continuations back out too 2009 Dec 28 01:22:35 anyway, lets move on for now 2009 Dec 28 01:22:41 that's it 2009 Dec 28 01:23:04 that's why you only have 5 continuations in your first "results" line. 2009 Dec 28 01:23:08 ok 2009 Dec 28 01:23:13 4.42 2009 Dec 28 01:23:20 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L780-822 2009 Dec 28 01:24:28 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.42 2009 Dec 28 01:25:16 ha, your version of XOR is massively better 2009 Dec 28 01:26:28 hehe, thanks 2009 Dec 28 01:27:35 I like "excluding" too 2009 Dec 28 01:27:59 Mine doesn't have any of the efficiency optimizations. 2009 Dec 28 01:28:20 hm, different implementations, I realize I never actually tried to run mine 2009 Dec 28 01:29:07 oh, no I did 2009 Dec 28 01:29:09 seems like it will work 2009 Dec 28 01:29:29 yeah, and wasn't implemented in amb-eval 2009 Dec 28 01:29:39 I didn't care enough to fix it so I didn't run it 2009 Dec 28 01:29:39 ;The object #f, passed as the first argument to integer-equal?, is not the correct type. 2009 Dec 28 01:30:01 oh, I guess I have to use (eq there 2009 Dec 28 01:30:28 or eq? 2009 Dec 28 01:31:00 (eq? #t #f) seems to work 2009 Dec 28 01:31:09 ok tried that 2009 Dec 28 01:31:11 ;Too many arguments supplied (a b) (#f #f #t #f #t) 2009 Dec 28 01:31:20 possibly a ")" out of place? 2009 Dec 28 01:32:07 hm, did you implement `and` in your amb-eval? 2009 Dec 28 01:32:15 I'm wondering why we got different errors 2009 Dec 28 01:32:22 nope, my typo 2009 Dec 28 01:33:03 I did implement and 2009 Dec 28 01:33:13 as well as or 2009 Dec 28 01:33:20 both implemented in terms of "if" 2009 Dec 28 01:33:40 ah, ok, cool 2009 Dec 28 01:34:39 ok, fixed the typo 2009 Dec 28 01:34:46 the problem is that my "and" is not general 2009 Dec 28 01:34:50 it only takes 2 arguments 2009 Dec 28 01:34:59 ok, that's what it looked like from the error 2009 Dec 28 01:35:06 yes 2009 Dec 28 01:35:35 ok, that explains it... I bet this runs with a proper "and" 2009 Dec 28 01:37:11 should we look at 4.43? 2009 Dec 28 01:37:16 sure 2009 Dec 28 01:37:35 oh, I skipped this one 2009 Dec 28 01:37:40 but I will read your solution 2009 Dec 28 01:37:47 This one was massively long! 2009 Dec 28 01:38:34 my solution felt like a mess, actually, because I never figured out how to cleanly map the fathers to the daughters. 2009 Dec 28 01:40:06 wow 2009 Dec 28 01:40:14 this is way longer than I expected the solution to be 2009 Dec 28 01:42:10 well, it looks like it works 2009 Dec 28 01:43:27 I think I mostly follow it 2009 Dec 28 01:43:50 I guess I thought this exercise would be very similar to the earlier logic puzzle ones 2009 Dec 28 01:44:17 I'm surprised at the complexity 2009 Dec 28 01:46:02 I bet there are much easier ways to handle it... but I ended up with this :( 2009 Dec 28 01:46:28 It's conceptually not different from the earlier ones -- it's just that there's more objects to keep track of. 2009 Dec 28 01:46:43 yeah 2009 Dec 28 01:47:06 the vague idea I have is to create father-daughter pairs 2009 Dec 28 01:47:20 okay, let's look at 4.44 2009 Dec 28 01:47:26 from the set of remaining fathers and daughters 2009 Dec 28 01:47:52 so you can call a function that ambiguously gives you a new pair, and then run some tests... not sure 2009 Dec 28 01:47:57 ok, 4.44 2009 Dec 28 01:48:11 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.44 2009 Dec 28 01:48:14 father-daughter-yacht triples might work 2009 Dec 28 01:48:17 interesting 2009 Dec 28 01:48:18 ok 2009 Dec 28 01:49:35 I think your (not-checking new-queen) should be (not-checking new-queen queen) 2009 Dec 28 01:50:09 oh, yes 2009 Dec 28 01:50:31 -*- inimino fixes 2009 Dec 28 01:51:28 I think they're not all that different -- you put your recursion in a sensible place. 2009 Dec 28 01:52:41 my version doesn't short circuit a checking queen as fast. 2009 Dec 28 01:53:02 I should note that mine is very slow -- took a minute or so for 6 queens, never finished for 8. 2009 Dec 28 01:53:42 oh, actually yours doesn't short-circuit faster -- basically works the same way there. 2009 Dec 28 01:54:18 they look about the same for efficiency from my reading 2009 Dec 28 01:54:35 I should note that I never ran mine but didn't expect it to be slow, so your result is surprising to me 2009 Dec 28 01:55:52 hm 2009 Dec 28 01:55:59 I'm not sure they're the same 2009 Dec 28 01:57:07 (let ((my-queens (cons (list n (amb-enumerate board-size)) (safe-queens (- n 1))))) 2009 Dec 28 01:57:45 this seems like it might be doing things in an inefficient order? 2009 Dec 28 01:58:13 hm, or maybe not 2009 Dec 28 01:58:37 I guess that's equivalent actually 2009 Dec 28 01:58:44 Yeah, yours is running slowly too. 2009 Dec 28 01:58:51 well, I wouldn't have expected this to be so slow, that's odd 2009 Dec 28 01:59:03 Well, it finished now 2009 Dec 28 01:59:07 So it's faster than mine. 2009 Dec 28 01:59:19 oh 2009 Dec 28 02:00:24 well I have a vague intuition about why but I can't really formulate it 2009 Dec 28 02:00:40 I still find reasoning about the performance of these programs quite hard 2009 Dec 28 02:00:54 what's the vague intuition? 2009 Dec 28 02:01:01 I guess something that generates a full trace of the execution path and plots a nice graph would be nice 2009 Dec 28 02:01:30 it's those two lines 2009 Dec 28 02:01:33 (let ((my-queens (cons (list n (amb-enumerate board-size)) (safe-queens (- n 1))))) 2009 Dec 28 02:01:35 (require (safe? my-queens)) 2009 Dec 28 02:01:58 ok, most likely yes 2009 Dec 28 02:02:03 it seems like you are generating a row 2009 Dec 28 02:02:13 then generating all smaller boards that are safe 2009 Dec 28 02:02:16 then testing them all 2009 Dec 28 02:02:18 most will fail 2009 Dec 28 02:02:27 I think mine tests each row as it is added 2009 Dec 28 02:02:38 so it generates fewer possibilities 2009 Dec 28 02:02:52 or s/row/column/ 2009 Dec 28 02:02:55 however you think about it 2009 Dec 28 02:03:30 ah, sort of like a Louis Reasoner attempt at the 8-queens problem. 2009 Dec 28 02:03:39 Been feeling a lot like Louis recently. 2009 Dec 28 02:03:59 I'm almost certain that you're right 2009 Dec 28 02:04:04 this chapter has been doing that to me too 2009 Dec 28 02:06:57 well, next one? 2009 Dec 28 02:07:05 ok sure 2009 Dec 28 02:07:30 ok 2009 Dec 28 02:07:35 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L1001-1027 2009 Dec 28 02:07:44 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.45 2009 Dec 28 02:10:28 I think your first parse is my last one 2009 Dec 28 02:10:44 my 1 = your 5, my 2 = your 3 2009 Dec 28 02:11:09 my 3 = your 4 2009 Dec 28 02:11:24 my 4 = your 1 2009 Dec 28 02:11:42 my 5 = your 2 2009 Dec 28 02:11:47 okay, they are the same 2009 Dec 28 02:11:49 yeah, I think that's it 2009 Dec 28 02:11:52 ok 2009 Dec 28 02:11:59 4.46? 2009 Dec 28 02:12:23 yes 2009 Dec 28 02:12:29 I was quite unsure of my answer to this one 2009 Dec 28 02:12:56 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.46 2009 Dec 28 02:12:57 Oh I see 2009 Dec 28 02:13:04 your answer is persuasive! 2009 Dec 28 02:14:02 I think your 4.46 is very like my answer to 4.47 2009 Dec 28 02:15:27 In fact I skipped 4.46 at first, then returned to it after 4.47 2009 Dec 28 02:15:41 Reading your answer to 4.47, and I think it's essentially the same as mine. 2009 Dec 28 02:16:09 yeah 2009 Dec 28 02:16:27 I think actually what you mention on 4.46 would also be a problem, if the other thing didn't bite first 2009 Dec 28 02:17:04 I found 4.47 really illustrative 2009 Dec 28 02:17:34 it took me quite a while to get it right, I think 2009 Dec 28 02:17:49 your answer looks exactly the same, which is reassuring 2009 Dec 28 02:18:02 Yes, I appreciate your longer explanation; it definitely maps to what I was thinking. 2009 Dec 28 02:18:39 4.48 ? 2009 Dec 28 02:19:01 sure 2009 Dec 28 02:19:17 ah, I skipped this one too 2009 Dec 28 02:19:40 ok 2009 Dec 28 02:19:46 this one wasn't particularly interesting 2009 Dec 28 02:20:00 your implementation looks straightforward 2009 Dec 28 02:20:02 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L1068-1091 <- 4.49 2009 Dec 28 02:20:15 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.49 2009 Dec 28 02:21:32 Interesting... 2009 Dec 28 02:21:45 The book was odd on this point. 2009 Dec 28 02:21:50 your results look about like what I expected 2009 Dec 28 02:22:01 I think that was the desired implementation 2009 Dec 28 02:22:10 I couldn't figure out a way to avoid infinite recursion without limiting the length of the sentence... 2009 Dec 28 02:22:18 It never produced a single valid phrase. 2009 Dec 28 02:22:21 not sure about the (require (not (null? *unparsed*))) bit 2009 Dec 28 02:22:26 hm 2009 Dec 28 02:22:51 I would have thought it would have produced something short at first 2009 Dec 28 02:22:53 That's from the original implementation of parse-word. 2009 Dec 28 02:23:12 That with the next line act like the length-limiter you describe in your answer 2009 Dec 28 02:23:19 right, I meant more the idea of limiting the length that way 2009 Dec 28 02:23:30 yes 2009 Dec 28 02:23:52 so without the length limitation it didn't terminate? 2009 Dec 28 02:24:10 is there anything in the grammar in which the first branch isn't also the shortest? 2009 Dec 28 02:24:31 right 2009 Dec 28 02:24:53 oh, you know, it might have been my adjectives patch! 2009 Dec 28 02:25:34 ah! 2009 Dec 28 02:26:11 ;Aborting!: out of memory 2009 Dec 28 02:26:21 ok, so my quick attempt to pull that out didn't work. 2009 Dec 28 02:27:27 yeah, actually your adjective patch looks like it should be okay as it tries the bare noun first 2009 Dec 28 02:27:52 ok, still getting infinite loop and out of memory errors 2009 Dec 28 02:28:08 oh well - the length limited one works fine, as you describe in your answer. 2009 Dec 28 02:28:17 And is superior in some ways. 2009 Dec 28 02:28:45 ok that's it for now 2009 Dec 28 02:29:32 alright 2009 Dec 28 02:30:38 your amb-any looks fine to me, not sure why it wouldn't terminate, maybe I'll play with this 2009 Dec 28 02:30:55 alright, so for next time, should we just finish up to 4.54? 2009 Dec 28 02:31:18 I am still just reading into the amb-eval implementation, I found it pretty heavy going 2009 Dec 28 02:31:22 A little more modest. 2009 Dec 28 02:31:36 Might be good actually, since I'm moving and there's new years. 2009 Dec 28 02:31:48 yeah, I'm in no rush to get through this section, I guess 2009 Dec 28 02:32:22 Okay, sounds good. 2009 Dec 28 02:33:00 alright, cool 2009 Dec 28 02:33:24 see you in a couple weeks :) 2009 Dec 28 02:33:45 in the new year, I should say :-) 2009 Dec 28 02:34:41 ok, talk to you then! 2009 Dec 28 02:35:34 -=- aamar has changed topic for ##SICP to: "Topic: SICP book club | Next meeting: Sunday, Jan 10, 5PM PST, Exer. 4.50-4.54 | http://hn-sicp.pbwiki.com | http://www.cafepress.com/SICP2 | http://www.cafepress.com/SICP2 | http://g.imagehost.org/0293/Untitled_11.jpg" 2009 Dec 28 02:35:54 cool