<commit_before>package org.basex.query.func.array;

import java.util.*;

import org.basex.query.*;
import org.basex.query.iter.*;
import org.basex.query.value.*;
import org.basex.query.value.array.*;
import org.basex.query.value.item.*;

/**
 * Function implementation.
 *
 * @author BaseX Team 2005-17, BSD License
 * @author <NAME>
 * @author <NAME>
 */
public final class ArrayFlatten extends ArrayFn {
  @Override
  public Value value(final QueryContext qc) throws QueryException {
    final ValueBuilder vb = new ValueBuilder();
    final Iter iter = qc.iter(exprs[0]);
    for(Item it; (it = iter.next()) != null;) add(vb, it, qc);
    return vb.value();
  }<commit_msg>[MOD] XQuery, array:flatten, better typing<commit_after>package org.basex.query.func.array;

import java.util.*;

import org.basex.query.*;
import org.basex.query.expr.*;
import org.basex.query.iter.*;
import org.basex.query.value.*;
import org.basex.query.value.array.*;
import org.basex.query.value.item.*;
import org.basex.query.value.type.*;

/**
 * Function implementation.
 *
 * @author BaseX Team 2005-17, BSD License
 * @author <NAME>
 * @author <NAME>
 */
public final class ArrayFlatten extends ArrayFn {
  @Override
  public Value value(final QueryContext qc) throws QueryException {
    final ValueBuilder vb = new ValueBuilder();
    final Iter iter = qc.iter(exprs[0]);
    for(Item it; (it = iter.next()) != null;) add(vb, it, qc);
    return vb.value();
  }

  @Override
  protected Expr opt(final CompileContext cc) throws QueryException {
    exprType.assign(type(exprs[0].seqType().type));
    return this;
  }


  /**
   * Recursive helper method for retrieving result type.
   * @param t type
   * @return result type
   */
  private static Type type(final Type t) {
    return t instanceof ArrayType ? type(((ArrayType) t).declType.type) : t;
  }
{'fraction_non_alphanumeric': 0.14316702819956617, 'fraction_numerical': 0.008134490238611713, 'mean_word_length': 3.7674418604651163, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6648337', 'n_tokens_mistral': 612, 'n_tokens_neox': 595, 'n_words': 163}