public void Set_Value(numbers.value value_index, numbers.value v) { if (!numbers_pkg.is_integer(value_index)) { throw new Exception(numbers_pkg.msstring_image(value_index) + " is not a valid array index."); } int index = numbers_pkg.integer_of(value_index); if (index > values.Count) { for (int i = values.Count; i <= index - 1; i++) { values.Add(numbers_pkg.make_value__2(0.0)); } } try { values[index - 1] = v._deep_clone(); } catch { System.Exception f = new System.Exception("can't do array assign to: " + (index - 1)); throw f; } }
public void Set_Value(numbers.value value_index1, numbers.value value_index2, numbers.value v) { if (!numbers_pkg.is_integer(value_index1)) { throw new Exception(numbers_pkg.msstring_image(value_index1) + " is not a valid array index."); } if (!numbers_pkg.is_integer(value_index2)) { throw new Exception(numbers_pkg.msstring_image(value_index2) + " is not a valid array index."); } int index1 = numbers_pkg.integer_of(value_index1); int index2 = numbers_pkg.integer_of(value_index2); int num_rows = values.Count; int num_cols = 0; if (num_rows > 0) { num_cols = ((System.Collections.ArrayList)values[0]).Count; } // add rows as needed if (index1 > num_rows) { for (int i = num_rows; i <= index1 - 1; i++) { values.Add(new System.Collections.ArrayList()); for (int j = 0; j < num_cols; j++) { ((System.Collections.ArrayList)values[i]).Add(numbers_pkg.make_value__2(0.0)); } } num_rows = index1; } // add columns as needed if (index2 > num_cols) { for (int i = 0; i < num_rows; i++) { for (int j = num_cols; j <= index2 - 1; j++) { ((System.Collections.ArrayList)values[i]).Add(numbers_pkg.make_value__2(0.0)); } } } try { ((System.Collections.ArrayList)values[index1 - 1])[index2 - 1] = v._deep_clone(); } catch { System.Exception f = new System.Exception("can't do 2D assign to: " + (index1 - 1) + "," + (index2 - 1)); throw f; } }