<commit_before>export function* map(fn, iterable) {
  for (const value of iterable) {
    yield fn(value);
  }
}

export function* filter(fn, iterable) {
  for (const value of iterable) {
    if (fn(value)) {
      yield value;
    }
  }
}

export function* first(iterable) {
  for (const value of iterable) {
    yield value;
    break;
  }
}

// export function* rest(iterable) {
//   let iterator = iterable[Symbol.iterator]();
//   iterator.next();
//   yield* iterator;
// }
export function* rest(iterable) {
  let first = true;
  for (const value of iterable) {
    if (first) {
      first = false;
    } else {
      yield value;
    }
  }
}

export function* reduce(fn, iterable) {
  let accumulator;
  for (const value of first(iterable)) {
    accumulator = value;<commit_msg>Implement basic list slicing operations<commit_after>export function* map(fn, iterable) {
  for (const value of iterable) {
    yield fn(value);
  }
}

export function* filter(fn, iterable) {
  for (const value of iterable) {
    if (fn(value)) {
      yield value;
    }
  }
}

export function* head(iterable) {
  for (const value of iterable) {
    yield value;
    break;
  }
}

export function* last(iterable) {
  let previousValue;
  for (const value of iterable) {
    previousValue = value;
  }
  yield value;
}

// export function* tail(iterable) {
//   let iterator = iterable[Symbol.iterator]();
//   iterator.next();
//   yield* iterator;
// }
export function* tail(iterable) {
  let first = true;
  for (const value of iterable) {
    if (first) {
      first = false;
    } else {
      yield value;
    }
  }
}

export function* init(iterable) {
  let previousValue;
  for (const value of first(iterable)) {
    previousValue = value;
  }
  for (const value of iterable) {
    yield previousValue
    previousValue = value;
  }
}

export function* reduce(fn, iterable) {
  let accumulator;
  for (const value of first(iterable)) {
    accumulator = value;
{'fraction_non_alphanumeric': 0.12423312883435583, 'fraction_numerical': 0.0, 'mean_word_length': 2.89065606361829, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3106152', 'n_tokens_mistral': 649, 'n_tokens_neox': 648, 'n_words': 188}