Where should I put a `condp` like function?

Idan Arye GenericNPC at gmail.com
Sun Apr 14 16:52:33 PDT 2013


I'm replicating `condp` from 
Clojure(http://clojuredocs.org/clojure_core/1.2.0/clojure.core/condp). 
Basically, it's like a `switch` statement without lookup table, 
only it's an expression(so it returns a value) and you can choose 
your own predicate(the default will be "a == b"). For example:

     writeln(2.predSwitch!"a < b"(
         1, "less then 1",
         5, "less then 5",
         10, "less then 10",
         "greater or equal to 10"));

Now, I've got it working(the example actually compiles and prints 
"less then 5"), and I want to make a pull request to put it in 
Phobos(because it's a useful function) but I don't really know 
where to put it. None of the existing modules seems fit, and I 
don't want to open a new module(std.monad?) for a single function.

Any suggestions?


More information about the Digitalmars-d mailing list