Skip to content

Instantly share code, notes, and snippets.

View shakerlxxv's full-sized avatar

Brian Shaver shakerlxxv

  • New Hampshire, USA
View GitHub Profile
%%==============================================================================
%% Univ. Kent Functional Programing with Erlang
%% Week 3: Part 11 - Functions as results in practice
%%
%% Description:
%% consolidate understanding of functions that take functions as
%% arguments and return functions as results.
%%
%% Author: Brian L. Shaver
%% Date : 2017-03-25
%%==============================================================================
%% Univ. Kent Functional Programing with Erlang
%% Week 3: Part 5 - Higher-order functions in practice
%%
%% Description:
%% work with higher order functions 'map','filter', and 'reduce'
%%
%% Author: Brian L. Shaver
%% Date : 2017-03-22
%%==============================================================================
%%==============================================================================
%% Univ. Kent Functional Programing with Erlang
%% Week 2: Part 20 - indexing a file
%%
%% Description:
%% Use the main function main/1 to create your output. It will produce
%% a list of data structures: { "foo" , [{3,5},{7,7},{11,13}] } meaning
%% the word "foo" occurs on lines 3, 4, 5, 7, 11, 12 and 13 in the file.
%%
%% Enhancements:
%%------------------------------------------------------------------------------
%% Univ. Kent Functional Programing with Erlang
%% Week 2: Part 18 - Consolidation: functions over lists
%%
%% Description:
%% Optional exercises to help consolidate knowledge on defining functions
%% over lists
%%
%% Author: Brian L. Shaver
%% Date : 2017-03-12
%%------------------------------------------------------------------------------
%% Univ. Kent Functional Programing with Erlang
%% Week 2: Part 9 - Constructing Functions on Lists
%%
%% Description:
%% Familiarize yourself with other ways of defining functions over lists
%%
%% Author: Brian L. Shaver
%% Date : 2017-03-10
%%------------------------------------------------------------------------------
%%==============================================================================
%% Univ. Kent Functional Programing with Erlang
%% Week 2: Part 6 - Defining function over lists
%%
%% Description:
%%
%% Author: Brian L. Shaver
%% Date : 2017-03-04
%%==============================================================================
-module(ex2_6).
@shakerlxxv
shakerlxxv / patterns.erl
Last active March 2, 2017 10:00
FUNCTIONAL PROGRAMMING IN ERLANG THE UNIVERSITY OF KENT: Variables and patterns in practice
-module(patterns).
-include_lib("eunit/include/eunit.hrl").
-export([xOr1/2,xOr2/2,xOr3/2,maxThree/3,howManyEqual/3]).
xOr1(A,B) ->
(not (A and B)) and (A == not B).
% the first clause is necessary to ensure the function errors
% if given a non-boolean argument.
xOr1_test() ->
@shakerlxxv
shakerlxxv / sti_helpers.rb
Created August 11, 2011 13:07
To smooth out the use of STI for Rails models
#-------------------------------------------------------------------------------
# This module is meant to be included in the Base class of an STI model
# hierarchy.
#
# Heavily inspired by a couple key blog posts
# http://code.alexreisner.com/articles/single-table-inheritance-in-rails.html
# http://coderrr.wordpress.com/2008/04/22/building-the-right-class-with-sti-in-rails/#comment-1826
#
# Thanks to Alex and coderrr!
#-------------------------------------------------------------------------------