'if' as a _function_, in Scheme and Python

Steve Schafer pandeng at telepath.com
Fri Aug 20 02:16:09 CEST 1999


On Thu, 19 Aug 1999 22:31:49 GMT, oleg at pobox.com wrote:

>To show it clearer, let me re-write my-if as
>
>        (define (my-if condition then-branch else-branch)
>           ((cdr (assq (eq? condition #f)
>                (list (cons #t else-branch) (cons #f then-branch))))))
>
>This definition is _purely_ functional

Not only is it purely functional, it also unconditionally evaluates
both branches (in Scheme). Therefore, it is not equivalent to IF.

-Steve





More information about the Python-list mailing list