map<B> method
Implementation
@override IList<B> map<B>(B f(A a)) {
final IList<B> bNil = nil();
if (!_isCons()) {
return bNil;
}
Cons<B> last = new Cons(f(_unsafeHead()), bNil);
if (!_unsafeTail()._isCons()) {
return last;
}
final result = last;
var current = _unsafeTail();
while (current._isCons()) {
final next = new Cons(f(current._unsafeHead()), bNil);
last._unsafeSetTail(next);
last = next;
current = current._unsafeTail();
}
return result;
}