
Some parts of this message have been removed.
Learn more about Nabble's
security policy.
You don’t send messages to
functions, you send them to processes. Also, you’re missing periods after the squarer
and squarer2 functions (after the ends), which accounts for two of the compiler
errors.
|
im using:
http://www.erlang.org/doc/reference_manual/part_frame.html
but cant really figure it out. i didnt expect this to work but compiled
anyway:
2> c("c:/Program Files/erl5.6.2/usr/serec", [{outdir,
"c:/Program Files/erl5.6.2/usr/"}]).
c:/Program Files/erl5.6.2/usr/serec.erl:2: function squarer/1 undefined
c:/Program Files/erl5.6.2/usr/serec.erl:2: function squarer2/1 undefined
c:/Program Files/erl5.6.2/usr/serec.erl:23: premature end
error
3>
obv this is just a toy program but say I have a function that squares the
integers of a list from 1 to the send parameter.
so i want to send a message to that function.
-module(serec).
-export([seq/2,squarer/1,squarer2/1]).
seq(Start, End) -> seq(Start, End, []).
seq(Start, End, Acc) when Start =< End ->
seq(Start, End-1, [End|Acc]);
seq(_, _, Acc) ->
Acc.
squarer(X) ->
receive
Pattern [when Pattern > 7] ->
[X*X || X <- [seq(1, 7]];
end
squarer2(X) ->
receive
when X > 7 -> [X*X || X <- [seq(1, 7]];
end
squarer(X) ! 2+6
|
Låna pengar utan säkerhet.
Sök
och jämför lån hos Kelkoo.
_______________________________________________
erlang-questions mailing list
erlang-questions@...
http://www.erlang.org/mailman/listinfo/erlang-questions