Returns a tuple consisting of the head of a enumerable, the middle
    as a list and the tail of the enumerable. If the enumerable is 1 item, the
    middle will be empty and the tail will be None. 

    >>> head_tail_middle([1, 2, 3, 4])
    1, [2, 3], 4
508288
def head_tail_middle(src):
    

    if len(src) == 0:
        return None, [], None

    if len(src) == 1:
        return src[0], [], None

    if len(src) == 2:
        return src[0], [], src[1]

    return src[0], src[1:-1], src[-1]
183739
public final Tuple2<Tuple1<T1>, Tuple4<T2, T3, T4, T5>> split1() {
        return new Tuple2<>(limit1(), skip1());
    }
389319
def reverse_list(head):
    
    if not head or not head.next:
        return head
    prev = None
    while head:
        current = head
        head = head.next
        current.next = prev
        prev = current
    return prev
452273
public static <T1, T2, T3> Tuple3<T1, T2, T3> tuple(T1 v1, T2 v2, T3 v3) {
        return new Tuple3<>(v1, v2, v3);
    }
1297610
public A next() {
        A x = elems.head;
        if (!elems.isEmpty()) {
            elems = elems.tail;
            if (elems.isEmpty()) last = null;
            count--;
        }
        return x;
    }
56033
def argmin(self):
        
        return tuple(centres[index] for centres, index in
                     zip(self.centres(), numpy.unravel_index(self.array.argmin(),
                                                             self.array.shape)))
756436
public final Tuple2<Tuple4<T1, T2, T3, T4>, Tuple0> split4() {
        return new Tuple2<>(limit4(), skip4());
    }
1331124
def tail(fpath, n=2, trailing=True):
    
    return path_ndir_split(fpath, n=n, trailing=trailing)
902720
def p_fromitem_list(self,t):
    
    if len(t)==2: t[0] = [t[1]]
    elif len(t)==4: t[0] = t[1] + [t[3]]
    else: raise NotImplementedError('unk_len', len(t)) # pragma: no cover
829218
def flat_list(*alist):
    
    a = []
    for x in alist:
        if x is None:
            continue
        if isinstance(x, (tuple, list)):
            a.extend([i for i in x if i is not None])
        else:
            a.append(x)
    return a
134748
def head(self, n):
        
        return DataAccessObject({k: self.dict[k][:n] for k in self.dict})
264758
def as_tuple(self):
        
        ptr = self._pointer
        return (ptr.xx, ptr.yx, ptr.xy, ptr.yy, ptr.x0, ptr.y0)
281379
def asTuple(self):
        
        t = []
        k = sorted(self.keys())
        for key in k:
            t.append((key, self[key]))
        return tuple(t)
16316
def constant_tuples(self):
        
        return [constant_tuple for tuple_prior in self.tuple_prior_tuples for constant_tuple in
                tuple_prior[1].constant_tuples] + self.direct_constant_tuples
223218
def _flatten(lst):
    
    if not isinstance(lst, (list, tuple)):
        return [lst]
    result = []
    for item in lst:
        result.extend(_flatten(item))
    return result
648375
def get_3_tuple_list(self,obj,default=None):
        
        if is_sequence2(obj):
            return [self.get_3_tuple(o,default) for o in obj]
        elif is_sequence(obj):
            return [self.get_3_tuple(obj[i:i+3],default) for i in range(0,len(obj),3)]
        else:
            return [self.get_3_tuple(obj,default)]
1207217
public static Tuple3<List<Point2D_F64>,List<Point2D_F64>,List<Point2D_F64>> split3(List<AssociatedTriple> input )
	{
		List<Point2D_F64> list1 = new ArrayList<>();
		List<Point2D_F64> list2 = new ArrayList<>();
		List<Point2D_F64> list3 = new ArrayList<>();

		for (int i = 0; i < input.size(); i++) {
			list1.add( input.get(i).p1 );
			list2.add( input.get(i).p2 );
			list3.add( input.get(i).p3 );
		}

		return new Tuple3<>(list1,list2,list3);
	}