Question:
Haskell append vs cons operators?
TimmahDee
2009-10-31 23:31:30 UTC
This really is a silly question but can someone explain the difference between append (++) and cons (:) ?
Three answers:
Shelby M
2009-11-03 00:49:51 UTC
(:) is the construction operator for lists and it takes an element on left and a list on left and returns the concatenated list:



http://www.haskell.org/onlinereport/standard-prelude.html#$t$Ba$c



(++) concatenates two lists:



http://www.haskell.org/onlinereport/standard-prelude.html#$v++



If you mean (x:xs), (_:xs), or (x:_) then you are referring to a pattern which can be used to match the arguments of a function:



http://cs.anu.edu.au/Student/comp1100/haskell/tourofsyntax.html#Patterns



http://www.haskell.org/tutorial/patterns.html#sect4



I am putting together a new "Essence of Functional Programming for Imperative Programmers" guide and when I upload it, then link will be:



http://www.coolpage.com/commentary/economic/shelby/Functional_Programming_Essence.html
anonymous
2017-03-01 10:49:26 UTC
Append Haskell
NetmanI
2009-10-31 23:50:48 UTC
you can also try to find solution from many professional expert from

websitelivexperts.tk/


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...