[erlang-questions] grab a value in list for later use in map

Bengt Kleberg <>
Thu Jun 3 06:49:44 CEST 2010


Greetings,

In general it is a good idea to use lists:foldl/3 when you are
(potentially) accumulating things.


bengt

On Thu, 2010-06-03 at 06:37 +0200, Wes James wrote:
> With a map such as this:
> 
> map(fun(Row) ->
>                      {tr, [],
>                       [{td, [], massage(W)} || W <- Row]
>                      }
>          	end, Rows)
> 
> It outputs values like this:
> 
> 4	 6183	 2010-05-20
> 0	 6193	 2010-05-21
> 6	 6209	 2010-05-24
> 
> But if there is a 0 in the first column, I want to instead of
> outputting the 0, subtract the column to the right value - previous
> column value, i.e subtract 6193-6183.  How do I keep a second column
> value around if I need it like this with map?
> 
> thx,
> 
> -wes
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
> 



More information about the erlang-questions mailing list