00:06 (join) mahsohn 00:10 (join) adadglgmut 00:58 (quit) adadglgmut: Ping timeout: 240 seconds 01:29 (join) sam__ 01:30 sam__: hey everyone, I was wondering if anyone here has gone through drafts of HtDP 2e? 01:38 (quit) jonrafkind: Ping timeout: 240 seconds 01:39 (join) jonrafkind 01:46 (quit) jonrafkind: Ping timeout: 260 seconds 01:47 (part) sam__ 01:58 (join) jonrafkind 02:43 (quit) jonrafkind: Ping timeout: 248 seconds 03:04 (join) pdelgallego 03:28 (quit) jao: Ping timeout: 245 seconds 03:39 (join) mahsohn1 03:39 (quit) mahsohn: Read error: Connection reset by peer 03:47 (quit) sstrickl: Quit: sstrickl 04:17 (quit) hanDerPeder: Quit: hanDerPeder 04:39 (join) hellmage 04:54 (join) hanDerPeder 05:05 (join) masm 07:09 (part) hellmage 09:32 (join) carleastlund 10:56 (join) sunnyps 11:23 (join) shkk 11:42 (quit) shkk: Quit: Page closed 11:50 (join) jonrafkind 11:51 (quit) jonrafkind: Read error: Connection reset by peer 11:51 (join) jonrafkind 12:00 (join) sstrickl 12:02 (quit) hanDerPeder: Read error: Operation timed out 12:10 (quit) jonrafkind: Read error: Connection reset by peer 12:11 (join) jonrafkind 12:26 (join) shkk 12:26 shkk: Hi All, can we simulate the foldl function of ML in Scheme ? 12:27 jonrafkind: simulate? you know its already there right? 12:27 jonrafkind: but to answer your question, yes you can easily write foldl in scheme 12:27 shkk: the foldl/foldr equivalent in Scheme?? 12:27 (quit) sunnyps: Read error: Connection reset by peer 12:28 jonrafkind: yea, its called 'foldl' 12:28 jonrafkind: just type it into the repl 12:29 shkk: But I tried the foldl, can you look at my code and let me know the issue ? 12:29 jonrafkind: ok 12:29 shkk: http://paste.bradleygill.com/index.php?paste_id=41293 12:29 shkk: The function evaluates obviously .. but how do I delay evaluation of the function ? 12:31 jonrafkind: dont you have too many parenthesis around the first argument to `myfoldl' ? 12:32 shkk: I dont think so: Are you talking about this: (func init (car input)) ?? 12:33 jonrafkind: yea 12:33 jonrafkind: actually you are passing in all the arguments as the first one 12:33 shkk: I dont think so. 12:33 shkk: Yes . 12:34 shkk: That would evaluate as soon as it is called. How shud I delay it ? 12:34 shkk: Or maybe my code is wrong 12:34 jonrafkind: just get rid of one of the parenthesis 12:34 jonrafkind: you basically wrote (myfoldl (args)) when you meant (myfoldl args) 12:36 shkk: Okie got it. but still, that would evaluate right away. so the 2nd call would have the evaluation of the function and not a function call itself 12:37 shkk: like if the function being passed is a add1 function. 12:37 jonrafkind: right, so your algorithm is incorrect somehow 12:38 jonrafkind: also your base case is flawed 12:38 jonrafkind: write some examples that help you understand how foldl should work. write an example with 0, 1, and 2 elements 12:41 shkk: Okie. Will get back to you if I have any updates 13:20 shkk: jonrafkind, http://paste.bradleygill.com/index.php?paste_id=41297 13:21 jonrafkind: ok 13:21 jonrafkind: yea I think that achieves what you want 13:21 shkk: I mean can you please take a look and let me know if this is full proof or if you have any suggestions 13:22 shkk: Do you think we can implement foldr as well? I mean we would have to reverse the input list using reverse function right and then use the same code ? 13:34 (quit) shkk: Quit: Page closed 14:23 (join) hanDerPeder 15:03 (quit) hanDerPeder: Quit: hanDerPeder 16:33 (join) jao 16:47 (quit) sstrickl: Quit: sstrickl 17:02 (join) paul_stansifer 17:22 (join) Nanakhiel 17:25 (quit) Lajla: Ping timeout: 240 seconds 17:31 (join) hanDerPeder 17:48 (quit) pdelgallego: Ping timeout: 246 seconds 17:51 paul_stansifer: jonrafkind: I understand that you're working on something called Honu? 17:51 jonrafkind: yea 17:51 paul_stansifer: It's syntax-extensible, but not S-expression-based? 17:51 jonrafkind: right 17:51 paul_stansifer: How does syntax extension work? What forms may macro invocations take? 17:52 jonrafkind: right now they have to appear at the head of the list 17:52 jonrafkind: i am experimenting with allowing macros to appear anywhere in a form 17:53 jonrafkind: its not that different from regular s-expression macros, the only real difference is pattern variables get expanded before you inject them into the template, and also you usually have to be explicit about where the macro ends 17:53 jonrafkind: you can force the system not to expand pattern variables though, if needed 17:53 paul_stansifer: Okay. 17:54 jonrafkind: usually you don't want to expand forms if you are binding new variables (like in `let' or something) 17:54 paul_stansifer: Expand forms under the 'let'? 17:55 jonrafkind: if you expanded the body of a let before binding the variables then the bindings wouldn't have the proper effect on the body 17:56 jonrafkind: oops gotta run, ill be back later 17:56 paul_stansifer: I think that Dybvig-style hygiene does just that, though. 17:57 paul_stansifer: (I guess that, in some sense, it binds the variables as it descends into the 'let') 17:58 chandler: paul_stansifer: Are you familiar with Dylan? 17:59 paul_stansifer: Only a little bit. 17:59 Nanakhiel: Dylan also did that right? 17:59 Nanakhiel: Or it later on switched to a conventional Lisp notation I believe. 18:00 Nanakhiel: But it used to be pretty much ALGOL in syntax. 18:00 (nick) Nanakhiel -> Lajla 18:00 paul_stansifer: I think I recall that macros in the ALGOL-style syntax were restricted in some way? 18:00 Lajla: Oh no, te other way around aparently 18:00 Lajla: http://en.wikipedia.org/wiki/Dylan_(programming_language)#Syntax 18:00 chandler: Lajla: That's the opposite of what happened. 18:00 (quit) jonrafkind: Ping timeout: 276 seconds 18:01 chandler: It started with a Lisp-like syntax, then went to an infix syntax in order to make it more appealing outside the lab at Apple. 18:01 Lajla: 'If you want lisp with a C like syntax, it's there, it's called javascript' 18:02 chandler: Yes, JavaScript is just like Lisp, except for all of the things that distinguish Lisp from other programming languages. 18:02 Lajla: I really feel I only started to understand javascript after I got a grasp on Scheme. 18:02 Lajla: chandler, hardly, the creator of Javascript originally wanted to use Scheme for web scripting but netscape ordered him to use a C like syntax. 18:02 paul_stansifer: Aw, but JS doesn't have macros! 18:03 chandler: paul_stansifer: There are several different places where macros can be used in Dylan. Macros are defined with `syntax-rules' style pattern matching. 18:03 chandler: Lajla: Yes, and he plainly didn't understand anything about Scheme, because JavaScript retains none of the distinguishing features of Scheme. 18:04 Lajla: chandler, has anyone ever told you 'if it's extremely easy to see why some one is wrong, most likely that person has some extra info you don't have'? 18:05 Lajla: Seriously, do you really think people would say this if you could refute it in a second? 18:05 chandler: Yes. 18:06 Lajla: which is answer to which of the two quaestions? 18:06 paul_stansifer: It looks like Dylan macros are fairly free-form -- I'm seeing one "if _ then _ else _" macro here. I have vague memories that they had to start with a keyword, to avoid ambiguity. 18:06 chandler: To the latter. People have said things like the former to me before, but I'm fairly certain that statement is wrong too. 18:06 paul_stansifer: (but I don't see anything about this as I'm skimming the macro documentation) 18:07 Lajla: chandler, and do you also think it's wrong for such a simple reason as the one you stated? 18:08 chandler: In fact, I'll now demonstrate. It's very easy to see that JavaScript is not like Scheme. What distinguishes Scheme is the S-expression syntax, the presence of macros, proper tail calling, a well-designed numeric tower, and first class continuations. (There are probably a few others I've missed there too.) 18:08 chandler: JavaScript retains none of these. 18:09 Lajla: How about first class functions, unified namespace of values and functions, lexical scope / closures, dynamic typing? 18:09 chandler: If JavaScript had an infix syntax, macros, tail calling, proper and well-designed numerics, and continuations, I'd grant that it was like Scheme. 18:09 Lajla: Also, the numerical tower is hardly Scheme, it's a part of Common Lisp if any that was later only applied to SCheme. 18:10 Lajla: Well, then you have to agree that your version of Scheme like and C-like syntax are about impossible to unify. 18:10 chandler: Really? 18:11 Lajla: Most likely. 18:11 chandler: The numeric tower is in fact part of the Common Lisp heritage, though it was refined even further by Scheme. We can broaden the argument to "JavaScript is not like Scheme or Common Lisp", if you like. 18:12 Lajla: Also, well, macros and the numerical tower weren't part of rnrs from the start if I recal correctly. 18:12 chandler: What would have prevented JavaScript from incorporating proper tail calling? First-class continuations? Non-broken numerics? Even hygienic syntactic abstraction? 18:12 Lajla: I would say it was not like common lisp yeah. 18:12 Lajla: To start with, Javascript is not homo-iconic. 18:12 Lajla: It's syntax is textual, not defined in some data structure. 18:12 chandler: homoiconicity is not a requirement for hygienic syntactic abstraction. Again, see Dylan. 18:13 Lajla: Proper tail calls could of course be put there. 18:13 Lajla: Dylan is not homo-iconic? 18:13 chandler: No. It has an infix syntax. 18:14 Lajla: How is homo iconic and infix syntax disjoint? 18:14 Lajla: I can perfectly well rew-rite eval such that the list (2 + 5) is evaluated to 7 18:14 chandler: Er, sorry. It has a textual syntax similar to ALGOL. 18:14 Lajla: Yes, it has no praefix notation, but as far as I know it's still homo-iconic and most likely praefix behind te screens. 18:15 Lajla: But algol syntax is different from C like syntax, an important area being that what are often expressions in ALGOL are statements in C. 18:15 chandler: I don't understand the distinction you're drawing between JavaScript syntax and Dylan syntax. In both cases, a parser is employed to convert tokenized text into an abstract syntax tree. 18:16 chandler: There is nothing "prefix behind the screens" about how Dylan is implemented. 18:16 chandler: Except within a Dylan compiler, there is no data structure in Dylan other than that used for text which represents a Dylan expression. 18:16 Lajla: Well, if you say so, it woukd seem the most straightforward to me to just map the bottom example to the top. 18:16 Lajla: And the macros are still hygienic? 18:16 chandler: Yes. 18:17 Lajla: And in a pattern language, right? 18:17 Lajla: Like, not low level? 18:17 chandler: Correct. 18:17 Lajla: And you have no aequivalent of apply? 18:18 chandler: And on a previous point - who cares what was in RnRS from the start? By the time JavaScript was invented, Scheme had hygienic macros. 18:18 chandler: There is an equivalent of apply. How does that relate? 18:19 Lajla: Some would call the existence of apply enough to justify calling a language homo-iconic, it's why prolog is often called homo-iconic. 18:19 Lajla: Also, R4RNS did not require hygenic macros if I recall correctly. 18:20 chandler: I think you're confusing two different concepts there. 18:20 Lajla: And which two? 18:20 Lajla: http://en.wikipedia.org/wiki/Homoiconic#Homoiconicity_in_Prolog 18:21 Lajla: I would say that the things which differentiated Scheme from other lisps fundamentally were tail calls, lexical scope and a unified namespace. The rest essentially follows from it, javascript has two of those. 18:22 chandler: First class continuations don't follow from those at all. 18:22 Lajla: Macros also essentially developed because some one had a 'nice realization', just as hygenic macros developed because some one realize 'but hey, if all variables are lexical that means ...' 18:22 Lajla: Oh yeah forgot those. 18:23 Lajla: Any way, first class continuations can be simulated in javascript by wrapping the entire code into one big huge arse function literal. 18:24 chandler: Lexical scope distinguished Scheme from other Lisps, but it did not distinguish Scheme from other programming languages. 18:25 Lajla: That's true, but I still wouldn't take back my claim that Javascript arose from a compromise of scheme in a C like syntax 18:25 chandler: The Prolog example in that Wikipedia entry does not demonstrate that `apply' makes a language homoiconic. 18:25 Lajla: The guy who designed it originally just wanted to use Scheme and it's more Scheme like than a lot of languages out there. 18:27 chandler: Has anyone ever told you that the road to hell is paved with good intentions? It doesn't matter what he *wanted*. What he designed lacks several essential characteristics of Scheme, including the two that provided the original impetus for the design of Scheme in the first place, namely proper tail calling and call/cc. 18:28 Lajla: I suppose one can say that. 18:28 Lajla: Still do you know a lot of languages that are closer to Scheme 18:28 chandler: I will grant that the presence of lexical scope and closures was inspired by Scheme, but by 1995 or so those were no longer distinguishing features. 18:29 chandler: Dylan in its infix syntax form, which predated (narrowly) JavaScript, is much closer to Scheme. 18:30 Lajla: Hmm, I suppose that could be said. 18:38 (quit) masm: Quit: Leaving. 19:13 (join) Toekutr 20:24 (quit) Lajla: Quit: Phallic Illuminatus 21:15 (join) hellmage 21:19 (quit) carleastlund: Quit: carleastlund 21:33 (quit) hanDerPeder: Quit: hanDerPeder 21:39 (join) Lajla 21:57 (quit) Toekutr: Quit: REALITY IS TEARING ITSELF ASUNDER, BUT I MUST RACE 22:39 (join) jonrafkind