Class StemEvaluator

    • Constructor Detail

      • StemEvaluator

        public StemEvaluator()
    • Method Detail

      • getNamespace

        public String getNamespace()
      • getFunctionNames

        public String[] getFunctionNames()
        A list of the names that this Evaluator knows about. NOTE that this must be kept in sync by the developer since it is used to determine if a function is built in or a user-defined function.
        Specified by:
        getFunctionNames in class AbstractEvaluator
      • getType

        public int getType​(String name)
      • rFormatStem

        protected String rFormatStem​(QDLStem stem,
                                     List<String> keySubset,
                                     boolean sortKeys,
                                     boolean multilineMode,
                                     int indent,
                                     int width)
      • reverseKeysAndValues

        protected QDLStem reverseKeysAndValues​(QDLStem inStem)
      • doIndices

        protected void doIndices​(Polyad polyad,
                                 State state)
      • doValues

        protected void doValues​(Polyad polyad,
                                State state)
      • doForEach

        protected void doForEach​(Polyad polyad,
                                 State state)
        Apply n-ary function to outer product of stems. There n stems passed in. The function is applied to each of them as an outer product. So every element of every argument is evaluated.
        Parameters:
        polyad -
        state -
      • doJPathQuery

        protected void doJPathQuery​(Polyad polyad,
                                    State state)
      • stemPathConverter

        protected QDLStem stemPathConverter​(String indexList)
        Convert output of a JSON query to a stem of lists. Each list is an index entry.
        Parameters:
        indexList -
        Returns:
      • doIsMemberOf

        protected void doIsMemberOf​(Polyad polyad,
                                    State state)
        Compute if the left argument is a member of the right argument. result is always conformable to the left argument.
        Parameters:
        polyad -
        state -
      • doFromJSON

        protected void doFromJSON​(Polyad polyad,
                                  State state)
      • doToJSON

        protected void doToJSON​(Polyad polyad,
                                State state)
      • doSize

        protected void doSize​(Polyad polyad,
                              State state)
      • doListKeys

        protected void doListKeys​(Polyad polyad,
                                  State state)
        Returns the keys in a stem as a list, filtering if wanted.
        Parameters:
        polyad -
        state -
      • doKeys

        protected void doKeys​(Polyad polyad,
                              State state)
        Return a stem of nothing key the keys, possibly filtering, so the final stem is of the form
             {key0=key0,key1=key1,...}
         
        This is useful in conjunction with the rename keys call, so you can get the keys and do some operations on them then rename the keys in the original stem.
        Parameters:
        polyad -
        state -
      • putLongOrStringKey

        protected void putLongOrStringKey​(QDLStem out,
                                          Object key)
        Needed by list_keys and keys so that returned indices that are longs are indeed longs. Otherwise everything returned would be a string (e.g., '0' not 0) which makes subsequent algebraic operations on them fail.
        Parameters:
        out -
        key -
      • doHasKeys

        protected void doHasKeys​(Polyad polyad,
                                 State state)
        Deprecated.
        This is not left conformable and any uses should be removed in favor of doHasKey(Polyad, State)
        Parameters:
        polyad -
        state -
      • doHasKey

        protected void doHasKey​(Polyad polyad,
                                State state)
        has_keys(key | keysList., arg.) returns left conformable result if the key or keylist. are keys in the arg.
        Parameters:
        polyad -
        state -
      • doMakeIndex

        protected void doMakeIndex​(Polyad polyad,
                                   State state)
      • indexRecursion

        protected void indexRecursion​(QDLStem out,
                                      int[] lengths,
                                      int index,
                                      StemEvaluator.CyclicArgList cyclicArgList)
        Fills in the elements for the n(x,y,z,...) function.adv74008
        Parameters:
        out -
        lengths -
        index -
        cyclicArgList -
      • doIsList

        protected void doIsList​(Polyad polyad,
                                State state)
      • doRemove

        protected void doRemove​(Polyad polyad,
                                State state)
        Remove the entire variable from the symbol table.
        Parameters:
        polyad -
        state -
      • doIncludeKeys

        protected void doIncludeKeys​(Polyad polyad,
                                     State state)
        include_keys(stem., var | list.);

        include keys on the right in the resulting stem
        Parameters:
        polyad -
        state -
      • doExcludeKeys

        protected void doExcludeKeys​(Polyad polyad,
                                     State state)
        exclude_keys(stem., var | list.)

        remove all the keys in list. from the stem.
        Parameters:
        polyad -
        state -
      • doShuffle

        protected void doShuffle​(Polyad polyad,
                                 State state)
        Permute the elements in a stem. The right argument must contain every key in the left argument or an exception is raised. This is really just using cycle notation from abstract algebra... E.g.,
         10+3*indices(5)
         [10,13,16,19,22]
         rename_keys(10+3*indices(5), [4,2,3,1,0])
         [22,19,13,16,10]
         
        read that in [4,2,3,1,0]: old → new, so 0 → 4, 1 → 2, 2→3, 3→1, 4→0
      • doRenameKeys

        protected void doRenameKeys​(Polyad polyad,
                                    State state)
        rename_keys(arg., indices.);

        list. contains entries of the form
            indices.old = new
         
        Note that this is different from doRemap(Polyad, State). The result is that each key in arg. is renamed, but the values are not changed. If a key is in indices. and does not correspond to one on the left, it is skipped, by subsetting rule. If a key is indices and the old and new value are the same, it is skipped.

        Limitations are that it applies to the zeroth axis, modifies arg. and the indices. are different than remap.
        Parameters:
        polyad -
        state -
      • doCommonKeys

        protected void doCommonKeys​(Polyad polyad,
                                    State state)
        common_keys(stem1., stem2.)

        Return a list of keys common to both stems.
        Parameters:
        polyad -
        state -
      • doSetDefault

        protected void doSetDefault​(Polyad polyad,
                                    State state)
        Sets the default value for a stem. returns the default value set.
        Parameters:
        polyad -
        state -
      • doMask

        protected void doMask​(Polyad polyad,
                              State state)
      • doJoin

        protected void doJoin​(Polyad polyad,
                              State state)
      • doTransform

        protected void doTransform​(Polyad polyad,
                                   State state)