Copied array functions from https://github.com/thomasbrus/interpres/pull/3