IList<A>.from constructor
IList<A>.from (
- Iterable<
A> iterable
Implementation
factory IList.from(Iterable<A> iterable) {
final IList<A> aNil = nil();
final Iterator<A> it = iterable.iterator;
if (!it.moveNext()) {
return aNil;
}
Cons<A> result = new Cons(it.current, aNil);
final IList<A> resultHead = result;
while(it.moveNext()) {
final next = new Cons(it.current, aNil);
result._unsafeSetTail(next);
result = next;
}
return resultHead;
}