2009 Mar 30 00:05:18 so 2009 Mar 30 00:05:32 everybody here? 2009 Mar 30 00:06:00 chrisconley sent his regrets 2009 Mar 30 00:06:11 yes 2009 Mar 30 00:06:15 nicou: you around? 2009 Mar 30 00:07:06 anyone else awake? 2009 Mar 30 00:07:41 should we get started? 2009 Mar 30 00:07:50 I guess we might as well. 2009 Mar 30 00:08:29 ok 2009 Mar 30 00:09:08 mariorz: yt? 2009 Mar 30 00:10:20 let's see, 2.17 2009 Mar 30 00:10:24 wish IRC supported "idle time" or something. 2009 Mar 30 00:10:39 yeah 2009 Mar 30 00:11:06 Exercise 2.17. Define a procedure last-pair that returns the list that contains only the last element of a given (nonempty) list: (last-pair (list 23 72 149 34)) (34) 2009 Mar 30 00:11:34 http://mibbit.com/pb/C42wKT -- 2.17 2009 Mar 30 00:11:48 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.17 2009 Mar 30 00:12:33 ah, we did have length to use there 2009 Mar 30 00:12:56 that would count the whole list, though 2009 Mar 30 00:14:12 why do we have to use length? 2009 Mar 30 00:14:46 we don't 2009 Mar 30 00:14:56 I was just noticing that you had used it there 2009 Mar 30 00:15:28 where I had used (null? (cdr items)) 2009 Mar 30 00:15:36 Oh, one thing is that the exercise wants you to return a list 2009 Mar 30 00:15:37 what I meant was "we have it available to use" 2009 Mar 30 00:15:47 oh yeah 2009 Mar 30 00:16:11 so you should return items 2009 Mar 30 00:16:15 so I shouldn't have car there 2009 Mar 30 00:16:16 yeah 2009 Mar 30 00:16:30 I'm looking up chris's answer also 2009 Mar 30 00:17:21 nothing posted on github for him after 2.16 2009 Mar 30 00:17:25 hm, I don't see it 2009 Mar 30 00:17:38 yeah, he said he had finished a couple of them but I don't see them, oh well 2009 Mar 30 00:18:24 alright, we can move on I guess 2009 Mar 30 00:18:26 oh well, 2.18? 2009 Mar 30 00:18:43 yeah 2009 Mar 30 00:18:44 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.18 2009 Mar 30 00:18:46 Exercise 2.18. Define a procedure reverse that takes a list as argument and returns a list of the same elements in reverse order: (reverse (list 1 4 9 16 25)) (25 16 9 4 1) 2009 Mar 30 00:19:02 http://mibbit.com/pb/fkxX1l -- 2.18 2009 Mar 30 00:20:22 looks like mine is iterative and yours is recursive in the terminology the book uses 2009 Mar 30 00:20:59 pretty straightforward, 2.19? 2009 Mar 30 00:21:31 ok 2009 Mar 30 00:21:56 I thought some other people might wake up and join in... 2009 Mar 30 00:22:03 hm... strange 2009 Mar 30 00:22:31 Define the procedures first-denomination, except-first-denomination, and no-more? in terms of primitive operations on list structures. Does the order of the list coin-values affect the answer produced by cc? Why or why not? 2009 Mar 30 00:22:43 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.19 2009 Mar 30 00:23:01 I don't think it does affect the answer 2009 Mar 30 00:23:04 http://mibbit.com/pb/fwbOTb -- 2.19 2009 Mar 30 00:23:22 yeah 2009 Mar 30 00:24:16 looks pretty similar 2009 Mar 30 00:25:06 ok, yes, pretty nearly the same. 2009 Mar 30 00:25:12 yeah 2009 Mar 30 00:25:15 ok 2.20 2009 Mar 30 00:25:19 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.20 2009 Mar 30 00:25:30 this one was a little more interesting I thought 2009 Mar 30 00:25:52 http://mibbit.com/pb/wVo25S -- 2.20 2009 Mar 30 00:26:01 I found this one to be relatively difficult, yeah. 2009 Mar 30 00:27:20 wow, yours is a lot simpler than mine 2009 Mar 30 00:27:50 I didn't test mine 2009 Mar 30 00:28:48 I get: ;The object #f is not applicable. 2009 Mar 30 00:28:58 hm, yeah 2009 Mar 30 00:29:08 I think the last line at least is wrong 2009 Mar 30 00:29:57 and the line two lines above it 2009 Mar 30 00:30:22 haha 2009 Mar 30 00:30:45 I was thinking you could call it recursively like that but obviously that doesn't work 2009 Mar 30 00:31:27 It seems like it ought to, trying to figure out why... 2009 Mar 30 00:32:27 I guess because the recursive calls will be like (same-parity x (list ...)) instead of (same-parity x ...) 2009 Mar 30 00:32:38 Oh right. 2009 Mar 30 00:32:57 which doesn't explain the error exactly 2009 Mar 30 00:33:08 so I'd have to use a (define) in there 2009 Mar 30 00:33:55 or find some way we haven't been given yet to un-list something in a function call 2009 Mar 30 00:35:15 I'm also having a problem in my interpreter just running (= (odd? 4) (odd? 5)) 2009 Mar 30 00:35:24 ;The object #f, passed as the first argument to integer-equal?, is not the correct type. 2009 Mar 30 00:35:58 yeah, that's not working for me either 2009 Mar 30 00:36:08 oh... 2009 Mar 30 00:36:15 integer-equal? 2009 Mar 30 00:36:36 that's weird, I guess you can't do that for some reason 2009 Mar 30 00:36:51 I wonder how you get boolean-equal? 2009 Mar 30 00:37:46 worst case scenario: (define (match? x y) (or (and x y) (and (not x) (not y)))) 2009 Mar 30 00:37:52 but I bet there is somethign built in 2009 Mar 30 00:38:06 yeah 2009 Mar 30 00:41:20 alright, well that was broken in a number of ways 2009 Mar 30 00:42:13 I may need to start running my answers 2009 Mar 30 00:42:22 yours looks like it should work 2009 Mar 30 00:42:47 -=- offby1` is now known as offby1 2009 Mar 30 00:43:09 offby1: you around? 2009 Mar 30 00:43:23 I've gotten it working somewhat, but it's still sort of infinite looping 2009 Mar 30 00:43:33 inimino: no 2009 Mar 30 00:43:39 -*- offby1 glances around nervously. 2009 Mar 30 00:43:40 oh, let's see it 2009 Mar 30 00:43:52 offby1: oh, ok then ;-) 2009 Mar 30 00:43:56 (define (same-parity x . ys) (display ys) (cond ((null? ys) ()) ((= 1 1) (cons (car ys) (same-parity x (cdr ys)))) (else (same-parity x (cdr ys))))) 2009 Mar 30 00:44:02 http://mibbit.com/pb/YefGsy 2009 Mar 30 00:44:20 actually it's not working at all. 2009 Mar 30 00:44:25 I think I made it worse 2009 Mar 30 00:45:01 = 1 1 ? 2009 Mar 30 00:45:20 debugging code 2009 Mar 30 00:45:20 -*- inimino tries to fix it 2009 Mar 30 00:45:38 http://mibbit.com/pb/cgrvra 2009 Mar 30 00:45:41 in #scheme someone just pointed out eq works for what I wanted 2009 Mar 30 00:45:53 ok nice 2009 Mar 30 00:45:55 (eq (odd? 1) (odd? 3)) 2009 Mar 30 00:46:19 eq? for me 2009 Mar 30 00:46:21 #t 2009 Mar 30 00:46:28 rudybot_: eval (eq? (odd? 1) (odd? 3)) 2009 Mar 30 00:46:28 *offby1: ; Value: #t 2009 Mar 30 00:46:32 rudybot_: nick rudybot 2009 Mar 30 00:46:32 -=- rudybot_ is now known as rudybot 2009 Mar 30 00:47:03 rudybot: eval (eq? true false) 2009 Mar 30 00:47:04 aamar: your sandbox is ready 2009 Mar 30 00:47:04 aamar: ; Value: #f 2009 Mar 30 00:47:45 rudybot: eval true 2009 Mar 30 00:47:45 *offby1: ; Value: #t 2009 Mar 30 00:47:47 rudybot: eval false 2009 Mar 30 00:47:47 *offby1: ; Value: #f 2009 Mar 30 00:47:49 rudybot: eval maybe 2009 Mar 30 00:47:49 *offby1: error: reference to an identifier before its definition: maybe in module: 'program 2009 Mar 30 00:47:57 I didn't even know "true" and "false" were predefined. 2009 Mar 30 00:49:34 Okay, with the last code I gave, the problem does indeed become because ys is being populated with a list, instead of sending a flattened list of arguments 2009 Mar 30 00:49:54 In ruby this could be fixed by passing *ys instead of ys 2009 Mar 30 00:50:14 don't know how to fix it in scheme though 2009 Mar 30 00:50:22 yeah, I'm sure there's a way to do it, but I don't know either 2009 Mar 30 00:50:25 I put a define in there 2009 Mar 30 00:50:47 but I'm still getting #f is not applicable 2009 Mar 30 00:50:52 for some reason 2009 Mar 30 00:53:29 Okay, here's a fix, adding a define... 2009 Mar 30 00:53:48 http://mibbit.com/pb/Epe08h -- inimino 2.20 with changes 2009 Mar 30 00:55:31 oooh nice 2009 Mar 30 00:56:37 cool 2009 Mar 30 00:56:45 alright, next one? 2009 Mar 30 00:57:00 ok 2009 Mar 30 00:57:41 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.21 2009 Mar 30 00:57:46 http://mibbit.com/pb/6euVQO 2009 Mar 30 00:58:11 ah, I think the idea here was that the map version is shorter 2009 Mar 30 00:58:13 ok same 2009 Mar 30 00:58:25 yes :) 2009 Mar 30 00:58:54 ok, next http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.22 2009 Mar 30 01:00:25 http://mibbit.com/pb/tQHVdt - 2.22 2009 Mar 30 01:00:31 My explanation's not so great. 2009 Mar 30 01:00:51 Yours is clearer, but similar 2009 Mar 30 01:01:49 Should we go onto the next one? 2009 Mar 30 01:01:52 yours seems clear enough, yeah 2009 Mar 30 01:02:00 ok, next http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.23 2009 Mar 30 01:02:02 http://mibbit.com/pb/JqJDLv -- 2.23 2009 Mar 30 01:02:55 looks exactly the same 2009 Mar 30 01:03:30 apparently if you don't include anything after the test, cond returns the value of the test 2009 Mar 30 01:03:52 didn't know that, nice tip 2009 Mar 30 01:03:59 and I also discovered there is no way to do this using if 2009 Mar 30 01:04:12 (unless you use other stuff we haven't been given) 2009 Mar 30 01:04:13 okay, 2.24? 2009 Mar 30 01:04:16 yeah 2009 Mar 30 01:04:39 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.24 2009 Mar 30 01:05:38 http://mibbit.com/pb/D5QiWN -- 2.24 2009 Mar 30 01:05:48 Oh, wow, I just completely didn't do the box and pointers. 2009 Mar 30 01:05:50 Yours looks good 2009 Mar 30 01:06:43 ok 2009 Mar 30 01:07:02 the tree is the same in both 2009 Mar 30 01:07:12 next? 2009 Mar 30 01:07:17 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.25 2009 Mar 30 01:07:43 http://mibbit.com/pb/r3Vdsx 2009 Mar 30 01:07:44 oh, yeah, this one 2009 Mar 30 01:08:20 same answers 2009 Mar 30 01:08:29 cool 2009 Mar 30 01:08:56 http://mibbit.com/pb/W5TQI1 -- 2.26 2009 Mar 30 01:09:01 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.26 2009 Mar 30 01:09:24 also same 2009 Mar 30 01:09:51 27 is the last one I got to 2009 Mar 30 01:09:55 http://inimino.org/~inimino/projects/2009/SICP/chap_2/2.27 2009 Mar 30 01:10:11 ok 2009 Mar 30 01:10:49 http://mibbit.com/pb/ArQuqQ 2009 Mar 30 01:11:05 ok, very different 2009 Mar 30 01:12:24 yeah, pretty different 2009 Mar 30 01:13:09 yours handles everything in one function 2009 Mar 30 01:13:37 mine has one function that only deals with lists 2009 Mar 30 01:14:13 and if not pair? then it's handled outside 2009 Mar 30 01:17:09 I think I was actually trying to implement something closer to yours 2009 Mar 30 01:17:45 I didn't get this one right on the first try 2009 Mar 30 01:17:52 I started writing some code 2009 Mar 30 01:18:03 went away for lunch and came back and started over 2009 Mar 30 01:19:14 this material isn't really deep or anything, but it's a different way of dealing with lists than any other language I know 2009 Mar 30 01:19:43 I find it a little confusing 2009 Mar 30 01:20:13 yes, it does seem mentally demanding 2009 Mar 30 01:20:25 I found this section to be less work but harder thinking. 2009 Mar 30 01:20:43 yeah 2009 Mar 30 01:21:01 trying to figure out what (cons x y) did when x and y are lists 2009 Mar 30 01:21:40 that took me minutes of solid thinking 2009 Mar 30 01:22:01 of course now it seems totally obvious 2009 Mar 30 01:22:04 heh 2009 Mar 30 01:22:14 that's how learning works I guess ;-) 2009 Mar 30 01:22:24 yes 2009 Mar 30 01:22:37 did you get up through 2.32? 2009 Mar 30 01:22:54 yes, did through 2.38 2009 Mar 30 01:23:05 I procrastinated too long, so didn't make it ;-) 2009 Mar 30 01:23:25 so I guess we should have the next meeting in 2 weeks? 2009 Mar 30 01:23:30 what should we shoot for? 2009 Mar 30 01:23:36 Yes, I think that's good. 2009 Mar 30 01:24:05 ok 2009 Mar 30 01:24:07 Hm...2.52 is the end of section 2.2 2009 Mar 30 01:24:26 ok, let's do that 2009 Mar 30 01:24:35 Okay sounds good. 2009 Mar 30 01:24:49 do you have a log to send out? 2009 Mar 30 01:24:51 2.33 through 2.52 2009 Mar 30 01:24:59 yeah, I'll send out a log 2009 Mar 30 01:25:21 great 2009 Mar 30 01:26:35 let's see,... Apr 12 then 2009 Mar 30 01:26:45 cool 2009 Mar 30 01:26:50 ok, see you then :-)