<div dir="ltr"><div><div><div><div><div><br></div><div>So I have an array of data...<br> struct romanSystemData {<br> string digit;<br> uint value;<br> ulong regionIndex;<br> ulong previous;<br>};<br><br></div>
<div>immutable romanSystemData romanSystem[] = [<br> {"" , 0, 0, 0},//0<br> {"I", 1, 0, 0},//1 8-7<br> {"V", 5, 1, 1},//2 8-6<br> {"X", 10, 1, 2},//3 8-5<br> {"L", 50, 3, 3},//4 8-4<br>
{"C", 100, 3, 4},//5 8-3<br> {"D", 500, 5, 5},//6 8-2<br> {"M", 1000, 5, 6} //7 8-1<br>];<br><br></div>I'm happy I can use this look up table ...<br><br>assert( 10 == find!"(a.digit == b)"( romanSystem, "X").front.value);<br>
<br></div>Now I'm sure I can use std.algorithm map to convert say a string of characters "IVXLCDM" into an array [1,5,10,50,100,500,1000]<br><br></div>but somehow D template instantiation syntax is flumoxing me.<br>
<br></div>When I try use find in map!"find!""" dmd whinges like crazy at me.<br><br></div>How do you nest these things?<br><div><div><div><div><br><br><div><div><div>-- <br><div dir="ltr">John Carter<br>
Phone : (64)(3) 358 6639<br>Tait Electronics <br>PO Box 1645 Christchurch<br>New Zealand<br><br></div>
</div></div></div></div></div></div></div></div>
<br>
<hr><font color="#808080">This email, including any attachments, is only
for the intended recipient. It is subject to copyright, is confidential
and may be the subject of legal or other privilege, none of which is
waived or lost by reason of this transmission.</font><div><font color="#808080">If
you are not an intended recipient, you may not use, disseminate,
distribute or reproduce such email, any attachments, or any part
thereof. If you have received a message in error, please notify the
sender immediately and erase all copies of the message and any
attachments.</font></div><div><font color="#808080">Unfortunately, we
cannot warrant that the email has not been altered or corrupted during
transmission nor can we guarantee that any email or any attachments are
free from computer viruses or other conditions which may damage or
interfere with recipient data, hardware or software. The recipient
relies upon its own procedures and assumes all risk of use and of
opening any attachments.</font></div><div><hr></div>