[erlang-questions] nand problem

Bob Ippolito bob@REDACTED
Mon Jan 26 17:27:30 CET 2015


Here's a hint:

http://en.wikipedia.org/wiki/NAND_gate

You already have an inverter by another name.

Although in this case I think implementing NAND as a pattern match would be
quite simple. Have you learned about wildcard patterns yet (the _ symbol)?


On Mon, Jan 26, 2015 at 8:21 AM, Roelof Wobben <r.wobben@REDACTED> wrote:

> Hello,
>
> I now have to make a nand boolean with pattern matching.
> I have found out that nand is true except when its true and true.
>
> as hint I get to implement nand using and and or.
>
> Can someone give me a hint how to do this ?
>
>
> My code looks like this at the moment :
>
> -module(boolean).
>
> -export([b_not/1, b_and/2, b_or/2]).
>
> b_not(true) ->
>   false;
>
> b_not(false) ->
>   true.
>
> b_and(true, true) ->
>   true;
>
> b_and(true, false) ->
>   false;
>
> b_and(false, true) ->
>   false;
>
> b_and(false, false) ->
>   false.
>
>
> b_or(true, true) ->
>   true;
>
> b_or(true, false) ->
>   true;
>
> b_or(false, true) ->
>   true;
>
> b_or(false, false) ->
>   false.
>
>
>     Roelof
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150126/2c3b4d59/attachment.htm>


More information about the erlang-questions mailing list