This file contains hidden or 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(frequency). | |
| -export([start/0,allocate/0,deallocate/1,stop/0]). | |
| -export([init/0]). | |
| %% These are the start functions used to create and | |
| %% initialize the server. | |
| start() -> | |
| register(frequency, | |
| spawn(frequency, init, [])). | 
  
    
      This file contains hidden or 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, find_index/2]). | |
| % Used to read a file into a list of lines. | |
| % Example files available in: | |
| % gettysburg-address.txt (short) | |
| % dickens-christmas.txt (long) | |
| % Get the contents of a text file into a list of lines. | 
  
    
      This file contains hidden or 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
    
  
  
    
  | perimeter({rectangle, {X, Y}, W, H}) -> 2 * W + 2 * H; | |
| perimeter({square, {X, Y}, Side}) -> 4 * Side; | |
| perimeter({triangle, {X, Y}, A, B, C}) -> A + B + C. | |
| area({circle, {X, Y}, R}) -> math:pi()*R*R; | |
| area({rectangle, {X, Y}, H, W}) -> H * W; | |
| area({triangle, {X, Y}, H, W}) -> H * W / 2. | |
| enclose({circle, {X, Y}, R}) -> {rectangle, {X,Y}, 2*R, 2*R}; | |
| enclose({triangle, {X, Y}, H, W}) -> {rectangle, {X, Y}, H, W}. |