[erlang-questions] why do I see a message about area of a square
Rick Pettit
rpettit@REDACTED
Mon Jan 26 02:54:06 CET 2015
Technically Erlang does have arrays—see “erl -man array” for details.
-Rick
> On Jan 25, 2015, at 4:42 PM, Christopher Vance <cjsvance@REDACTED> wrote:
>
> The argument is a tuple. Erlang does not have arrays; you have to decide whether to use a list or a tuple.
>
> On Mon, Jan 26, 2015 at 12:36 AM, Roelof Wobben <r.wobben@REDACTED <mailto:r.wobben@REDACTED>> wrote:
> Nope, Thanks for the patience with me.
>
> So area is the function with 1 argument a array with the shape and the parameters to calculate it.
>
> Roelof
>
>
>
> Hynek Vychodil schreef op 25-1-2015 om 14:23:
>> Sorry, typo I mean area/1 and arity 1 because you have only one parameter.
>>
>> On Sun, Jan 25, 2015 at 1:24 PM, Roelof Wobben <r.wobben@REDACTED <mailto:r.wobben@REDACTED>> wrote:
>> Sorry, now im totally confused .
>>
>> where does the name array come from and why a arity 1 ?
>>
>> Roelof
>>
>>
>> Hynek Vychodil schreef op 25-1-2015 om 13:07:
>>> Hi,
>>>
>>> You don't have any functions named square, circle or triangle. You have only one function array/1 with four function clauses, the first for square, the second for circle, the third for triangle and the fourth catch-all one.
>>>
>>> Hynek
>>>
>>> On Sun, Jan 25, 2015 at 12:29 PM, Roelof Wobben <r.wobben@REDACTED <mailto:r.wobben@REDACTED>> wrote:
>>> Thanks,
>>>
>>> That error messages disappear.
>>>
>>> As I understand it right. The eror message is on all functions so on the square, circle and triangle functions.
>>> And if not so, why also not a error functions on the other two.
>>>
>>> Roelof
>>>
>>>
>>>
>>>
>>> Taavi Talvik schreef op 25-1-2015 om 12:22:
>>>
>>> Until you export your functions, they remain local to
>>> module. And compiler sees here, that they are not used
>>> locally here.
>>>
>>> Try adding
>>> -export([area/1]).
>>>
>>> best regards,
>>> taavi
>>> On 25 Jan 2015, at 13:12, Roelof Wobben <r.wobben@REDACTED <mailto:r.wobben@REDACTED>> wrote:
>>>
>>> Hello,
>>>
>>> I have this programm :
>>>
>>> -module(shapes).
>>>
>>> -import(math, [sqrt/1]).
>>>
>>> area({square, Side}) ->
>>> Side * Side ;
>>>
>>> area({circle, Radius}) ->
>>> math:pi() * Radius * Radius;
>>>
>>> area({triangle, A, B, C}) ->
>>> S = (A + B + C)/2,
>>> math:sqrt(S*(S-A)*(S-B)*(S-C));
>>>
>>> area(Other) ->
>>> {error, invalid_object}.
>>>
>>>
>>> As soon I as try to compile it , I see these messages :
>>>
>>>
>>> 6> c(shapes).
>>> shapes.erl:5: Warning: function area/1 is unused
>>> shapes.erl:15: Warning: variable 'Other' is unused
>>>
>>> Why does Erlang do this?
>>> On compile time you cannot see which functions are used and which not in my oponion.
>>>
>>> Roelof
>>>
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>>> http://erlang.org/mailman/listinfo/erlang-questions <http://erlang.org/mailman/listinfo/erlang-questions>
>>>
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>>> http://erlang.org/mailman/listinfo/erlang-questions <http://erlang.org/mailman/listinfo/erlang-questions>
>>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>> http://erlang.org/mailman/listinfo/erlang-questions <http://erlang.org/mailman/listinfo/erlang-questions>
>>
>>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> http://erlang.org/mailman/listinfo/erlang-questions <http://erlang.org/mailman/listinfo/erlang-questions>
>
>
>
>
> --
> Christopher Vance
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150125/9c1d83d3/attachment.htm>
More information about the erlang-questions
mailing list