November 15, 2014 Multi-Prefix Version of skipOver() | ||||
---|---|---|---|---|
| ||||
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. |
November 15, 2014 Re: Multi-Prefix Version of skipOver() | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | 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. |
Copyright © 1999-2021 by the D Language Foundation