This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(ex1_shapes). | |
-export([perimeter/1,test_perimeter/0,area/1,test_area/0,enclose/1,test_enclose/0,run_tests/0]). | |
%% Perimeter function and tests | |
perimeter({circle, R}) -> | |
{ok, math:pi() * 2 * R}; | |
perimeter({rectangle, {A, B}}) -> | |
{ok, 2 * A + 2 * B}; | |
perimeter({square, A}) -> | |
{ok, 4 * A}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(ex1_bits). | |
-export([bits_direct/1,test_bits_direct/0,bits_tail/2,test_bits_tail/0,run_tests/0]). | |
bits_direct(0) -> | |
0; | |
bits_direct(N) -> | |
N rem 2 + bits_direct(N div 2). | |
bits_tail(0, B) -> | |
B; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(index). | |
-export([get_file_contents/1 | |
,show_file_contents/1 | |
,main/1 | |
% for tests | |
,get_words/4 | |
,get_numbered_words/1 | |
,sort_word_pair/2 | |
,test_sort_word_pair/0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(hofex). | |
-export([add/1,times/1,compose/2,id/1,iterate/1 | |
, compose_all/1 | |
, test_compose_all/0 | |
, twice/1 | |
, test_twice/0 | |
, test_iterate/0 | |
]). | |
add(X) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(rps_game). | |
-export([play/1,echo/1,play_two/3,play_two/4,rock/1,no_repeat/1,const/1,enum/1,cycle/1,rand/1,val/1,tournament/2 | |
, least_freq/1 | |
, most_freq/1 | |
, rand_strategies/1 | |
, best_strategy/1 | |
, t_const/1 | |
, t_cycle/1 | |
, t_echo/0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Based on code from | |
%% Erlang Programming | |
%% Francecso Cesarini and Simon Thompson | |
%% O'Reilly, 2008 | |
%% http://oreilly.com/catalog/9780596518189/ | |
%% http://www.erlangprogramming.org/ | |
%% (c) Francesco Cesarini and Simon Thompson | |
-module(frequency2). | |
-export([start/0,allocate/0,deallocate/1,stop/0]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(billing). | |
-export([ get_data/0 | |
, get_barcodes/0 | |
, get_bill/3 | |
, print_bill/1 | |
, test_print_bill/0 | |
, test_print_bill2/0 | |
, test_print_bill3/0 | |
]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Based on code from | |
%% Erlang Programming | |
%% Francecso Cesarini and Simon Thompson | |
%% O'Reilly, 2008 | |
%% http://oreilly.com/catalog/9780596518189/ | |
%% http://www.erlangprogramming.org/ | |
%% (c) Francesco Cesarini and Simon Thompson | |
% Using the observer, set up a system of frequency server and at least two clients, and kill the frequency server when the clients are in possession of a frequency – you can make the clients “sleep” at any point using the timer:sleep/1 function – observe that the clients are killed too. | |
% How would you modify the clients so that they are not affected by the server terminating? How could you then shut down the entire system if you needed to? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Based on code from | |
%% Erlang Programming | |
%% Francecso Cesarini and Simon Thompson | |
%% O'Reilly, 2008 | |
%% http://oreilly.com/catalog/9780596518189/ | |
%% http://www.erlangprogramming.org/ | |
%% (c) Francesco Cesarini and Simon Thompson | |
-module(gf). | |
-behaviour(gen_server). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Alphabet exposing (..) | |
import Char | |
capitalLetters : List Char | |
capitalLetters = | |
List.range (Char.toCode 'A') (Char.toCode 'Z') | |
|> List.map Char.fromCode |
OlderNewer