>>> [1, 4, 6, 4, 1] > take_until(X > 5) | list
    [1, 4]

    >>> [1, 4, 6, 4, 1] > take_until(X > 5).including | list
    [1, 4, 6]
348594
def take_until(condition):
    
    f = partial(takewhile, pipe | condition | operator.not_)
    f.attrs = {'including': take_until_including(condition)}
    return f
725817
def chop_sequence(sequence, limit_length):
        
        return [sequence[i:i + limit_length] for i in range(0, len(sequence), limit_length)]
75530
def flatten_list(l):
    
    if (l == []) or (l is None):
        return l
    if isinstance(l[0], list):
        return flatten_list(l[0]) + flatten_list(l[1:])
    return l[:1] + flatten_list(l[1:])
171108
def listify(val, return_type=tuple):
    
    # TODO: flatlistify((1, 2, 3), 4, (5, 6, 7))
    if val is None:
        return return_type()
    elif isiterable(val):
        return return_type(val)
    else:
        return return_type((val, ))
1108972
def window(seq, n=2):

    

    it = iter(seq)
    result = tuple(islice(it, n))

    if len(result) == n:
        yield result

    for token in it:
        result = result[1:] + (token,)
        yield result
245319
def split_every(parts, iterable):
    
    return takewhile(bool, (list(islice(iterable, parts)) for _ in count()))
290009
def p_iteration_statement_5(self, p):
        
        p[0] = ast.ForIn(item=ast.VarDecl(p[4]), iterable=p[6], statement=p[8])
1113379
public Vector slice(int from, int until) {
        if (until - from < 0) {
            fail("Wrong slice range: [" + from + ".." + until + "].");
        }

        Vector result = blankOfLength(until - from);

        for (int i = from; i < until; i++) {
            result.set(i - from, get(i));
        }

        return result;
    }
1268735
public List<Integer> until(int end) {
                List<Integer> list = new ArrayList<>();
                for (int i = this.n; i < end; ++i) {
                        list.add(i);
                }
                return list;
        }
1112184
def safe_slice(list_, *args):
    
    if len(args) == 3:
        start = args[0]
        stop  = args[1]
        step  = args[2]
    else:
        step = 1
        if len(args) == 2:
            start = args[0]
            stop  = args[1]
        else:
            start = 0
            stop = args[0]
    len_ = len(list_)
    if stop > len_:
        stop = len_
    return list_[slice(start, stop, step)]
1146511
def bracketedList(l, r, sep, expr, allow_missing_close=False):
  
  # We may need to backtrack for lists, because of list comprehension, but not for
  # any of the other lists
  strict = l != '['
  closer = sym(r) if not allow_missing_close else p.Optional(sym(r))
  if strict:
    return sym(l) - listMembers(sep, expr) - closer
  else:
    return sym(l) + listMembers(sep, expr) + closer
1267516
def _group(tlist, cls, match,
           valid_prev=lambda t: True,
           valid_next=lambda t: True,
           post=None,
           extend=True,
           recurse=True
           ):
    """"""

    tidx_offset = 0
    pidx, prev_ = None, None
    for idx, token in enumerate(list(tlist)):
        tidx = idx - tidx_offset

        if token.is_whitespace:
            continue

        if recurse and token.is_group and not isinstance(token, cls):
            _group(token, cls, match, valid_prev, valid_next, post, extend)

        if match(token):
            nidx, next_ = tlist.token_next(tidx)
            if prev_ and valid_prev(prev_) and valid_next(next_):
                from_idx, to_idx = post(tlist, pidx, tidx, nidx)
                grp = tlist.group_tokens(cls, from_idx, to_idx, extend=extend)

                tidx_offset += to_idx - from_idx
                pidx, prev_ = from_idx, grp
                continue

        pidx, prev_ = tidx, token
872039
def take_while(&predicate)
      filter("take_while") do |yielder, all_done|
        each do |element|
          throw all_done unless yield(element)
          yielder.call(element)
        end
      end
    end
893149
def operatorOperands(tokenlist):
    ""
    it = iter(tokenlist)
    while 1:
        try:
            yield (next(it), next(it))
        except StopIteration:
            break
194213
function eagerSlice (list, start, end) {
  const sliced = []
  for (let i = start; i < end; i++) {
    sliced.push(list[i])
  }
  return sliced
}
340364
@Override
    public ListT<W,T> takeUntil(final Predicate<? super T> p) {

        return (ListT<W,T>) FoldableTransformerSeq.super.takeUntil(p);
    }
185551
function untilFn(test, fn) {
    return this.then(function(last) {
        if (!test(last)) {
            return Q(fn(last)).then(function(value) {
                return Q(value).until(test, fn);
            });
        }
        return last;
    });
}