Skip to main content

List and Array

List

List comprehension

see haskell doc math, set comprehension

Array

Aspect Prim.Array Data.Array Mutability Mutable (JS arrays) Immutable Import Automatic Explicit import needed API Very limited Rich functional API Safety Unsafe operations Type-safe with Maybe Performance Faster (mutable) Slower (immutable copies) Usage FFI, performance-critical General PureScript code

Array comprehension

tip

A pattern like x:xs will bind the head of the list to x and the rest of it to xs, even if there's only one element so xs ends up being an empty list. Note: The x:xs pattern is used a lot, especially with recursive functions.