On Wednesday, 29 January 2014 at 09:53:15 UTC, Stanislav Blinov wrote:
On Wednesday, 29 January 2014 at 09:50:13 UTC, Timon Gehr wrote:

import std.range, std.algorithm;
int value(int xs[]...) {
   return reduce!((a,b)=>10*a+b)(0,xs.retro);
}

Sadly, you can't build a struct (with N int fields) or an enum this way.


That was a problem for me today XD . Couldn't make a auto fct(string[] choices ...)(string[] id, string[] key ...) but I managed to find a workaround...

// KEYWORDS
enum USING = "USING.",
        VAR = "VAR.",
        LIST = "LIST.",
        SET = "SET.",
        ZSET = "ZSET.",
        HASHMAP = "HASHMAP.",
        LOCK = "LOCK.",
        UNLOCK = "UNLOCK.",
        SKIPCACHE = "SKIPCACHE.",
        INCREMENT = "INCREMENT.",
        DECREMENT = "DECREMENT.",
        FRONT = "FRONT.",
        BACK = "BACK.",
        PUSH = "PUSH.",
        POP = "POP.",
        REPLACE = "REPLACE.",
        TRIM = "TRIM.",
        RETURNS = "RETURNS.",
        LENGTH = "LENGTH.",
        EXISTS = "EXISTS.",
        VALUE = "VALUE.",
        KEY = "KEY.",
        STREAM = "STREAM.",
        ERROR = "ERROR.",
        

void exec(string command)(){
        foreach(str ; choice.splitter(".")){
                writeln(str);
        }
}

void main()
{
        exec!(USING ~ VAR ~ ADD ~ USING ~ LIST ~ INSERT ~ LOCK)();
}

Reply via email to