[erlang-questions] increment in map
Nicholas Frechette
zeno490@REDACTED
Mon Jul 26 21:25:34 CEST 2010
You could use 'foldl' instead of map:
foldl(fun(Row, Inc) ->
...
Inc + 1 %% Return value is the new value of Inc for the next call
end, Rows, 0).
You could also zip seq(0, numrows) with your rows and unzip them inside the
map (though if you have a lot of rows, the above will be faster and leaner).
Nicholas
On Mon, Jul 26, 2010 at 2:38 PM, Wes James <comptekki@REDACTED> wrote:
> I have this code:
>
> map(fun(Row) ->
> {table, [{style, "width:700px; margin:5px;
> background-color:dddddd;"}],
> [
> thtd(Hdrs, [{td, [], massage(W,Ls)} || W <-
> vp(Vp,Row)])
> ]}
> end, Rows)
>
> and as I loop through the Row I would also like to send an increment
> in the massage(W,LS,Inc) call, but I don't see how I can do that
> within a list comprehension. Any ideas on how I would do this?
>
> thx,
>
> -wes
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
More information about the erlang-questions
mailing list