www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Multi-Prefix Version of skipOver()

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
What's currently the fastest way of removing the largest matching 
prefix from an array of prefix arrays from an array in D like

     auto x = "first_second";
     x.skipOverLargestMatch(["fir", "first"]);
     assert( == "_second");

     auto x = "first_second";
     x.skipOverLargestMatch(["fir"]);
     assert( == "st_second");

The list of prefixes is preferrably dynamically generated but can 
also a variadic list of arguments if necessary.

I guess we could reuse variadic find in the static case.
Nov 15 2014
parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Saturday, 15 November 2014 at 14:41:29 UTC, Nordlöw wrote:
 What's currently the fastest way of removing the largest 
 matching prefix from an array of prefix arrays from an array in 
 D like

     auto x = "first_second";
     x.skipOverLargestMatch(["fir", "first"]);
     assert( == "_second");

     auto x = "first_second";
     x.skipOverLargestMatch(["fir"]);
     assert( == "st_second");

 The list of prefixes is preferrably dynamically generated but 
 can also a variadic list of arguments if necessary.

 I guess we could reuse variadic find in the static case.
So I hacked together skipOverShortestOf at https://github.com/nordlow/justd/blob/master/skip_ex.d#L39 Now I need help figuring out how to implement skipOverLongestOf hopefully by reusing skipOverShortestOf. Other comments would also be great.
Nov 15 2014