Chaining std.algorithm
John Carter
john.carter at taitradio.com
Sun Dec 15 20:42:10 PST 2013
So I have an array of data...
struct romanSystemData {
string digit;
uint value;
ulong regionIndex;
ulong previous;
};
immutable romanSystemData romanSystem[] = [
{"" , 0, 0, 0},//0
{"I", 1, 0, 0},//1 8-7
{"V", 5, 1, 1},//2 8-6
{"X", 10, 1, 2},//3 8-5
{"L", 50, 3, 3},//4 8-4
{"C", 100, 3, 4},//5 8-3
{"D", 500, 5, 5},//6 8-2
{"M", 1000, 5, 6} //7 8-1
];
I'm happy I can use this look up table ...
assert( 10 == find!"(a.digit == b)"( romanSystem, "X").front.value);
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]
but somehow D template instantiation syntax is flumoxing me.
When I try use find in map!"find!""" dmd whinges like crazy at me.
How do you nest these things?
--
John Carter
Phone : (64)(3) 358 6639
Tait Electronics
PO Box 1645 Christchurch
New Zealand
--
------------------------------
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.
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.
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.
------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20131216/324b842f/attachment.html>
More information about the Digitalmars-d-learn
mailing list