<div dir="ltr">You should be able to make that assessment yourself. Does this program compile? Does it work for the example? Does it work for other examples you can come up with?</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Feb 1, 2015 at 9:27 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">
<div bgcolor="#FFFFFF" text="#000000">
<div>Roelof Wobben schreef op 1-2-2015 om
12:08:<br>
</div><div><div class="h5">
<blockquote type="cite">
<div>Bob Ippolito schreef op 1-2-2015 om
11:24:<br>
</div>
<blockquote type="cite">
<div dir="ltr">The goal is to solve the problem as stated such
that it would work for *any* example, not just that one. It's
very easy to come up with an example that does not work with
your implementation.
<div><br>
</div>
<div>Perhaps you should read the source for the lists module,
and take the time to try and understand it. <a href="https://github.com/erlang/otp/blob/maint/lib/stdlib/src/lists.erl" target="_blank">https://github.com/erlang/otp/blob/maint/lib/stdlib/src/lists.erl</a></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sun, Feb 1, 2015 at 2:14 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 have this exercise of the Erlang programming book.<br>
<br>
Write a function that, given a list of lists, will
concatenate them.<br>
Example:<br>
concatenate([[1,2,3], [], [4, five]]) ⇒ [1,2,3,4,five].<br>
Hint: you will have to use a helpfunction and concatenate
the lists in several steps.<br>
<br>
But I do not need to use a helper function because it can
be solved like this :<br>
<br>
concatenate( [List1 , List2 , List3] ) -><br>
List1 ++ List2 ++ List3.<br>
<br>
Or is this not the solution that is meant on this exercise
?<br>
Do I need to solve it by using pattern matching ?<br>
<br>
Roelof<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
Thanks, I will do this,<br>
<br>
But there is one problem.<br>
<br>
The source is full of -spec and in programming erlang that is
explained in chapter 18 where Im trying exercises of chapter 3.<br>
<br>
Roelof<br>
<br>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
erlang-questions mailing list
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
<br></div></div>
This solution better ?<br>
<br>
concatenate([]) -><br>
[].<br>
<br>
concatenate([List] ) -><br>
concatenate2(List1, []).<br>
<br>
concatenate2([], List) -><br>
List; <br>
<br>
concatenate2([Head| Tail], List) -><br>
concatenate2(Tail, [Head | List])<span class="HOEnZb"><font color="#888888"><br>
<br>
Roelof<br>
<br>
</font></span></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>