Getting the last element of an iterator

lastiterate(itr) = foldl((_, y) -> y, itr)

or

lastiterate(itr) = applicable(last, itr) ? last(itr) :  foldl((_, y) -> y, itr)
2 Likes