Reimplemented take, drop, indexOf in terms of foreach