<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Or use binary comprehensions.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Something along the lines of this totally untested code…</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><< << (length(Item)), (list_to_binary(Item))/binary >>  || Item <- tuple_to_list(Input) >>.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 3, 2020 at 11:48 AM Hugo Mills <<a href="mailto:hugo@carfax.org.uk">hugo@carfax.org.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, Jul 03, 2020 at 10:43:22AM +0100, Hugo Mills wrote:<br>
>    There's a tuple_to_list/1 function. Use that to start with, and<br>
> then you can map over the list to generate a list of size/value<br>
> binaries, converting one at a time. Then finally fold over that list<br>
> to produce the final binary.<br>
> <br>
>    Alternatively, require the input to be a list in the first place,<br>
> and you can skip the tuple_to_list/1 part. (But the rest is still<br>
> necessary).<br>
<br>
   Sorry, just realised I should have added:<br>
<br>
   More fundamentally, work out how to do *one* thing (convert a<br>
string to a length+data binary), then use the list functions to<br>
map/filter/fold many of those into one result.<br>
<br>
   Occasionally, you'll have to write a recursive function directly,<br>
but it's rarer than you might think.<br>
<br>
   Hugo.<br>
<br>
-- <br>
Hugo Mills             | Well, sir, the floor is yours. But remember, the<br>
hugo@... <a href="http://carfax.org.uk" rel="noreferrer" target="_blank">carfax.org.uk</a> | roof is ours!<br>
<a href="http://carfax.org.uk/" rel="noreferrer" target="_blank">http://carfax.org.uk/</a>  |<br>
PGP: E2AB1DE4          |                                             The Goons<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><table border="0" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td align="left" valign="bottom" width="107" style="line-height:0;vertical-align:bottom;padding-right:10px;padding-top:20px;padding-bottom:20px">
                <a href="https://about.me/elbrujohalcon?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb" style="text-decoration:none" target="_blank">
                    <img src="https://thumbs.about.me/thumbnail/users/e/l/b/elbrujohalcon_emailsig.jpg?_1498084031_146" alt="" width="105" height="70" style="margin: 0px; padding: 0px; display: block; border: 1px solid rgb(238, 238, 238);">
                </a>
            </td>
            <td align="left" valign="bottom" style="line-height:1.1;vertical-align:bottom;padding-top:20px;padding-bottom:20px">
                <img src="https://about.me/t/sig?u=elbrujohalcon" width="1" height="1" style="border: 0px; margin: 0px; padding: 0px; overflow: hidden;">
                <div style="font-size:18px;font-weight:bold;color:rgb(51,51,51);font-family:"Proxima Nova",Helvetica,Arial,sans-serif">Brujo Benavides</div>
                <a href="https://about.me/elbrujohalcon?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb" style="text-decoration:none;font-size:12px;color:rgb(43,130,173);font-family:"Proxima Nova",Helvetica,Arial,sans-serif" target="_blank">about.me/elbrujohalcon
                </a>
            </td>
        </tr>
    </tbody>
</table>
</div>