<div dir="ltr"><div><div><div>Interesting question.<br><br></div>So there is a concept in computer science called <b>fusion</b>.<br><br></div>My understanding (I don't have a CS degree) is that when data is subject to fusion, we don't create the intermediary lists as you are talking about. This is why, in Haskell, we have the <b>ByteString</b> and <b>Text</b> datatypes. Unlike <b>String</b>, they (ByteString / Text) are subject to fusion. <b>Text</b> is useful when we are dealing with unicode data, while <b>ByteString</b> is the correct tool when we are dealing with binary data. <br><br></div><div>All of this is to say that you should look at the <b>ByteString</b> data type. (Take a look at this description, for example: <a href="https://hackage.haskell.org/package/bytestring-0.10.8.2/docs/Data-ByteString.html#t:ByteString">https://hackage.haskell.org/package/bytestring-0.10.8.2/docs/Data-ByteString.html#t:ByteString</a>). <br><br></div><div>The only potential problem I see is that <b>ByteString</b> internally uses <b>Word8</b>, and since <b>Word8</b> is <u>unsigned</u>, negatives are problematic. (Now that I think about it, how the heck do you represent negative numbers in binary?). <br><br></div><div>I hope this is useful.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 14, 2018 at 4:28 PM, Quentin Liu <span dir="ltr"><<a href="mailto:quentin.liu.0415@gmail.com" target="_blank">quentin.liu.0415@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif">Hi all,
<div><br></div>
<div>Suppose I want to multiply two binary numbers whose representation uses lists (e.g. 14 is represented as [1, 1, 1, 0]). Is there any efficient way to do binary multiplication? The way I could come up with involves a lot of intermediate lists that will be discarded eventually and is extremely inefficient. I know one fast algorithm that uses Array but would it be possible to do the multiplication with only lists? </div>
</div>
<div name="messageSignatureSection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif"><br>
Regards,
<div>Qingbo Liu</div>
</div>
</div>
<br>______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Steven Leiva<br>305.528.6038<br><a href="mailto:leiva.steven@gmail.com" target="_blank">leiva.steven@gmail.com</a><br><a href="http://www.linkedin.com/in/stevenleiva" target="_blank">http://www.linkedin.com/in/stevenleiva</a><br></div>
</div>