What does the : infix operator do in Haskell?

: is the “prepend” operator:

x : xs

Returns a list which has x as first element, followed by all elements in xs. In other functional languages, this is usually called cons, because it “cons”tructs a list recursively by repeated application from an empty list:

1 : 2 : 3 : 4 : []

is the list [1, 2, 3, 4].

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)