A Pythonista's Impressions of Erlang
Raimo Niskanen
raimo@REDACTED
Wed Jan 12 14:46:23 CET 2005
1> string:strip("http://www.erlang.org/", right, $/).
"http://www.erlang.org"
blaguehubert@REDACTED (blaguehubert) writes:
> Speaking of string operations, I need to add (or remove) the / at the
> end of an URL if it is absent (or present).
>
> I only ended in writing ugly code like that:
>
> RootUrl=
> if
> list:last(SiteRoot) =/= $/ ->
> SiteRoot ++ [$/];
> true ->
> SiteRoot
> end
>
> Is there an elegant way to do last character manipulation?
>
> Raimo Niskanen wrote:
>
> >I think either string:stubstr/2,3 (that can operate on
> > any-element-lists as well), or lists:split/2 can do what you want.
> >
> >By the way, the 'string' module has got a lot of
> > C-style string handling functions. Many of them do not bother about
> > the list elements being characters.
> >
> >When doing a quick readthrough of 'string' it seems as
> >words/1,2, sub_word/2,3, left/2,3, and right/2,3
> > require that the elements are integers. I do not see why this
> > requirement could not be relaxed.
> >
> >
> >
> >csanto@REDACTED (Corrado Santoro) writes:
> >
> >
> >>Dominic Williams wrote:
> >>
> >>>Given what is already in the lists module,
> >>>
> >>>>a="Hello, World"
> >>>>a[5:-3] --> ", Wo"
> >>>>
> >>>slice("Hello, World", 5, -3) -> ...
> >>>must be a one- or two-liner.
> >>>
> >>why not including such a function in "lists"?
> >>
> >>
> >>>Why bother with the syntactic sugar?
> >>>
> >>I agree :-))
> >>
> >>Cheers,
> >>--Corrado
> >>
> >> --
> >>======================================================
> >>Eng. Corrado Santoro, Ph.D.
> >>
> >>University of Catania - Engineering Faculty
> >>Department of Computer Science and
> >>Telecommunications Engineering
> >>Viale A. Doria, 6 - 95125 CATANIA (ITALY)
> >>
> >>Tel: +39 095 7382380 Fax: +39 095 7382397
> >> +39 095 7382365
> >> +39 095 7382364
> >>
> >>EMail: csanto@REDACTED
> >>Personal Home Page:
> >> http://www.diit.unict.it/users/csanto
> >>
> >>NUXI Home Page:
> >> http://nuxi.iit.unict.it
> >>======================================================
> >>
> >>
> >
> >
>
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list