write list/set/array
436444
private Object writeArray(SerIterator itemIterator) {
        List<Object> result = new ArrayList<>();
        while (itemIterator.hasNext()) {
            itemIterator.next();
            result.add(writeObject(itemIterator.valueType(), itemIterator.value(), itemIterator));
        }
        return result;
    }
643517
function toArray(set) {
    var ret = [];
    set.forEach(function(element) {
        ret.push(element);
    });
    return ret;
}
238793
def _dump_list(list_data, jsonify, stream=sys.stdout):
    '''
    
    '''
    if not jsonify and list_data:
        print >> stream, '\n'.join(list_data)
    else:
        print >> stream, json.dumps(list_data)
700447
def write_attribute(key, values)
      set = read_attribute(key)
      if values.respond_to?(:to_str) && !set.single_value? && set.syntax_object && set.syntax_object.error("1\n1")
        values = values.split(/\r?\n/)
      elsif values == ''
        values = []
      end
      set.replace(values)
    end
343216
def writeArray(fp, a, delim = " ", nl = 1):
    
    for i in a:
        fp.write("%f%s" % (i, delim))
    if nl:
        fp.write("\n")
148739
public static void putLongList(Writer writer, List<Long> values) throws IOException {
		if (values == null) {
			writer.write("null");
		} else {
			startArray(writer);
			for (int i = 0; i < values.size(); i++) {
				put(writer, values.get(i));
				if (i != values.size() - 1) {
					addSeparator(writer);
				}
			}
			endArray(writer);
		}
	}
950144
private static void arrayToWriter(Object array, JsonWriter writer) throws IOException {
    writer.beginArray();
    for (int i = 0, size = Array.getLength(array); i < size; i++) {
      writeValue(Array.get(array, i), writer);
    }
    writer.endArray();
  }
1064912
private void appendList(StringBuffer buffer, List<Object> list) {

        Iterator<Object> iter = list.iterator();
        while (iter.hasNext()) {
            Object entry = iter.next();
            buffer.append(entry).append("<br/>\n");
        }
    }
531233
function (list) {
		var items = [];
		var i = 0;
		var listLength = list.length;

		for (; i < listLength; i++) {
			items.push(list[i]);
		}

		return items;
	}
1036236
function listFromArray(arr) {

  // note the below inadvertantly connected the input forms to the
  // output generated code forms and caused a problem if anonymous
  // "reactor functions" were used.  But without it - compile times
  // went thru the roof!!
  if(isList(arr)) { return arr; }

  var thelist = [];

  function _wrap(form) {
    var wrapped;
    if(!Array.isArray(form)) {
      wrapped = atom(form);
    }
    else {
//      wrapped = (isList(form) ? arr : listFromArray(form));
      wrapped = listFromArray(form);
    }
    if(!thelist.noparenting) {
      wrapped.parent = thelist;
    }
    return wrapped;
  }

  /**
  * Add the given form to the end of the list.
  * note: this also wraps the form and sets the list as the parent of the item
  */
  thelist.push = function(form) {
    Array.prototype.push.call(this, _wrap(form));
    return this;
  };

  /**
  * Add each element of the array to the end of the list.
  * note: this also wraps the forms and sets the list as the parent of the item
  */
  thelist.pushFromArray = function(arr) {
    arr.forEach(function(elem) {
      thelist.push(elem);
    });
    return this;
  };

  /**
  * Add the given form to the beginning of the list.
  * note: this also wraps the form and sets the list as the parent of the item
  */
  thelist.unshift = function(form) {
    Array.prototype.unshift.call(this, _wrap(form));
    return this;
  };

  /**
  * Add each element of the array to the beginning of the list.
  * note: this also wraps the forms and sets the list as the parent of the item
  */
  thelist.unshiftArray = function(arr) {
    for(var i = arr.length-1; i >= 0; i--) {
      thelist.unshift(arr[i]);
    };
    return this;
  };

  /**
  * Disable the auto-setting of parents as forms are added to the list.
  * This is useful for macros because even though they rearrange forms
  * we don't want the macros themselves winding up in the parent/child
  * relationships that are used for finding locally scoped dialects.
  */
  thelist.disable_parenting = function() {
    thelist.noparenting = true;
  };

  /**
  * Remove the given item from its parent list.
  */
  thelist.remove = function(form) {
    var parent = parentOf(form);
    if(!parent) {
      parent = thelist;
    }
    else {
      if(parent !== thelist) {
        throw Error("Attempt to remove form from a list that was not it's parent");
      }
    }

    var pos = parent.indexOf(form);
    if(pos !== -1) {
      form.parent = undefined;
      delete parent[pos];
    }
    else {
      throw Error("Attempt to remove form from a list which didn't contain it");
    }

    return this;
  };

  thelist.error = function(msg, locator) {
    lexerOf(thelist).error(msg, locator || thelist);
  };

  /**
  * Get the simplified JSON representation of the atoms in this list.
  */
  thelist.toJSON = function() {
    return toJSON(this);
  };

  /**
  * For "object" or "attr" lists, this returns the js object with properties and
  * values equivalent to the lispy (object..) or (attr..) object.  For all other
  * lists it returns the same as toJSON (above).
  */
  thelist.toObject = function() {
    var obj;
    var jsonsexpr = toJSON(this);
    if(Array.isArray(jsonsexpr) && jsonsexpr.length > 0 &&
      (jsonsexpr[0] === 'object' || jsonsexpr[0] === 'attr'))
    {
      obj = {};
      for (var i = 1; i < jsonsexpr.length; i = i + 2) {
        // toJSON has already made keys into strings and values into primitives
        obj[jsonsexpr[i]] = jsonsexpr[i+1];
      }
    }
    else {
      // it wasn't an object/attr s-expression just give back our list json
      obj = jsonsexpr;
    }

    return obj;
  };

  /**
  * Set parents all the way down this form tree.
  */
  thelist.setParents = function(parent) {

    if(parent) {
      if(this.parent && this.parent !== parent) {
        console.log('warning:  setParents is *changing* an existing parent value??!!');
      }

      this.parent = parent;

    }

    this.forEach(function(form) {
      if(Array.isArray(form) && form.setParents) {
        form.setParents(thelist);
      }
    });
  };

  /**
  * Set the opening line/col for a list from the opening token (e.g. "(")
  * or current position in the Source
  */
  thelist.setOpening = function(tokenOrLexer) {
    this.line = tokenOrLexer.line;
    this.col = tokenOrLexer.col;

    // whitespace or comments that preceded the opening token
    // (e.g. on a () list whitespace or comments that preceded "(")
    this.prelude = tokenOrLexer.prelude;
  }

  /**
  * Set the closing line/col for a list from the closing token (e.g. ")")
  */
  thelist.setClosing = function(tokenOrLexer) {
    this.endLine = tokenOrLexer.line;
    this.endCol = tokenOrLexer.col;

    // whitespace or comments that preceded the end token
    // (e.g. on a () list whitespace or comments that preceded ")")
    this.endPrelude = tokenOrLexer.prelude;
  }

  // did they give an initial arr?
  if(arr && Array.isArray(arr) && arr.length > 0) {
    // wrap the elements and assign parents, etc.
    thelist = fromJSON(arr, thelist);
  }

/*
THIS APPEARS TO BE TRYING TO HELP SET LINE/COL POSITIONS FOR SOURCE
MAPS WHEN A LIST MIGHT HAVE SOME PROGRAM-CREATED TOKENS?  COMMENTED
FOR NOW SINCE WE'RE MOVING FROM THERE EVEN BEING ATOM.LEXER
  var atomwithsource = finddeep(thelist, function(atom) { return atom.lexer; });
  if(atomwithsource) {
    thelist.setOpening(lexerOf(atomwithsource));
  }
*/

  thelist.__islist = true; // is this is a sugarlisp list or just a js array?

  return thelist;
}
806862
def _list_to_set(self, list_key, set_key):
        
        if self.cls.database.support_scripting():
            self.cls.database.call_script(
                # be sure to use the script dict at the class level
                # to avoid registering it many times
                script_dict=self.__class__.scripts['list_to_set'],
                keys=[list_key, set_key]
            )
        else:
            conn = self.cls.get_connection()
            conn.sadd(set_key, *conn.lrange(list_key, 0, -1))
414310
private void _serializeList(List list, StringBuilder sb, Set<Object> done) throws ConverterException {

	sb.append(goIn());
	sb.append("[");
	boolean doIt = false;
	ListIterator it = list.listIterator();
	while (it.hasNext()) {
	    if (doIt) sb.append(',');
	    doIt = true;
	    _serialize(it.next(), sb, done);
	}

	sb.append(']');
    }
1086908
def set_list(self, name: str, plist) -> None:
        """"""
        self.lists[zlib.crc32(name.encode())] = plist
587463
def write_data_set(file_path, dataset, output_dir, color_array_info, new_name=None, compress=True):
    """"""
    fileName = new_name if new_name else os.path.basename(file_path)
    dataset_dir = os.path.join(output_dir, fileName)
    data_dir = os.path.join(dataset_dir, 'data')

    if not os.path.exists(data_dir):
        os.makedirs(data_dir)

    root = {}
    root['metadata'] = {}
    root['metadata']['name'] = fileName

    writer = writer_mapping[dataset.GetClassName()]
    if writer:
        writer(dataset_dir, data_dir, dataset, color_array_info, root, compress)
    else:
        print(dataObject.GetClassName(), 'is not supported')

    with open(os.path.join(dataset_dir, "index.json"), 'w') as f:
        f.write(json.dumps(root, indent=2))

    return dataset_dir
290906
def write_array(path, arr):
    """"""
    file_ext = op.splitext(path)[1]
    if file_ext == '.npy':
        return np.save(path, arr)
    raise NotImplementedError("The file extension `{}` ".format(file_ext) +
                              "is not currently supported.")
906704
public function setList($list = [])
    {
        if (!is_array($list)) {
            $list = ArrayUtils::iteratorToArray($list);
        }

        $this->list = $list;
    }
812057
public static Object addArray(Object list, Object[] array) {
        for (int i = 0; array != null && i < array.length; i++)
            list = LazyList.add(list, array[i]);
        return list;
    }