<div dir="ltr">I think we need a little more clarification...<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 27, 2015 at 9:15 AM, Roelof Wobben <span dir="ltr"><<a href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I try now to solve a challenge where I must make a list  from a range,<br>
<br>
So for example if I do create(2) the outcome have to be [ 1, 2]<br></blockquote><div><br></div><div>Here you are saying create(N) should create a list from 1-N.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
So i can do<br>
<br>
create(0) -><br>
  print array<br>
<br>
but as far as I know the list is then not in the scope so I cannot use it when I do<br>
<br>
create(2) -><br>
  add the 2 to the array.<br></blockquote><div><br></div><div>Here you are saying create(2) should ONLY add 2 to the list, when previously you said create(2) should create a list from 1-2. Now, if you are saying that create(N) should create a list from 1-N OR list:last()-N (meaning it should be in range), then you would first have to check if N is in the current list. If not, create the list, if so cancel</div><div><br></div><div>EX) (Using my assumption)</div><div><br></div><div>create(0) -></div><div>         print array.</div><div><br></div><div>create(N) -></div><div>          case lists:member(N, list) of</div><div>                     true -></div><div>                              exit;</div><div>                      false ->       </div><div>                              get last element of list (L),</div><div>                              append L-N to current list (L can also be nothing, if this is the first call to this function in which case it should append 1-N)</div><div>           end.</div><div><br></div><div><br></div><div><br></div><div>This should always work because the function is generating a list from A-B. And you can using something like ets with ordered_set or something similar to keep it in order.</div><div><br></div><div><br></div><div> </div></div><br></div></div>