Keep on moving

あんまりまとまってないことを書きますよ

Erlang Super liteの予習

Erlang Super Lite [Chapter1] : ATND

Erlang Programming

Erlang Programming


かなり前に解いてたけど、取り合えず。
2.1と2.2は実行すればいいから略

2.3

%% Author: Ehren
%% Created: 2009/11/09
%% Description: TODO: Add description to boolean
-module(boolean).

%%
%% Include files
%%

-include_lib("eunit/include/eunit.hrl").

%%
%% Exported Functions
%%
-export([b_and/2, b_or/2,b_not/1, b_nand/2]).

%%
%% API Functions
%%

b_not_test_() ->
	[
		?_assertEqual(b_not(false) ,true)
	].

b_and_test_() ->
	[
		?_assertEqual(b_and(false,true),false),
		?_assertEqual(b_and(boolean:b_not(boolean:b_and(true, false)), true),true)
	].

%%
%% TODO: Add description of b_and/function_arity
%%
b_and(true, true) -> 
	true;
b_and(_,_) ->
	false.

%%
%% TODO: Add description of b_or/function_arity
%%
b_or(false, false) -> 
	false;
b_or(_,_) ->
	true.

%%
%% TODO: Add description of b_not/function_arity
%%
b_not(true) -> 
	false;
b_not(false) ->
	true.

%%
%% TODO: Add description of b_nand/function_arity
%%
b_nand(A,B) ->
	b_not(b_and(A,B)).

参考

EUnitの使い方は以下を参考にさせていただきました。先人に感謝。
shibu.jp: Erlang用の軽量ユニットテストフレームワーク