(******************************************************************* This file was generated automatically by the Mathematica front end. It contains Initialization cells from a Notebook file, which typically will have the same name as this file except ending in ".nb" instead of ".m". This file is intended to be loaded into the Mathematica kernel using the package loading commands Get or Needs. Doing so is equivalent to using the Evaluate Initialization Cells menu command in the front end. DO NOT EDIT THIS FILE. This entire file is regenerated automatically each time the parent Notebook file is saved in the Mathematica front end. Any changes you make to this file will be overwritten. ***********************************************************************) BeginPackage["indexedVariables`"]; indexedVariable::usage="indexedVariable[dict,indicesValues] sets dict[index]=value from {index, value} pairs in indicesValues."; values::usage="values[dict] returns the list of values of dict (gathered from DownValues)."; indices::usage="indices[dict] returns the list of indices of dict (gathered from DownValues)."; items::usage="items[dict] returns the list of {index, value} pairs of dict (gathered from DownValues)."; indexQ::usage="indexQ[dict, index] returns True if index is an index of the dict and False otherwise."; update::usage="update[dict, otherDict] adds index, value pairs from otherDict to dict."; Begin["`Private`"]; indexedVariable[dict_,indicesValues_]:= Scan[(dict[#[[1]]]=#[[2]]) &,indicesValues]; index[downvalue_]:=(downvalue[[1]]/.HoldPattern[dict[x_]]\[Rule]x)// ReleaseHold; value[downvalue_]:=downvalue[[-1]]; values[dict_]:=Map[value[#]&,DownValues[dict]]; indices[dict_]:=Map[index[#]&,DownValues[dict]]; items[dict_]:=Map[{index[#],value[#]}&,DownValues[dict]]; (* This form of IndexQ thanks to Frank J. Iannarilli *) indexQ[dict_,index_]:= If[MatchQ[dict[index],HoldPattern[dict[index]]],False,True]; update[dict_,otherDict_]:=Scan[(dict[#[[1]]]=#[[-1]])&,items[otherDict]]; End[]; EndPackage[];