2009 Oct 26 00:04:23 hello? 2009 Oct 26 00:04:28 hey 2009 Oct 26 00:04:49 how's it going inimino? 2009 Oct 26 00:05:06 pretty good 2009 Oct 26 00:05:32 just finished up the last of these exercises :) 2009 Oct 26 00:05:42 ok 2009 Oct 26 00:05:54 Got stuck just before the end... 2009 Oct 26 00:06:25 well, I did partly skip one of them (4.10) 2009 Oct 26 00:06:35 should we start? 2009 Oct 26 00:07:32 yes, let's start 2009 Oct 26 00:07:33 4.2 2009 Oct 26 00:07:36 ok 2009 Oct 26 00:07:50 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.2 2009 Oct 26 00:08:04 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L21-29 2009 Oct 26 00:08:45 same answer, looks like 2009 Oct 26 00:08:54 yep, looks like 2009 Oct 26 00:09:00 4.3? 2009 Oct 26 00:09:30 yes 2009 Oct 26 00:09:34 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L30-44 2009 Oct 26 00:09:40 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.3 2009 Oct 26 00:10:02 actually: http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L30-69 2009 Oct 26 00:13:05 not that different actually 2009 Oct 26 00:13:23 yeah, I left out the test for application? 2009 Oct 26 00:13:26 I probably shouldn't have used operator where i did, inside the "get" call 2009 Oct 26 00:13:53 Yes, you can include that and otherwise error out 2009 Oct 26 00:14:18 I had a little bit of the code to "put" things in too, but none of it was interesting 2009 Oct 26 00:14:40 oh, mine is inside pair? so I guess I should have put that "Unknown expression type" after that 2009 Oct 26 00:14:57 ok, yeah I didn't run any of the code in this chapter so far 2009 Oct 26 00:15:05 oh, and you made 'variable data-directed too, which seems better 2009 Oct 26 00:15:51 Me neither, for the most part. 2009 Oct 26 00:15:58 Book made it fairly hard to do so. 2009 Oct 26 00:16:21 4.4 ? 2009 Oct 26 00:16:27 ok, sure 2009 Oct 26 00:16:42 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.4 2009 Oct 26 00:17:00 this one had a couple unexpected glitches 2009 Oct 26 00:17:30 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L69-92 2009 Oct 26 00:18:37 see some issues in mine 2009 Oct 26 00:21:39 regarding the return value? 2009 Oct 26 00:27:35 in your and->if, I think when and->if recurs, you should call (and->if (cons 'and rest)) 2009 Oct 26 00:27:35 or similar 2009 Oct 26 00:27:35 otherwise it's fine 2009 Oct 26 00:27:35 github's flaky on me for a moment, so I'm waiting on giving my corrected version 2009 Oct 26 00:27:50 ok 2009 Oct 26 00:27:53 -*- inimino looks 2009 Oct 26 00:28:28 ah, I think you're right 2009 Oct 26 00:28:56 I think I'll just create another procedure 2009 Oct 26 00:29:45 Okay, I see that I also missed how and and or are supposed to work -- mine always return 'true or 'false 2009 Oct 26 00:31:04 minor -- in or->if you recurse to and->if 2009 Oct 26 00:31:48 I agree with your caveat, now. An eval-or special form seems like the only possible solution here. 2009 Oct 26 00:32:28 (given that there's no way to guarantee a unique binding for a let-style solution) 2009 Oct 26 00:33:06 ah, so I did; ok, I fixed that, the other thing, and a typo or two 2009 Oct 26 00:33:26 yeah, ok, agreed 2009 Oct 26 00:34:52 slightly updated mine, but it's still does not address all the issues 2009 Oct 26 00:35:00 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L70-93 2009 Oct 26 00:36:23 should we move on to 4.5? 2009 Oct 26 00:37:12 ok, sure 2009 Oct 26 00:37:33 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.5 2009 Oct 26 00:38:21 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L95-115 2009 Oct 26 00:42:00 does your arrow-form? case on line 111 call the recipient immediately? 2009 Oct 26 00:42:47 hm. looks like yes 2009 Oct 26 00:43:18 perhaps a cons call would solve that 2009 Oct 26 00:43:32 I think it needs an extra make-if and a make-application, or something like that 2009 Oct 26 00:44:09 right, make-application might do it 2009 Oct 26 00:44:21 (which would basically be a cons) 2009 Oct 26 00:44:27 yeah, you could solve it with cons and quote too, though at the cost of syntax-abstraction 2009 Oct 26 00:44:44 ok 2009 Oct 26 00:45:02 yours doesn't appear to handle "normal" cond clauses anymore 2009 Oct 26 00:45:04 or, I guess you wouldn't need quote 2009 Oct 26 00:45:44 oh yeah, quite so 2009 Oct 26 00:46:08 I think I meant to add another cond branch for those, after I decided not to try to do it all in one 2009 Oct 26 00:46:48 Trying to understand why I have sequence->exp and you have eval-sequence 2009 Oct 26 00:47:20 Oh, I see 2009 Oct 26 00:47:29 You are turning it into a special form 2009 Oct 26 00:47:36 yeah 2009 Oct 26 00:48:33 Ok, and in my version, if one of those cond clauses evaluates to true, it will be eval'd again when passed to the recipient. 2009 Oct 26 00:48:34 Ok 2009 Oct 26 00:49:35 yeah 2009 Oct 26 00:49:45 ok, exhausted this one 2009 Oct 26 00:49:47 I think I have eval-cond where I need eval-cond-clauses here 2009 Oct 26 00:50:35 ok, I think I fixed that 2009 Oct 26 00:50:38 next one? 2009 Oct 26 00:50:42 yes 2009 Oct 26 00:50:43 4.6? 2009 Oct 26 00:50:43 4.6 2009 Oct 26 00:50:44 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L117-139 2009 Oct 26 00:51:02 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.6 2009 Oct 26 00:53:17 very similar 2009 Oct 26 00:53:41 mostly similar 2009 Oct 26 00:53:43 I used car and cadr directly on the let bindings 2009 Oct 26 00:53:58 let-body: you have caddr 2009 Oct 26 00:54:07 I have cddr 2009 Oct 26 00:54:40 oh, cddr is right I think 2009 Oct 26 00:54:58 checking how make-lambda works... 2009 Oct 26 00:54:58 we want the rest of it, after all, not just the first expression 2009 Oct 26 00:55:32 yes, okay, so cddr seems to work 2009 Oct 26 00:55:42 okay, otherwise these look equivalent. cool 2009 Oct 26 00:56:20 ok 2009 Oct 26 00:56:28 4.7? 2009 Oct 26 00:56:55 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L140-163 2009 Oct 26 00:57:08 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.7 2009 Oct 26 01:01:35 some differences in make-let 2009 Oct 26 01:01:41 same issue with body being multiple expressions -- affects let*-body and make-let 2009 Oct 26 01:02:24 the recursive in your nested-lets is a little different in order from my expand-let*, but it should be equivalent except for an extra (list ...) procedure in mine 2009 Oct 26 01:02:58 yeah, I think these are more or less equivalent 2009 Oct 26 01:03:56 I see -- the difference in make-let does explain the use of list in mine. 2009 Oct 26 01:04:20 yeah, I think we just chose different representations for lets 2009 Oct 26 01:04:44 well, it goes back to whether you allow let to have multiple expressions inside the body 2009 Oct 26 01:04:54 otherwise it's just a different representation, agreed 2009 Oct 26 01:05:24 yeah, I guess since we are implementing Scheme here, mine isn't correct 2009 Oct 26 01:05:36 haha 2009 Oct 26 01:05:52 4.8... 2009 Oct 26 01:06:00 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L164-203 2009 Oct 26 01:06:44 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.8 2009 Oct 26 01:07:27 actually I did two versions of this one, neither of which is quite correct 2009 Oct 26 01:08:01 where's the other? 2009 Oct 26 01:08:04 the other one is http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.8_1 2009 Oct 26 01:09:03 the trouble is the same I think as yours has 2009 Oct 26 01:09:30 which is that if you're using begin and define, you're leaking the binding of the named let into the outer environment 2009 Oct 26 01:09:51 I think the idea is that you can use the name inside the body of the let but not outside it 2009 Oct 26 01:10:38 interesting 2009 Oct 26 01:10:43 so if that's the case, the way to actually do it is to create a lambda, and then use a define at the beginning of the lambda 2009 Oct 26 01:11:00 so basically wrapping the whole thing in a lambda would fix it? 2009 Oct 26 01:11:09 yeah, I think so 2009 Oct 26 01:12:26 ok, so your 4.8_1 is the equivalent of my 4.8 2009 Oct 26 01:12:38 yeah looks like it 2009 Oct 26 01:12:40 confirmed that mine leaks the define into the environment 2009 Oct 26 01:13:09 so, okay, will try wrapping this in a lambda to force a new frame to be created 2009 Oct 26 01:13:29 maybe a bit later though :) 2009 Oct 26 01:13:34 alright :) 2009 Oct 26 01:13:38 4.9? 2009 Oct 26 01:13:44 oh, 4.9 I skipped :( 2009 Oct 26 01:13:56 oh, ok 2009 Oct 26 01:14:06 not a bad idea, you can see mine here: http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.9 2009 Oct 26 01:14:15 but it's not terribly fascinating 2009 Oct 26 01:14:55 it occurred to me that something like do-while, or any while loop or for loop 2009 Oct 26 01:15:00 actually, I missed entirely the idea to use a named-let and tried to use if's only 2009 Oct 26 01:15:07 and that's why I got stuck in a way. 2009 Oct 26 01:15:11 ah 2009 Oct 26 01:15:32 although you've used "get-new-identifier" 2009 Oct 26 01:15:35 I figured if we'd implemented named-let and let* we could be allowed to use them so I used them freely from here out 2009 Oct 26 01:15:40 yeah I cheated with that 2009 Oct 26 01:16:20 but since it's only bound in the body of the let, it really only needs to be some variable that's not occurring inside it 2009 Oct 26 01:17:05 but it also needs to avoid conflicting with anything in the enclosing env, right? 2009 Oct 26 01:17:21 not if it's not mentioned in the expression 2009 Oct 26 01:17:28 true 2009 Oct 26 01:17:30 got it 2009 Oct 26 01:17:35 but I noticed that any kind of loop is only useful if yog have assignment 2009 Oct 26 01:18:07 in a language with referential transparence (like Scheme before we had set!) something like while (x < 10) would be useless 2009 Oct 26 01:18:22 I guess that's somewhat obvious but this is the first time it occurred to me ;) 2009 Oct 26 01:18:40 anyway, 4.10? 2009 Oct 26 01:18:47 hang on a sec there... 2009 Oct 26 01:19:08 erm s/transparence/transparency/ 2009 Oct 26 01:19:17 you could do something like (while while-proc do-proc), right? 2009 Oct 26 01:19:30 where while-proc is a lambda that accepts a value of x? 2009 Oct 26 01:19:42 actually, no, I'm not sure that's feasible 2009 Oct 26 01:19:52 yes, but it would give the same value every time if you didn't have assignment 2009 Oct 26 01:20:07 I remember this concept that loops are only useful with assignment, but at the moment it's not mentally adding up... 2009 Oct 26 01:20:10 well, depending on how you meant that 2009 Oct 26 01:20:26 well, if you have something like while(i<10) ... 2009 Oct 26 01:20:40 it's assumed that i is always the 'same' variable 2009 Oct 26 01:20:50 oh I see 2009 Oct 26 01:20:54 Now I get it 2009 Oct 26 01:21:03 thanks 2009 Oct 26 01:21:07 4.10 ? 2009 Oct 26 01:21:08 so if there was no way for i to change, that would either never run or never terminate 2009 Oct 26 01:21:09 ok 2009 Oct 26 01:21:17 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L220-247 2009 Oct 26 01:21:20 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.10 2009 Oct 26 01:21:49 actually felt that given 4.2 and 4.5 this one was arguably redundant 2009 Oct 26 01:22:50 yeah, probably 2009 Oct 26 01:23:02 I didn't really implement it, but described something a little more radical 2009 Oct 26 01:23:42 quite a bit 2009 Oct 26 01:23:50 heh 2009 Oct 26 01:23:50 how does the factorial (n - 1) part work? 2009 Oct 26 01:24:01 the parens mean grouping 2009 Oct 26 01:24:47 so when it hits that it just turns it into what would be (factorial (- n 1)) normally 2009 Oct 26 01:24:54 well, take the section that is n * factorial (n - 1) j 2009 Oct 26 01:24:55 the () don't mean application anymore 2009 Oct 26 01:25:08 the * will consume n and factorial and attempt to multiply them, 2009 Oct 26 01:25:46 I was thinking that function application would bind tighter than * 2009 Oct 26 01:25:57 (as it does in Haskell) 2009 Oct 26 01:26:03 sure, so you are setting some kind of order of operations in which factorial ( n - 1) gets evaluated before n * factorial ? 2009 Oct 26 01:26:20 yeah, that's the idea 2009 Oct 26 01:26:48 you can probably see why I wasn't enthusiastic about implementing it ;) 2009 Oct 26 01:27:21 so I guess, as in javascript and so on, you, 'factorial' means the procedure, and 'factorial()' means the results of running the procedure? 2009 Oct 26 01:27:42 actually function application is more Haskell-like here 2009 Oct 26 01:27:51 I realize now I didn't describe that part 2009 Oct 26 01:28:03 "f x" means the application of f to x 2009 Oct 26 01:28:07 I guess there are a few ways to make that call. 2009 Oct 26 01:28:49 so the parens wouldn't be necessary except for the fact that function application binds more tightly than subtraction 2009 Oct 26 01:29:32 my main point or question was really just that, that the parens aren't just used to group (n - 1), they're (possibly) also indicating that factorial should be executed before the multiplication operator consumes the operation. 2009 Oct 26 01:29:39 that's why "display factorial 7" works later on, though it's possible that should have actually been 'display (factorial 7)' 2009 Oct 26 01:30:29 yeah, they could be used to indicate that, though it wasn't what I had in mind 2009 Oct 26 01:30:47 it would perhaps make things cleaner and less ambiguous 2009 Oct 26 01:31:29 one of the potential ambiguities in Haskell syntax is what order functions are applied to arguments, which using parens for function application completely eliminates 2009 Oct 26 01:31:39 (I should be playing around with Haskell a little more) 2009 Oct 26 01:31:57 (like whether f g x means (f g) x or f (g x)) 2009 Oct 26 01:32:25 it's not actually ambiguous, just that there's a lot of syntax required to work around those issues, like the $ operator 2009 Oct 26 01:32:42 in other news, everything in programming language design is a tradeoff ;-) 2009 Oct 26 01:32:43 (definitely will do that when time can be found...) 2009 Oct 26 01:32:43 Let's go to 4.11 ? 2009 Oct 26 01:32:43 http://github.com/aalearn/aalearn-sicp/blob/master/ch4-outline.scm#L248-259 2009 Oct 26 01:32:49 yeah lets :) 2009 Oct 26 01:33:04 http://inimino.org/~inimino/projects/2009/SICP/chap_4/4.11 2009 Oct 26 01:34:42 yours looks like the implementation I wrote at first, but I don't think add-binding-to-frame! can work like that 2009 Oct 26 01:35:23 in the case where the frame starts out empty, you won't be able to set-cdr! on '() 2009 Oct 26 01:35:56 and if it's not empty (set-cdr! frame frame) creates a loop even after you set-car! on the next line 2009 Oct 26 01:36:00 still there? 2009 Oct 26 01:36:05 yeah 2009 Oct 26 01:37:02 am I lagging? 2009 Oct 26 01:38:24 so if you (set-cdr! frame frame), then the cdr of frame is a pointer to that same pair. 2009 Oct 26 01:38:53 aamar: you there? 2009 Oct 26 01:40:30 :/ 2009 Oct 26 01:42:26 aamar? 2009 Oct 26 01:42:31 actually getting late... 2009 Oct 26 01:42:31 might need to head out 2009 Oct 26 01:43:26 ok 2009 Oct 26 01:43:46 want to pick up here next time? 2009 Oct 26 01:46:47 <-- aamar (n=aamar@204.14.159.249) has quit (Read error: 104 (Connection reset by peer)) 2009 Oct 26 01:47:33 hm, I guess he wasn't seeing my replies 2009 Oct 26 01:47:38 :( 2009 Oct 26 01:49:09 --> aamar (n=aamar@204.14.159.249) has joined ##SICP 2009 Oct 26 01:50:24 hey aamar 2009 Oct 26 01:50:34 did you see my replies? 2009 Oct 26 01:52:41 hrm 2009 Oct 26 01:52:53 -*- inimino needs to head out soon too 2009 Oct 26 01:56:33 let's pick up in 2 weeks -- should be able to finish up though 4.25 2009 Oct 26 01:56:41 ok 2009 Oct 26 01:57:16 ok, see you in two weeks!