<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">What about just<br>
<br>
map (map f) xxs<br>
<br>
where for your example<br>
<br>
xxs == [[1,2], [3,4]]<br>
f == (+1)<br>
<br>
Graham<br>
<br>
On 13/08/2012 1:21 AM, Christopher Howard wrote:<br>
</div>
<blockquote cite="mid:50288EF7.4090000@frigidcode.com" type="cite">
<pre wrap="">Hi. Is the some generic, clean syntax to unwrap a nested list, modify
the value, and put it back together? 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]].
After reading about the list monad, I was rather excited, because I
(mistakenly) thought something like this would work:
code:
--------
a = do b <- [[1,2],[3,4]]
c <- b
return (c + 1)
--------
That would be awesome, because I would be able to modify the list at
each level of unwrapping, while leaving the code very neat and readable.
However, what the above example actually does is produce a /single/ list
from the values:
code:
--------
*Main> a
[2,3,4,5]
--------
Obviously wishing won't change how the list monad works, but I thought
it might be worth asking if there is some other monad or syntactic trick
that does something along the lines of what I am looking for.
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://www.haskell.org/mailman/listinfo/beginners">http://www.haskell.org/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</body>
</html>