Skip to content

Yurie/Math/Label

  • label[var_|{vars__},label_|{labels__},pos_] - join the variable(s) and label(s) into a (sequence of) labeled object(s).

    • pos:Symbol|Function|Subscript|Superscript - control the position of label.

      Example

      Map[label[x,1,#]&,{Symbol,Function}]
      
      Out[] = {x1,x[1]}
      
  • labelConvert[vars__|{vars__},pos1_->pos2_,opts_][expr_] - convert the labeled object(s) according to the two specified label positions.

    Example

    z1+z2//labelConvert[z,Symbol->Function]
    
    Out[] = z[1]+z[2]
    
    • "LabelType"->All - control the pattern of labels, and resolves possible conflicts between variable and label.

      The supported values are

      • All
      • "PositiveInteger"
      • "PositiveIntegerOrSingleLetter"
      • "PositiveIntegerOrGreekLetter"
      • "NaturalNumber"
      • "NaturalNumberOrSingleLetter"
      • "NaturalNumberOrGreekLetter"
      • _Symbol|_Function|_RightComposition|_Composition - pure function for string pattern matching

      Example

      zb1//labelConvert[{z,zb},Symbol->Function,"LabelType"->"PositiveInteger"]
      
      Out[] = zb[1]
      
      zb1//labelConvert[{z,zb},Symbol->Function]
      
      Out[] = z[b1]
      
    • labelJoin|labelSplit - special cases of labelConvert that convert Symbol to/from other Function|Subscript|Superscript.

  • labelTo*[var_|{vars__},rule_|{rules__},pos_:Function] - return a ReplaceAll function according to the rules.

    Example

    labelToDiff[{z,zb},{1->2},Function]
    
    Out[] = ReplaceAll[{z[1]->z[2]+z["12"],zb[1]->zb[2]+zb["12"]}]
    
    Name Prototype
    labelToZero $ x_1 \to 0 $
    labelToEqual $ x_1 \to x_2 $
    labelToDiff $ x_1 \to x_{12} + x_2 $
    labelToDiffZero $ x_1 \to x_{12},\, x_2 \to 0 $
    labelToDiffBack $ x_{12} \to x_1 - x_2 $