<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def concatenate(samplesets, defaults=None):
 """Combine SampleSets. Args: samplesets (iterable[:obj:`.SampleSet`):
 An iterable of sample sets. defaults (dict, optional):
 Dictionary mapping data vector names to the corresponding default values. Returns: :obj:`.SampleSet`: A sample set with the same vartype and variable order as the first given in `samplesets`. Examples: array([[-1, 1], [ 1, -1]], dtype=int8) """


    itertup = iter(samplesets)

    try:
        first = next(itertup)
    except StopIteration:
        raise ValueError("samplesets must contain at least one SampleSet")

    vartype = first.vartype
    variables = first.variables

    records = [first.record]
    records.extend(_iter_records(itertup, vartype, variables))

    # dev note: I was able to get ~2x performance boost when trying to
    # implement the same functionality here by hand (I didn't know that
    # this function existed then). However I think it is better to use
    # numpy's function and rely on their testing etc. If however this becomes
    # a performance bottleneck in the future, it might be worth changing.
    record = recfunctions.stack_arrays(records, defaults=defaults,
                                       asrecarray=True, usemask=False)

    return SampleSet(record, variables, {}, vartype)