Skip to content

Instantly share code, notes, and snippets.

@jo1077
jo1077 / Animals.py
Last active October 3, 2018 04:10
this is game of words uses text file with animal names as source and plays back and forth between machine and player. Work in progress, need to add words already played and some other adjustments
import re
from random import *
used_words=[]
words=[]
animals=open('animals.txt','r') #opens file
for line in animals: # create list of animals
@jo1077
jo1077 / ass_wk1.erl
Created May 11, 2020 03:07 — forked from duncanatt/ass_wk1.erl
Functional Programming in Erlang - Week 1 Assignment
-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.
@jo1077
jo1077 / ass_wk1.erl
Created May 11, 2020 03:08 — forked from duncanatt/ass_wk1.erl
Functional Programming in Erlang - Week 1 Assignment
-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.
@jo1077
jo1077 / morelists.erl
Created May 14, 2020 02:47 — forked from dduugg/morelists.erl
Functional Programming in Erlang: 2.27
-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)].
-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]) ->
@jo1077
jo1077 / index.erl
Created May 14, 2020 03:40 — forked from colinbankier/index.erl
Indexing a file - Erlang
-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.
@jo1077
jo1077 / index.erl
Created May 15, 2020 03:32 — forked from emaphis/index.erl
Functional programming in Erlang -- index program.
-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.
@jo1077
jo1077 / index.erl
Created May 17, 2020 02:52 — forked from ekalinin/index.erl
indexing a file
-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)
@jo1077
jo1077 / index.erl
Created May 17, 2020 03:05 — forked from rui-dias/index.erl
Functional Programming in Erlang - Programming challenge: indexing a file
-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)
@jo1077
jo1077 / second_week.erl
Created May 17, 2020 03:08 — forked from Acentelles/second_week.erl
Second week - Index a file - FUNCTIONAL PROGRAMMING IN ERLANG - THE UNIVERSITY OF KENT
-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.