[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: functional programming is great, but why lists?



Bill,

> I'm perfectly sold on functional programming, i.e. no mutators.  But
> cons/list seems pretty cumbersome.  Why not use functions instead?

I'm missing something.  Are you extrapolating from this one example you've
found, to conclude that all uses of cons/list could be more efficient with
functions?  If that's true, based on the enormous code saving in your
example, I'll be your first convert.  However, I have a sneaking suspicion
that this might not apply to all uses of lists, wouldn't you agree?

If my suspicion is correct, the question you're really asking doesn't go
much beyond "why did the authors of The Seasoned Schemer use a longer
algorithm than strictly necessary in this example?"  I can only speculate,
but when I've written articles and contributions to books, I've found it can
be quite difficult to come up with small examples that illustrate a point
meaningfully, without being somewhat forced.  Because examples are
necessarily small, the complexity of the point being illustrated often isn't
justified in the example itself.  It seems as though that might be the case
here.

Anton