Dynamic variable assignment by recursion or loop?

Hugo Mills hugo@REDACTED
Fri Jul 3 11:48:01 CEST 2020

On Fri, Jul 03, 2020 at 10:43:22AM +0100, Hugo Mills wrote:
>    There's a tuple_to_list/1 function. Use that to start with, and
> then you can map over the list to generate a list of size/value
> binaries, converting one at a time. Then finally fold over that list
> to produce the final binary.
>    Alternatively, require the input to be a list in the first place,
> and you can skip the tuple_to_list/1 part. (But the rest is still
> necessary).

   Sorry, just realised I should have added:

   More fundamentally, work out how to do *one* thing (convert a
string to a length+data binary), then use the list functions to
map/filter/fold many of those into one result.

   Occasionally, you'll have to write a recursive function directly,
but it's rarer than you might think.


Hugo Mills             | Well, sir, the floor is yours. But remember, the
hugo@REDACTED carfax.org.uk | roof is ours!
http://carfax.org.uk/  |
PGP: E2AB1DE4          |                                             The Goons

More information about the erlang-questions mailing list