<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>In some Racket languages they are: </div><div><br></div><div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000">Welcome to DrRacket, version 5.3.0.8--2012-05-25(eeb3da0c/d) [3m].</font></div><div><font class="Apple-style-span" color="#000000">Language: htdp/isl.</font></div><div><font class="Apple-style-span" color="#000000">> (member? 2 '(1 2 3))</font></div><div><font class="Apple-style-span" color="#000000">true</font></div></blockquote><br></div><div><br></div><div>Note the '?'. </div><div><br></div><div>In untyped languages, conditionals count every value other than #f as a true value. So there isn't a real need to return #t. Better still, in some cases it is much better to return an additional result value -- in member's case it would have been '(2 3) above -- because this value is useful and avoids a recompilation. </div><div><br></div><div>Example: </div><div> </div><div> (define (take-step game-state)</div><div> (if (move-available game-state)</div><div> (step state (determine-best-move state))</div><div> (give-up)))</div><div><br></div><div>It all likelihood there is a tremendous overlap between move-available? and determine-best-move so why not rewrite it like this:</div><div><br></div><div> (define (take-step game-state)</div><div> (define good-move (determine-best-move state))</div><div> (if good-move (step state good-move) (give-up)))</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br><div><div>On May 25, 2012, at 12:29 PM, Don Green wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Why are some Racket functions such a 'member' not designed as booleans?<br>I would expect 'member' to be a boolean.<br>I am inclined to write my own version of 'member' that is boolean.<br>Before I do, I am wondering if the bright person who designed the Racket function: 'member', did so for some very good reason that is not obvious to me.<br>
I notice that there are a number of other Racket functions like this, where they return #t or the value of the argument passed to the function, not #t or #f.<br>I am just looking for the concept so that I might be convinced that I should use the racket function as it is, rather than writing a boolean version.<br>
Thanks <br><br>
____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>