Re: recursion performance



Pascal Costanza wrote:
Both versions cheat because even the second version uses the 1+ and 1- functions. It's no wonder that the OP feels confused because the suggested answer is confusing.

Well, I'm assuming that 1+ and 1- are primitives to use. Of course it would be nicer to have something like a zero (or nil) and an add1 function that pushes a value onto the list...


If you don't want to cheat, you can only do this by encoding numbers manually, for example implicitly by the number of atoms in a list, or some such.

But in the end I think it doesn't really matter how the primitives work, as long as you use only them.


Again, this exercise doesn't teach anything about Lisp.

Nothing specific, no. Maybe the OP is just getting a feel for the language.

I don't think posting a (even useless) Lisp program on c.l.l hurts. If anything, it makes more people comfortable with ((syntax)).

--
The road to hell is paved with good intentions.
.



Relevant Pages

  • Re: negative stride list slices
    ... >> reversed order. ... I've been using extended slicing in Numeric and now numarray for years ... still often find it confusing to use negative indices in practice. ... greater than zero, otherwise it defaults to the last element -1). ...
    (comp.lang.python)
  • Re: Error correction using linear block codes
    ... Now how do I go about designing the right system to use? ... manage the (rather confusing - to me) tradeoffs? ... the likelihood of 1 or 2 bits being in error in each byte? ... access to soft-decisions, i.e., barely a one or zero, or strongly a ...
    (comp.dsp)
  • Re: A Response to Dr. Dawkins "Information Challenge" (Part 1): Specified Complexity Is the Measure
    ... confusing as possible, as are their questions. ... the message has zero usefullness! ... Terrorists nerve-gas the entire airport 15 minutes after you receive ... The utility or meaningfulness of a message ...
    (talk.origins)
  • Re: Era labels
    ... Its already been done by using BCE so you are wasting ... your time and confusing people by using - like NASA but not using a zero. ... cosmological dates refering to + and - years exist, ...
    (soc.history.ancient)
  • Re: Era labels
    ... Its already been done by using BCE so you are wasting your time and confusing people by using - like NASA but not using a zero. ... cosmological dates refering to + and - years exist, ...
    (soc.history.ancient)