[erlang-questions] Erlang newbie - quick critique?
Thu Sep 7 06:30:35 CEST 2006
Rather new to the FP paradigm (painful learning curve with an attempt
at Common Lisp) so I just thought I'd run my first attempts at a
recursive Erlang function past you.
I'm not near an Erlang interpreter at the moment, unfortunately, so I
can't test the code, I'm worried about one bit, which I'll highlight.
I'm trying to replicate the string.join() method of Python i.e.,
":".join(["a", "b", "c"]) resulting in "a:b:c"
This is what I've drawn up on paper -
my_join([H|T] Delimiter) ->
myjoin(T, Delimiter, [H])).
my_join([H|T], Delimiter, Acc) ->
myjoin(T, Delimiter, lists:append([Acc, Delimiter, H]) ).
my_join(, Delimiter, Acc) ->
Usage: my_join(["a", "b", "c"], ":")
What I'm concerned about is the [H] and the lists:append call with the
arguments being inserted into two square brackets to make a new list.
Would that work? It's a Python thing, or do I need to use a function
to make it a list?
I've decided to start small for now - I intend to use Erlang to write
an MSN client as I think the asynchrous nature of Erlang (and I love
the sockets returning messages) suits the problem perfectly. I had
started in Python, but have hit a bunch of fiddliness with asynchrous
sockets, so thought I'd give Erlang a go.
In designing the actual architecture of an Erlang system, can anyone
recommend some best practises? I'm working on the message interfaces
between the socket handling process and it's controller at the moment.
More information about the erlang-questions