[erlang-questions] nand problem

Hugo Mills hugo@REDACTED
Mon Jan 26 18:26:32 CET 2015


On Mon, Jan 26, 2015 at 05:21:42PM +0100, Roelof Wobben wrote:
[snip]
> b_and(true, true) ->
>   true;
> 
> b_and(true, false) ->
>   false;
> 
> b_and(false, true) ->
>   false;
> 
> b_and(false, false) ->
>   false.

   You could make this shorter and possibly easier to read with

b_and(true, true) ->
    true;
b_and(_, _) ->
    false.

   i.e. define the (one) special case, and then just say that
everything else evaluates to false. You can do something similar with
b_or.

   Hugo.

-- 
Hugo Mills             | Two things came out of Berkeley in the 1960s: LSD
hugo@REDACTED carfax.org.uk | and Unix. This is not a coincidence.
http://carfax.org.uk/  |
PGP: 65E74AC0          |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150126/c99ec4c7/attachment.bin>


More information about the erlang-questions mailing list