KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
So I wanted to do a simple string reverse function in Haskell swapReverse :: String => String swapReverse [x] = [x] swapReverse [x,y] = [y,x] swapReverse (x:xs:l) = -- pattern match fails here let last = [l] middle = xs first = [x] in last ++ swapReverse middle ++ first So is there a way to define a pattern structure in haskell that has first and last element, and all the elements in the middle ?
Tags (comma-separated)
Save Edits
Cancel