Jerry <jlqu...@optonline.net> writes: > Andrei Alexandrescu <seewebsiteforem...@erdani.org> writes: > >> uint among(T, Us...)(T v, Us vals) >> { >> foreach (i, U; Us) >> { >> if (v == vals[i]) return i + 1; >> } >> return 0; >> } > > This seems less useful to me. What was the example where you found it > useful?
Being bad and following myself up... I think this proposal is highlighting that Phobos more generally lacks set operations. It seems to me that among() is roughly equivalent to: auto i = v in vals; but this is only currently used for builtin hash tables. Since this syntax already exists, does it make sense to see if it can be done as something like: auto i = v in (val, val, val ...); ? I've been playing with porting some code where we use hash tables and sets quite a bit and end up creating a lot of bool[string] objects. It works, but I do wish there was a more explicit set. This allows for blah["entry"] = false, which isn't really what I'm trying to model :-) Would it make sense to create a Set object in std.container? Jerry