Pergunta

From Wikipedia:

$\mathrm{true} = \lambda a. \lambda b. a$
$\mathrm{false} = \lambda a. \lambda b. b$

Because true and false choose the first or second parameter they may be combined to provide logic operators. Note that there are two version of not, depending on the evaluation strategy that is chosen.

$\mathrm{and} = \lambda p . \lambda q . p \, q \, p$
$\mathrm{or} = \lambda p . \lambda q . p \, p \, q$

$\mathrm{not}_A = \lambda p . \lambda a . \lambda b . p \, b \, a$   (This is only a correct implementation if the evaluation strategy is applicative order.)

$\mathrm{not}_N = \lambda p . p \, (\lambda a . \lambda b . b) \, (\lambda a . \lambda b . a) = \lambda p . p \, \mathrm{false} \, ⁡\mathrm{true}⁡$   (This is only a correct implementation if the evaluation strategy is normal order.)

I know what applicative order and normal order are (eager evaluation vs lazy evaluation of arguments to functions). But I don’t understand why the two nots don’t work in both of these evaluation strategies.

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a cs.stackexchange
scroll top