Javascript functions that roughly correspond to those used in The Little Schemer