Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In PureScript, how does List differ from Array?

Tags:

purescript

In PureScript, how does List differ from Array?

What are the reasons to use one over the other?

like image 304
sdgfsdh Avatar asked Jun 27 '17 21:06

sdgfsdh


1 Answers

The representation for Array is a JavaScript array, whereas List is implemented as a cons (linked) list.

Lists have better performance characteristics when being built up item-by-item, or iterated over by taking an item from front each time - basically List has O(1) cons and uncons, vs O(n) for Array.

Take a look at the documentation for Array and List on Pursuit for more information about the running time of various operations.

like image 132
gb. Avatar answered Sep 21 '22 05:09

gb.