Website Source

This script builds a set of unique values from the argument list and prints its contents.

    # import what we need from the appropriate modules
    import crack.cont.hashmap HashMap;
    import crack.io cout;
    import crack.strutil StringArray;
    import crack.sys argv;

    ## Cheesey set implementation.
    class ArgSet : HashMap[String, bool] {
        oper init(StringArray args) {
            for (arg :in args)
                this[arg] = true;
        }

        void dump() {
            for (item :in this)
                cout `got $(item.key)\n`;
        }
    }

    # initialize the arg set from the actual args
    ArgSet a = {argv};

    # write the set
    a.dump();


Tags: language   compiled   static   object  

Last modified 01 July 2021