2009 Apr 13 00:01:10 hey all 2009 Apr 13 00:01:25 hey 2009 Apr 13 00:01:25 anybody else awake? 2009 Apr 13 00:02:12 heey 2009 Apr 13 00:02:25 -*- mariorz is still starting 2.20 2009 Apr 13 00:02:31 hey 2009 Apr 13 00:02:46 got through 2.52 2009 Apr 13 00:03:22 i got to 2.42 2009 Apr 13 00:03:24 still working on it 2009 Apr 13 00:03:30 same as me 2009 Apr 13 00:03:45 well, I haven't started working on it 2009 Apr 13 00:04:16 -*- inimino had a snack and a little nap instead 2009 Apr 13 00:06:30 do you guys want to talk section 2.2 in general tonight? 2009 Apr 13 00:06:40 then get all caught up for next meeting? 2009 Apr 13 00:06:54 that sounds good 2009 Apr 13 00:07:04 ok 2009 Apr 13 00:07:55 2.2 is a long section 2009 Apr 13 00:08:23 aamar: how is 2.43->2.52? 2009 Apr 13 00:09:33 I guess "hierarchical data" covers a lot 2009 Apr 13 00:09:47 last few are fairly long 2009 Apr 13 00:09:53 heh, yeah 2009 Apr 13 00:10:42 2.49(d) is tedious and long -- I suggest skipping it, actually. 2009 Apr 13 00:11:09 hmmm, thanks for the tip 2009 Apr 13 00:11:30 mind if i ask about 2.42? 2009 Apr 13 00:12:09 i'm having trouble with safe? 2009 Apr 13 00:12:22 ok 2009 Apr 13 00:13:09 i might be heading down the wrong path, but I am passing "positions" as ((31) (21) (12)) for example 2009 Apr 13 00:13:15 same here 2009 Apr 13 00:13:30 (31) is my most recent position 2009 Apr 13 00:13:59 i want to compare the row(3) to all of the other rows 2009 Apr 13 00:14:12 (assume there's a space in there, i.e. (3 1)) 2009 Apr 13 00:14:29 something like (include? 3 (cdr postions)) 2009 Apr 13 00:14:46 actually, those parens were just a pause, so i actually meant 3 2009 Apr 13 00:15:27 let me try to be a little clearer? 2009 Apr 13 00:15:47 ok 2009 Apr 13 00:15:54 so in the positions example above, i have queens in rows 3 2 and 1 2009 Apr 13 00:16:10 those queens are in columns 1 1 2 2009 Apr 13 00:16:47 columns 1 2 and 3, you mean? 2009 Apr 13 00:17:00 yeah, bad example above 2009 Apr 13 00:17:28 seems okay so far 2009 Apr 13 00:17:51 so you want to check the first queen to see if it's safe against all the previous queens 2009 Apr 13 00:17:56 yes 2009 Apr 13 00:18:18 so you have to check if any row is the same 2009 Apr 13 00:18:23 right 2009 Apr 13 00:18:25 and the diagonals 2009 Apr 13 00:19:09 the way i have it, i just have to check rows, the columns are already unique 2009 Apr 13 00:19:19 ahhhhh 2009 Apr 13 00:19:28 crap, i forgot about diagonals-heh 2009 Apr 13 00:19:35 hehe 2009 Apr 13 00:19:53 ok, forgetting that for a minut 2009 Apr 13 00:20:09 is there a way to do something like (include? 3 (list 1 2 3)) 2009 Apr 13 00:20:35 returns true if 3 exists in the given list 2009 Apr 13 00:21:04 you could write that as a helper function 2009 Apr 13 00:21:07 yes, you could write an include? method 2009 Apr 13 00:22:28 case (nil items) -> false, (car items == x) -> true, otherwise (include? x (cdr items)) 2009 Apr 13 00:23:14 (def (include? x others) (cond ((null? others) false) (= x (car others)) true) (else (include? x (cdr others))))) 2009 Apr 13 00:23:22 right, that sort of thing... 2009 Apr 13 00:23:57 It's hard to use an include like that for diagonals, I think. 2009 Apr 13 00:23:58 ahhhh, thanks! i had a major brain block and wasn't thinking recursively 2009 Apr 13 00:24:07 have i not learned anything!? :) 2009 Apr 13 00:24:16 how soon we forget! 2009 Apr 13 00:24:55 for diagonals you need to check whether any (col+n, row±n) is occupied 2009 Apr 13 00:25:13 yeah cool 2009 Apr 13 00:25:57 ok i should be good to go, thanks! 2009 Apr 13 00:26:30 jump back to 2.33? 2009 Apr 13 00:26:39 sure 2009 Apr 13 00:27:44 oh yeah, I did this one wrong the first time and had to go back 2009 Apr 13 00:28:11 http://mibbit.com/pb/EOw9nl 2009 Apr 13 00:28:25 I was thinking of accumulate as a fold-left 2009 Apr 13 00:28:32 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.33 2009 Apr 13 00:29:55 hm, my length lambda only takes one argument 2009 Apr 13 00:30:02 http://github.com/chrisconley/sicp-exercises/blob/66ffd41c76d8840c5987d60d7e778a616fbd5f74/chapter2/ex2-33.ss 2009 Apr 13 00:30:07 yours takes two 2009 Apr 13 00:30:50 oh yeah, it's going to be called with the element 2009 Apr 13 00:31:18 i have the same length as aamar it seems 2009 Apr 13 00:32:14 yeah mine was incorrect 2009 Apr 13 00:32:46 your map is different 2009 Apr 13 00:33:13 chrisconley: your map uses (p x y) while we have (cons (p x) y) 2009 Apr 13 00:33:21 yeah 2009 Apr 13 00:33:54 your map is more of a fold 2009 Apr 13 00:34:02 yeah whoops 2009 Apr 13 00:35:41 okay, otherwise everything matches 2009 Apr 13 00:35:45 yeah 2009 Apr 13 00:35:50 should we go on to 2.34? 2009 Apr 13 00:35:53 yeah 2009 Apr 13 00:35:57 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.34 2009 Apr 13 00:36:22 http://github.com/chrisconley/sicp-exercises/blob/66ffd41c76d8840c5987d60d7e778a616fbd5f74/chapter2/ex2-34.ss 2009 Apr 13 00:36:22 http://mibbit.com/pb/eBcA3f -- 2.34 2009 Apr 13 00:37:15 all the same 2009 Apr 13 00:37:34 wait 2009 Apr 13 00:37:38 mine is backwards 2009 Apr 13 00:37:44 whoops :-) 2009 Apr 13 00:38:27 right, results in an extra x factor. 2009 Apr 13 00:38:35 Okay, otherwise the same... 2009 Apr 13 00:38:38 yeah 2009 Apr 13 00:39:48 2.35 2009 Apr 13 00:39:53 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.35 2009 Apr 13 00:39:56 http://mibbit.com/pb/4Y194N -- 2.35 2009 Apr 13 00:40:50 http://github.com/chrisconley/sicp-exercises/blob/66ffd41c76d8840c5987d60d7e778a616fbd5f74/chapter2/ex2-35.ss 2009 Apr 13 00:40:59 nice, keep forgetting that "+" is a useful synonym for (lambda (x y) (+ x y)) 2009 Apr 13 00:41:13 i cheated a bit on this one 2009 Apr 13 00:41:50 aamar yours and mine look just the same 2009 Apr 13 00:42:24 i replaced (map (??) (??)) with (enumerate-tree t) 2009 Apr 13 00:42:35 ah 2009 Apr 13 00:43:07 alright, 2.36? 2009 Apr 13 00:43:37 http://github.com/chrisconley/sicp-exercises/blob/66ffd41c76d8840c5987d60d7e778a616fbd5f74/chapter2/ex2-36.ss 2009 Apr 13 00:43:39 ok 2009 Apr 13 00:43:59 http://mibbit.com/pb/WlfcIK -- 2.36 2009 Apr 13 00:44:53 all the same 2009 Apr 13 00:45:27 2.37? 2009 Apr 13 00:45:34 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.37 2009 Apr 13 00:45:35 ok 2009 Apr 13 00:45:49 http://github.com/chrisconley/sicp-exercises/blob/66ffd41c76d8840c5987d60d7e778a616fbd5f74/chapter2/ex2-37.ss 2009 Apr 13 00:46:10 http://mibbit.com/pb/zItO4C 2009 Apr 13 00:48:01 heh, my transpose has an unnecessary lambda 2009 Apr 13 00:49:15 chrisconley -- in your dot product (define (dot-product v w) (accumulate + 0 (map * v w))) -- I'm not sure of the use of map there... 2009 Apr 13 00:49:16 and looks like i should've replaced my second map in matrix*matrix with matrix*vector like inimino 2009 Apr 13 00:49:31 the map I have takes only one sequence 2009 Apr 13 00:50:29 oh I didn't look at that dot-product 2009 Apr 13 00:50:43 since it was given in the problem 2009 Apr 13 00:50:56 dot product is V0W0 + V1W1 +...+ ViWi 2009 Apr 13 00:51:08 but that's how it was given 2009 Apr 13 00:51:25 you're right -- I see that now. 2009 Apr 13 00:51:28 Hm. 2009 Apr 13 00:51:40 yeah i just went with the book's definition; my matrix operation knowledge is a bit rusty 2009 Apr 13 00:51:57 I think there was a footnote about it 2009 Apr 13 00:52:24 http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-15.html#footnote_Temp_190 2009 Apr 13 00:52:25 footnote 17 talks about the extended version of map 2009 Apr 13 00:52:51 http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-15.html#footnote_Temp_166 (actually this) 2009 Apr 13 00:53:13 thanks, completely missed those notes. 2009 Apr 13 00:53:49 so map is basically map-n (by analogy with accumulate-n) 2009 Apr 13 00:55:08 all of the rest looks similar 2009 Apr 13 00:55:44 2.38? 2009 Apr 13 00:55:56 yep, sure 2009 Apr 13 00:56:02 http://github.com/chrisconley/sicp-exercises/blob/66ffd41c76d8840c5987d60d7e778a616fbd5f74/chapter2/ex2-38.ss 2009 Apr 13 00:56:20 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.38 2009 Apr 13 00:56:20 http://mibbit.com/pb/H9CVrp -- 2.38 2009 Apr 13 00:57:00 when I got to this problem I had to go back and redo all the ones involving accumulate ;-) 2009 Apr 13 00:57:44 hehe, that must've been fun... 2009 Apr 13 00:58:16 yeah 2009 Apr 13 00:58:43 hm, you have commutativity where I have associativity 2009 Apr 13 00:58:56 yeah i think you're right; i think i got them mixed up 2009 Apr 13 00:59:02 and aamar didn't answer that part ;) 2009 Apr 13 00:59:23 forgot to paste it in 2009 Apr 13 00:59:28 ; associative property -- (op (op a b) c) = (op a (op b c)) -- guarantees equality 2009 Apr 13 00:59:41 it's also necessary for the initial value to have some property 2009 Apr 13 01:00:32 do you in fact need both associativity and commutativity? 2009 Apr 13 01:00:38 I guess to be the identity under that op, since it will actually come at different ends of the list 2009 Apr 13 01:00:47 trying to think of something that has one but not the other... 2009 Apr 13 01:00:59 I think you only need associativity 2009 Apr 13 01:01:03 http://en.wikipedia.org/wiki/Moyal_product is one 2009 Apr 13 01:01:30 but you also need for the zero op x = x op zero 2009 Apr 13 01:01:54 where zero is whatever initial value you provide 2009 Apr 13 01:02:09 (I think) 2009 Apr 13 01:02:32 prob. right 2009 Apr 13 01:03:44 Hm. I think it would take a while for me to use the Moyal product to test this claim. 2009 Apr 13 01:03:59 heh, yeah, me too 2009 Apr 13 01:04:14 probably easier to construct such an operation directly by using a table 2009 Apr 13 01:07:22 Well, it's easy to make one that's commutative but not associative: (abs (- a b)) 2009 Apr 13 01:08:20 true 2009 Apr 13 01:08:58 (fold-left (lambda (a b) (abs (- a b))) 0 (list 10 4 1)) ; => 5 2009 Apr 13 01:09:07 (fold-right (lambda (a b) (abs (- a b))) 0 (list 10 4 1)) ; =? 7 2009 Apr 13 01:09:16 ; => 7 I mean 2009 Apr 13 01:09:21 okay, that's good enough for me 2009 Apr 13 01:10:19 2.39 ? 2009 Apr 13 01:10:35 Complete the following definitions of reverse (exercise 2.18) in terms of fold-right and fold-left from exercise 2.38: (define (reverse sequence) (fold-right (lambda (x y) ) nil sequence)) (define (reverse sequence) (fold-left (lambda (x y) ) nil sequence)) 2009 Apr 13 01:10:35 ok 2009 Apr 13 01:10:50 http://mibbit.com/pb/TsWXLx -- 2.39 2009 Apr 13 01:10:50 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.39 2009 Apr 13 01:11:37 same. 2009 Apr 13 01:11:51 http://github.com/chrisconley/sicp-exercises/blob/66ffd41c76d8840c5987d60d7e778a616fbd5f74/chapter2/ex2-39.ss 2009 Apr 13 01:12:07 i didn't get the reverse working with fold-right 2009 Apr 13 01:12:42 seems simple now :) 2009 Apr 13 01:13:29 actually took a while to get that one 2009 Apr 13 01:13:44 And some trial and error too. 2009 Apr 13 01:13:44 yeah it was tricky 2009 Apr 13 01:14:08 I never test anything ;-) 2009 Apr 13 01:14:29 I think something like (append x (list y)) has appeared before 2009 Apr 13 01:14:52 but actually,,,, that was probably when I was using the backwards version of accumulate, heh 2009 Apr 13 01:16:12 2.40? 2009 Apr 13 01:16:16 ok 2009 Apr 13 01:16:27 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.40 2009 Apr 13 01:16:29 http://github.com/chrisconley/sicp-exercises/blob/66ffd41c76d8840c5987d60d7e778a616fbd5f74/chapter2/ex2-40.ss 2009 Apr 13 01:16:37 http://mibbit.com/pb/k3sGym -- 2.40 2009 Apr 13 01:17:27 I was actually talking to someone who'd done most of SICP when she was in college, she actually did all the assigned exercises by hand on paper. 2009 Apr 13 01:17:46 all look the same 2009 Apr 13 01:17:49 It was a while back I guess, when it wasn't likely you'd have a scheme interpreter runnable on Windows 3.1 or whatever. 2009 Apr 13 01:18:12 geez; i did everything on paper for most of chapter 1 2009 Apr 13 01:18:36 they all look the same 2009 Apr 13 01:18:49 yeah, I've only been running the ones that require you to 2009 Apr 13 01:19:17 like the ones that say "test your procedure by finding the largest prime after 100000000" or whatever 2009 Apr 13 01:19:18 i haven't done it lately because i've needed more hints 2009 Apr 13 01:19:42 ha, I'm glad I got the scheme interpreter working -- I just hit C-x C-e and it tests if I'm right 2009 Apr 13 01:19:51 I guess rudybot_ here is just as good 2009 Apr 13 01:19:55 which shows in the number of dumb mistakes that remain in my answers, like calling functions with the wrong number of arguments ;) 2009 Apr 13 01:20:30 inimino: i always wondered why you had plain text files :) 2009 Apr 13 01:20:42 that's why :-) 2009 Apr 13 01:21:12 I can cut and paste into MIT/GNU scheme when necessary 2009 Apr 13 01:22:12 for ones like "what is the result of (fold-left 1 / (list 1 2 3))" I seem to learn better by working it out mentally 2009 Apr 13 01:22:33 i should try to start the problems on paper more often; sometimes you can cheat by testing and not fully understand 2009 Apr 13 01:22:48 yeah 2009 Apr 13 01:23:32 i guess i should replace "you can cheat" with "you end up cheating" 2009 Apr 13 01:23:32 all of this accumulate and map and fold stuff is actually quite dense 2009 Apr 13 01:24:19 even though I was exposed to some of it previously, I still get confused a lot 2009 Apr 13 01:24:20 yeah there a lot of layers to keep in your head 2009 Apr 13 01:24:42 definitely attempted to cheat in 2.43, though it turned out not to help 2009 Apr 13 01:25:39 just think of the poor undergrad with no programming experience trying to get through this :) 2009 Apr 13 01:26:26 as an introduction to programming it really is pretty hardcore 2009 Apr 13 01:26:28 seriously! i never would've survived at the pace they go at 2009 Apr 13 01:27:14 some of the math might be fresher in mind though. 2009 Apr 13 01:27:22 it's been a while since I did any calculus. 2009 Apr 13 01:27:35 yeah, same here 2009 Apr 13 01:27:58 yeah true 2009 Apr 13 01:28:35 though I probably would have choked on matrices as a freshman 2009 Apr 13 01:29:07 but then I didn't go to MIT either ;) 2009 Apr 13 01:29:36 hm, where are we, 2.41? 2009 Apr 13 01:30:07 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.41 2009 Apr 13 01:30:25 that's the last one I finished 2009 Apr 13 01:30:57 http://github.com/chrisconley/sicp-exercises/blob/66ffd41c76d8840c5987d60d7e778a616fbd5f74/chapter2/ex2-41.ss 2009 Apr 13 01:30:58 http://mibbit.com/pb/7S0EgC -- 2.41 2009 Apr 13 01:32:51 (cadr (cdr x)) -> (caddr x) 2009 Apr 13 01:33:41 all look similar 2009 Apr 13 01:34:07 yep, good point 2009 Apr 13 01:34:22 yeah they look the same 2009 Apr 13 01:34:59 chrisconley: yours does an additional map, but conceptually I think it's the same 2009 Apr 13 01:35:24 yeah the extra map is just to create a list with the triple and the sum 2009 Apr 13 01:35:41 ((6 5 4 . 15) 2009 Apr 13 01:35:41 (7 5 3 . 15)......) 2009 Apr 13 01:35:49 ok, got it 2009 Apr 13 01:36:01 similar to make-pair-sum in the book 2009 Apr 13 01:36:07 yeah 2009 Apr 13 01:36:34 we all came out with the very same unique-triples 2009 Apr 13 01:36:55 so we must be doing something right :) 2009 Apr 13 01:36:57 I prob. should have used a fold for triple-sum like both of you did. 2009 Apr 13 01:37:30 I thought about doing it your way 2009 Apr 13 01:37:33 heh, yeah, i would've thought our solutions would be pretty diverse 2009 Apr 13 01:37:52 but it just seemed easier 2009 Apr 13 01:38:39 the wife has dinner ready, so i should run 2009 Apr 13 01:39:03 it was funny how they just introduced cadr without comment in an example 2009 Apr 13 01:39:18 chrisconley ok 2009 Apr 13 01:39:27 ok cool 2009 Apr 13 01:39:47 see you in two weeks? up to 2.52? or more? 2009 Apr 13 01:40:08 how about 2.58 ? 2009 Apr 13 01:40:24 that sounds good 2009 Apr 13 01:40:44 I guess the next ten should not take us a whole two weeks (though I haven't looked at them) 2009 Apr 13 01:41:03 2.44 through 2.48 are also trivial 2009 Apr 13 01:41:10 yeah that sounds good 2009 Apr 13 01:41:12 cool 2009 Apr 13 01:41:18 ok cool 2009 Apr 13 01:41:22 let's go for it 2009 Apr 13 01:41:23 ok see ya then! 2009 Apr 13 01:41:25 sounds good 2009 Apr 13 01:41:35 ok catch ya in a couple weeks 2009 Apr 13 01:41:37 (and thanks again for help on 42 earlier!) 2009 Apr 13 01:41:45 see ya