itertools: add tail

This commit is contained in:
Colin Caine 2018-04-14 11:33:09 +01:00
parent 4981a3618e
commit ff69b7e8a1

View file

@ -6,6 +6,17 @@ export function head(iter) {
else return result.value else return result.value
} }
/** Get the last item of an array or iterable */
export function tail(iter) {
if (Array.isArray(iter)) {
return iter[iter.length - 1]
} else {
let last
for (last of iter) {}
return last
}
}
/** Zip some arrays together /** Zip some arrays together
If you need variable length args, you need izip for now. If you need variable length args, you need izip for now.