[erlang-questions] map over bitstring
Fri Oct 22 06:55:06 CEST 2010
Thanks, that was really helpful.
One more question, how do I zip on two bitstrings.
On 10/21/10, Jesper Louis Andersen <> wrote:
> On Thu, Oct 21, 2010 at 9:56 PM, rgowka1 <> wrote:
>> Hi -
>> How do I map a function over a bitstring without converting into string or
>> For example - how can I replace << "a" >> with << "X" >> and any other
>> character to << "Y" >>??
>> InBin = << "abcaa" >>
>> OutBin = << "XYYXX" >>
> The trick is Binary Comprehensions or by using the (R14B) binary
> module. Here is a solution using the Binary Comprehensions:
> 3> << <<case X of $a -> $X; _ -> $Y end>> || <<X>> <= <<"abcaa" >> >>.
More information about the erlang-questions