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([do_index/1, show_file_contents/1]). | |
%% Main entrypoint | |
%% In the Erlang shell, execute: rp(index:do_index("path_to_file")). | |
%% Reads the contents of the file using the provided functions, builds up a map | |
%% of words to their locations, compresses the locations to ranges and returns a | |
%% list sorted in alphabetical order | |
do_index(Name) -> | |
Lines = get_file_contents(Name), |
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,run/1,just_words/1,print_words/1]). | |
% Self reference! View this gist at https://gist.github.com/einarwh/7c287097f54f549a427a537ec0caee47 | |
% This solution should produce output roughly as specified. | |
% Short words are dropped, the words are sorted, and all words are in lowercase form. | |
% I haven't attempted to "canonicalize" words any further (singulars and plurals are distinct). | |
% For faster lookup, a dictionary (dict in Erlang, apparently) might have been useful. |
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
-module(index). | |
-include_lib("eunit/include/eunit.hrl"). | |
-export([get_file_contents/1,show_file_contents/1,main/1]). | |
% Used to read a file into a list of lines. | |
% Example files available in: | |
% gettysburg-address.txt (short) | |
% dickens-christmas.txt (long) |
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). | |
-compile([export_all]). | |
% -export([get_file_contents/1,show_file_contents/1]). | |
% Used to read a file into a list of lines. | |
% Example files available in: | |
% gettysburg-address.txt (short) | |
% dickens-christmas.txt (long) |
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]). | |
-export([index_file/1,print_index/1]). | |
-export([partition_test/0]). | |
%% The main prorgram. | |
%% Run: | |
%% index:index_file("gettysburg-address.txt"). | |
%% to produce a list of word indexes. |
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_index/1]). | |
% 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
-module(lists2). | |
-export([join/2,concat/1,member/2,sort/1,sort/2,perms/1]). | |
-export([join_test/0,concat_test/0,member_test/0,sort_test/0,perms_test/0]). | |
%% Join %%% | |
join(L1, L2) when is_list(L1), is_list(L2) -> | |
join_internal(lists:reverse(L1), L2). | |
join_internal(L1, []) -> lists:reverse(L1); | |
join_internal(L1, [H|T]) -> |
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(morelists). | |
-export([concat/1, concat_test/0, insertion_sort/1, | |
join/2, join_test/0, member/2, member_test/0, | |
merge_sort/1, perms/1, perms_test/0, quicksort/1, | |
sort_tests/0]). | |
join([], Y) -> Y; | |
join([X | Xs], Y) -> [X | join(Xs, Y)]. |
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 (ass_wk1). | |
-export ([area/1, perimeter/1, enclose/1, bits/1, bits_tail/1]). | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%% Question 1 - Shapes. %% | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% I'm assuming three shapes: circles, rectangles and squares. | |
%% Perimeter of circle is calulated using the standard formula 2 * Pi * R. |
NewerOlder