|
|
| Author |
Message |
|
| rvirding |
Posted: Thu Dec 03, 2009 2:48 pm |
|
|
|
User
Joined: 30 Aug 2006
Posts: 452
Location: Stockholm, Sweden
|
2009/12/3 Garrett Smith <g@rre.tt>
> On Wed, Dec 2, 2009 at 7:23 PM, Ngoc Dao <ngocdaothanh@gmail.com> wrote:
> >> string:str(List, [Element]).
> >
> > What a surprise! Thank you.
>
> A good example of "most astonishment"
>
Unfortunately they have added som type checking in string otherwise you
could do string:chr(List,Element).
Robert
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Thu Dec 03, 2009 3:49 pm |
|
|
|
Guest
|
2009/12/2, Tim Fletcher <twoggle@gmail.com>:
>> Hmm, I fail to come up with a good usage scenario for wanting this. What
>> are
>> you needing the position of an item in a list for?
>
> FWIW, here's something i wrote recently:
>
> base32_decode(Char) ->
> list_index(Char, base32_alphabet()).
>
> base32_alphabet() ->
> "0123456789bcdefghjkmnpqrstuvwxyz".
I usually see code like this implemented like this:
base32_decode2(Char) when Char>=$0, Char=<$9 ->
Char-47;
base32_decode2(Char) when Char>=$b, Char=<$h ->
Char-87;
base32_decode2(Char) when Char>=$j, Char=<$k ->
Char-88;
base32_decode2(Char) when Char>=$m, Char=<$n ->
Char-89;
base32_decode2(Char) when Char>=$p, Char=<$z ->
Char-90.
It (ab)uses the fact that we're latin-1 (effectively ASCII) charset.
The other kind of code I usually see for this kind of task contains
one function clause for each possible inputs. I don't know, but I
think both approaches are faster than traversing the list with
string:str/2. Probably binaries could be used instead of lists to
speed up indexing.
________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Thu Dec 03, 2009 9:51 pm |
|
|
|
Guest
|
> I usually see code like this implemented like this:
>
> base32_decode2(Char) when Char>=$0, Char=<$9 ->
> |
|
|
| Back to top |
|
| wuji |
Posted: Thu Sep 13, 2012 8:10 am |
|
|
|
User
Joined: 10 Aug 2012
Posts: 654
|
even by some very close family members, though."That was bad because they they cheap authentic air jordans they loved me and I loved them," she said. "And they didn't
me in the house."She said that wanting to be accepted for who who cheap jordan shoes who she is drove her to come out on television that year
Jerry Falwell, Pat Robertson and other members of the evangelical community who who cheap designer *beep* who said they were disappointed. Some called her "Ellen Degenerate.""You know Ellen
such a good person," her mother said. "Now, I don't want to to cheap polo shirts to get weepy, I don't, but she's so good that she shouldn't
all this directed at her."Today Betty DeGeneres fights for gay rights. She She [h1]designer replica *beep*[/h1] She is devoted and always tolerant.Bill Clinton Boosts President Obama - So
George W. Bush for Mitt Romney?2 Prior Presidents Take Dramatically Different Approaches Approaches cheap Ralph Lauren Polo Approaches to 2012 CampaignBy JOEL SIEGELMay 4, 2012 He was once |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|