# [erlang-questions] nand problem

Ivan Uemlianin ivan@REDACTED
Mon Jan 26 18:11:44 CET 2015

```Yes, you can do:

b_nand(X,Y) ->
b_not(b_and(X,Y)).

Ivan

On 26/01/2015 17:01, Roelof Wobben wrote:
> Yes. I have learned the wildcardpattern but also there was a text
> beneath it saying not to use it for defensive programming.
>
> oke I have misread it and have to use the not and and.
>
> Or can i do things like
>
> b_nand { true, true) ->
>     b-not(b_and(true, true)
>
> Roelof
>
>
>
> Bob Ippolito schreef op 26-1-2015 om 17:27:
>> 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
>> <mailto: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 <mailto:erlang-questions@REDACTED>
>>     http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

--
============================================================
Ivan A. Uemlianin PhD
Llaisdy
Speech Technology Research and Development

ivan@REDACTED
@llaisdy
llaisdy.wordpress.com
github.com/llaisdy

festina lente
============================================================

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150126/e0c2b516/attachment.htm>
```