ignore this one
Oct. 11th, 2004 11:49 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
From Paulson's ML for the Working Programmer:
And it's not that it's totally debilitating, trying to code in it, anymore... it's just that it's incredibly slow going, and the documentation sucks. And this is me whining that I could whip out the cs4240 project in LISP in like a quarter of the time, if that.
Nyip, off to go do things...
The product of a list of integers can be computed like this:*laughs* I guess I'd better give up ML for LISP, then, because that's exactly how I'd do it. I'm sure that ML is, uh, lovely when you get to know it (perhaps analogous to "I'm sure that deep down inside, he's a really nice guy..."), but it just feels pretentious, as a language. The Paulson text really doesn't help.
fun prod ns = if null ns then 1 else (hd ns) * (prod (tl ns));
If you prefer this version of prod, you might as well give up ML for Lisp. For added clarity, Lisp primitives have names like CAR and CDR. Normal people find pattern-matching more readable than hd and tl.
And it's not that it's totally debilitating, trying to code in it, anymore... it's just that it's incredibly slow going, and the documentation sucks. And this is me whining that I could whip out the cs4240 project in LISP in like a quarter of the time, if that.
Nyip, off to go do things...
no subject
Date: 2004-10-11 10:32 am (UTC)I think that's the point of that remark -- if you're going to be using ML, you might as well get the benefit of the built-in pattern matching! :)
no subject
Date: 2004-10-11 10:37 am (UTC)Of course, I'd probably rather just use:
if I was going to define prod as a function instead of just inlining the fold :)
no subject
Date: 2004-10-11 10:38 am (UTC)I've made too many comments already -- I should be more patient when writing them, then I wouldn't think of things after the fact!
no subject
Date: 2004-10-11 11:17 am (UTC)no subject
Date: 2004-10-11 04:09 pm (UTC)no subject
Date: 2004-10-11 02:40 pm (UTC)I swear I'm not an idiot!
no subject
Date: 2004-10-11 04:10 pm (UTC)no subject
Date: 2004-10-12 11:49 am (UTC)I read this and was all, "What?! What normal people would those be?" But then I remembered that this was ML pattern-matching, and not Perl or something.
And yeah, Paulson's example might look more like Lisp than ML, but that doesn't mean there wouldn't be other ways to do it in Lisp. Tail-recursive ways, for instance.
no subject
Date: 2004-10-12 02:49 pm (UTC)("Eh? What's all that crap on your screen? ...")