• List is immutable, its elements can’t be changed
  • List is recursive

  • All the elements of list have the same type
  • All lists are constructed from
    • An empty list Nil
    • Operator cons (::)
  • Operators ending with “:” is calculated from right to left

A :: B :: C is interpreted A :: (B :: C)

Functions on list

  • Implement of last

  • Implement of init

  • Implement of concat

  • Implement of reverse

  • Implement of removeAt

List patterns

  • Nil: an empty list
  • p :: ps: this pattern will match any lists whose head matches p and tail matches ps
  • List(p1, …, pn) is the same as p1 :: … :: pn :: Nil

You May Also Like

About the Author: Phuong Ta Thi Thao

Leave a Reply

Notify of