[Haskell-beginners] cleanest way to unwrap a list?

Shakthi Kannan shakthimaan at gmail.com
Mon Aug 13 07:37:48 CEST 2012


Hi,

--- On Mon, Aug 13, 2012 at 10:51 AM, Christopher Howard
<christopher.howard at frigidcode.com> wrote:
| Say, for example, I have the list
| [[1,2],[3,4]] and want to add 1 to each inner element, resulting in
| [[2,3],[4,5]].
\--

Like this?

ghci> let xxs = [[1,2], [3,4]]

ghci> [ [ x+1 | x <- xs] | xs <- xxs ]
[[2,3],[4,5]]

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com



More information about the Beginners mailing list