| 283 | * @category constructors |
| 284 | */ |
| 285 | export const fromIterable = <A>(prefix: Iterable<A>): List<A> => { |
| 286 | const iterator = prefix[Symbol.iterator]() |
| 287 | let next: IteratorResult<A> |
| 288 | if ((next = iterator.next()) && !next.done) { |
| 289 | const result = makeCons(next.value, _Nil) |
| 290 | let curr = result |
| 291 | while ((next = iterator.next()) && !next.done) { |
| 292 | const temp = makeCons(next.value, _Nil) |
| 293 | curr.tail = temp |
| 294 | curr = temp |
| 295 | } |
| 296 | return result |
| 297 | } else { |
| 298 | return _Nil |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Constructs a new `List<A>` from the specified values. |