[erlang-questions] Fwd: run program from commandprompt? define function?
Sat May 31 20:30:04 CEST 2008
Forgot to reply-all, here it is again:
c(tut) will look in the current directory. So if you moved it to bin, you
should run erl from there or do:cd("bin").
from the shell
as for defining functions from the shell, I don't believe you can define
normal module:function/arity style functions like in your tut.erl (that
function being tut:double/1)
but you can define fun's from the shell and call them, example:
1> Double = fun(X) -> 2 * X end.
the difference here is you have to make anonymous functions and bind them to
variables. so they won't look quite the same as from a source file where
you use lowercase atom names.
2008/5/31 Circular Function <>:
> double(X) ->
> 2 * X.
> saved that in tut.erl, placed it in the bin/ and tried to run it but it
> asks for a specific program to run.
> Erlang (BEAM) emulator version 5.6.2 [async-threads:0]
> Eshell V5.6.2 (abort with ^G)
> 1> c(tut).
> ./tut.erl:none: no such file or directory
> so which install do i need?
> how do i define a function?
> can i do that directlyin the shell?
> like in python:
> def sq(x): return x*x
> how would i dot hat in erlang?
> Sök efter kärleken!
> Hitta din tvillingsjäl på Yahoo! Dejting: http://se.meetic.yahoo.net<http://ad.doubleclick.net/clk;185753627;24584539;x?http://se..meetic.yahoo.net/index.php?mtcmk=148783>
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions