[erlang-questions] How to keep adding items to a data structure
Sun Apr 24 22:05:35 CEST 2016
You are kind and generous to help. I'll study this carefully. I will
be wanting to add a list or a record, not just numbers. Is this possible?
On 04/24/2016 03:13 PM, Antonios Kouzoupis wrote:
> Hi Don,
> The way you iterate in Erlang and I guess in most functional programming
> languages is by recursive call. So if you want to add/append some
> numbers to a list, one way to go is the following:
> populate(Num) ->
> populate(Num, ).
> populate(0, Acc) ->
> populate(Num, Acc) ->
> populate(Num - 1, [Num | Acc]).
> Now if you call populate(100), you'll get the list [1,...,100]
> erlang-questions mailing list
More information about the erlang-questions