www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9942] New: Add a functional switch function

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9942

           Summary: Add a functional switch function
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: pull
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: GenericNPC gmail.com


--- Comment #0 from IdanArye <GenericNPC gmail.com> 2013-04-16 13:41:18 PDT ---
Based on `condp` from
Clojure(http://clojuredocs.org/clojure_core/1.2.0/clojure.core/condp), I've
written the function `predSwitch`. It acts as the functional(=expression)
version of the `switch` statement, and it also allows a custom predicate:

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 16 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9942


IdanArye <GenericNPC gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://github.com/D-Progra
                   |                            |mming-Language/phobos/pull/
                   |                            |1259


--- Comment #1 from IdanArye <GenericNPC gmail.com> 2013-04-16 13:51:06 PDT ---
See https://github.com/D-Programming-Language/phobos/pull/1259

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 16 2013