Skip to content

Instantly share code, notes, and snippets.

View pdpi's full-sized avatar

Pedro Pinheiro pdpi

View GitHub Profile
/* Let's pretend we're building a game, which has a physics
* simulation and a renderer. We're expecting to have a
* sufficiently large collection of entities that updating in a
* functional/immutable style is too expensive, but we still want
* to avoid allowing mutation where it's not strictly required.
*
* To this effect, note how `physics` takes a list of MutableEntity,
* but `render` takes Entity instead. The physics simulation is
* expected to mutate the entities (to update their (x,y) position
* according to whatever the simulation wants to do), but rendering
@pdpi
pdpi / AutoCalc.java
Created September 9, 2012 23:35 — forked from anonymous/AutoCalc.java
AutoCalc by joshellis625
import java.util.Scanner;
public class AutoCalc {
/* It's conventional that field names are in camelCase, so I changed that.
*
* The private keyword means only this class can look at these values. Here,
* declaring the field as 'static' means that it's a class field, rather than
* an instance field. The two x and y values are specific to one particular