Re: Yet another newB attempting a scheme alg...



Not for any useful definition of "guarantees failure" it doesn't. The
R5RS says that it is "an error" to take the car and cdr of an empty
list. That means that all bets are off regarding how the program will
behave. A particular Scheme system may choose to signal the error --
the R5RS encourages them to do so -- but there is no guarantee that
others will. They could instead return some arbitrary value. -max

I know, and you are absolutely (if a bit pedantically) correct. I
should never have said it guaranteed a thing - it only makes it as much
an error as taking the car or cdr (whichever happens first) of the
empty list.

Now, as a matter of taste, I choose to use languages (and/or
implementations) where these kinds of errors are indeed flagged, so
that I don't need to perform those sanity checks by myself all the
time. But that's just me.

.



Relevant Pages

  • Re: Yet another newB attempting a scheme alg...
    ... (cons (car alist) ... (combine (cdr alist) ... R5RS says that it is "an error" to take the car and cdr of an empty ...
    (comp.lang.scheme)
  • Re: newbie exploring better ways
    ... If the list is empty, ... If the car of the list is equal to the item, return the cdr of the ... Else cons the car of the list with the result of calling the function ... How would that look in Lisp? ...
    (comp.lang.lisp)
  • Re: newbie exploring better ways
    ... If the list is empty, ... If the car of the list is equal to the item, return the cdr of the ... Else cons the car of the list with the result of calling the function ... Do you know how CL manages tail recursion? ...
    (comp.lang.lisp)
  • Re: Newbie - Im soooo stuck - trying to remove an item from a list
    ... a-list) empty] ... FIRST (or CAR) returns the head of a list: ... while REST (or CDR) returns the rest of a list. ... to get a feeling for lists and pairs. ...
    (comp.lang.scheme)
  • Re: Lisp in hardware
    ... > and then you could implement CAR, CDR, or both of them. ... unresolved CAR reference until a CDR is applied. ... functionally expressed directly with simple machine code. ...
    (comp.lang.lisp)