[racket] Missionaries and cannibals

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Mon Nov 29 23:15:46 EST 2010

On Nov 29, 2010, at 10:30 PM, Ken Hegeland wrote:

> I've almost managed to create mc-solvable as the book wants it. I  
> originally designed it to take a list of states, and I changed it  
> to accept a list of states, list of(listof states), or a single state.

That's almost certainly a bad idea.  A function that takes in any of  
several different types is often useful as a "front-end" function, or  
perhaps for a type with a special exceptional value (e.g. false), but  
for a function that actually does a lot of work, it'll only cause  
confusion.  And it'll make your function longer, more complicated,  
and less efficient, as the first thing it has to do is figure out  
which of the three ways it was called this time.  Decide what one  
type you want it to take in, and what one type you want it to return,  
and stick to those.


Stephen Bloch
sbloch at adelphi.edu



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101129/191ade22/attachment.html>

Posted on the users mailing list.