Skip to content

Instantly share code, notes, and snippets.

View maryrosecook's full-sized avatar

Mary Rose Cook maryrosecook

View GitHub Profile

Responding to a student's request for help

Process

  1. Map the student's request for help to one of the underlying problems listed below.

  2. Apply one of the suggested solutions.

  3. Ask the student for feedback on your help.

@maryrosecook
maryrosecook / ...
Last active September 13, 2018 18:17
Reminders to myself to help me get better at programming. I don't always manage to do these things, but I try. Please feel free to add your own reminders to yourself in the comments below!
We couldn’t find that file to show.
@maryrosecook
maryrosecook / alltogether.js
Created May 25, 2011 16:53
Examples for Machine.js
var landscape = new Landscape(); // one actor
// make instance of Machine and get the root nodes for each actor
var machine = new Machine();
landscape.state = machine.generateTree(landscapeJson, landscape);
// every second, something happens in the ecosystem
setTimeout("step()", 1000);
var step = function() {
// trigger the next state transition
@maryrosecook
maryrosecook / enemyai.js
Created May 26, 2011 14:20
The behaviour tree for Pistol Slut
{
identifier: "idle", strategy: "prioritised",
children: [
{
identifier: "spot", strategy: "sequential",
children: [
{ identifier: "callRange" },
{ identifier: "stopSpotting" },
]
},
# Use test-driven development to write a method that:
# * Takes an array of numbers.
# * Returns the sum of the numbers in the array.
# * e.g.
# * Input: [1, 2, 3, 4, 5]
# * Return: 15
# * Make sure to create a separate project directory for your code.
# Use test-driven development to write a method that:
# * Takes an array of numbers.
# * Returns an array of the same numbers, except each number has had 1 added to it.
# * e.g.
# * Input: [1, 2, 3, 4, 5]
# * Return: [2, 3, 4, 5, 6]
# * Make sure to create a separate project directory for your code.
OVERVIEW OF THE WEEK
- Encapsulating Single Responsibilities (rather than just common behaviour) into classes
- makes code easy to reuse
- makes code easy to change
- makes code easy to understand
- Refactoring code for SRP
- Adopt this code writing process
# A practical introduction to functional programming
Many functional programming articles teach abstract functional techniques. That is, composition, pipelining, higher order functions. This one is different. It shows examples of imperative code that people write every day and translates them to a functional style.
The imperative examples are all loops. The first section of the article takes short, data transforming loops and translates them into functional maps and reduces. The second section takes longer loops, breaks them up into units and makes each unit functional. The third section takes a loop that is a long series of successive data transformations and decomposes it into a functional pipeline.
The examples are in Python, because many people find Python easy to read. A number of the examples eschew pythonicity in order to demonstrate functional techniques common to many languages: map, reduce, pipeline.
## A guide rope