func TestLTake(t *T) {
	testTakeGen(t, LTake)
}
Test lazily taking from a Seq
package seq
import (
	. "testing"
	"github.com/stretchr/testify/assert"
)
func testSeqGen(t *T, s Seq, ints []interface{}) Seq {
	intsl := uint64(len(ints))
	for i := range ints {
		assertSaneList(ToList(s), t)
		assert.Equal(t, intsl-uint64(i), Size(s))
		assert.Equal(t, ints[i:], ToSlice(s))
		first, rest, ok := s.FirstRest()
		assert.Equal(t, true, ok)
		assert.Equal(t, ints[i], first)
		s = rest
	}
	return s
}
func testSeqNoOrderGen(t *T, s Seq, ints []interface{}) Seq {
	intsl := uint64(len(ints))
	m := map[interface{}]bool{}
	for i := range ints {
		m[ints[i]] = true
	}
	for i := range ints {
		assertSaneList(ToList(s), t)
		assert.Equal(t, intsl-uint64(i), Size(s))
		assertSeqContentsNoOrderMap(t, m, s)
		first, rest, ok := s.FirstRest()
		assert.Equal(t, true, ok)
		_, ok = m[first]
		assert.Equal(t, true, ok)
		delete(m, first)
		s = rest
	}
	return s
}
func TestReverse(t *T) {
	intl := []interface{}{3, 2, 1}
	l := NewList(intl...)
	nl := Reverse(l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, []interface{}{1, 2, 3}, ToSlice(nl))
	l = NewList()
	nl = Reverse(l)
	assert.Equal(t, 0, Size(l))
	assert.Equal(t, 0, Size(nl))
}
func testMapGen(t *T, mapFn func(func(interface{}) interface{}, Seq) Seq) {
	fn := func(n interface{}) interface{} {
		return n.(int) + 1
	}
	intl := []interface{}{1, 2, 3}
	l := NewList(intl...)
	nl := mapFn(fn, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, []interface{}{2, 3, 4}, ToSlice(nl))
	l = NewList()
	nl = mapFn(fn, l)
	assert.Equal(t, 0, Size(l))
	assert.Equal(t, 0, Size(nl))
}
func TestMap(t *T) {
	testMapGen(t, Map)
}
func TestLMap(t *T) {
	testMapGen(t, LMap)
}
func TestReduce(t *T) {
	fn := func(acc, el interface{}) (interface{}, bool) {
		return acc.(int) + el.(int), false
	}
	intl := []interface{}{1, 2, 3, 4}
	l := NewList(intl...)
	r := Reduce(fn, 0, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, 10, r)
	fns := func(acc, el interface{}) (interface{}, bool) {
		return acc.(int) + el.(int), el.(int) > 2
	}
	r = Reduce(fns, 0, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, 6, r)
	l = NewList()
	r = Reduce(fn, 0, l)
	assert.Equal(t, 0, Size(l))
	assert.Equal(t, 0, r)
}
func TestAny(t *T) {
	fn := func(el interface{}) bool {
		return el.(int) > 3
	}
	intl := []interface{}{1, 2, 3, 4}
	l := NewList(intl...)
	r, ok := Any(fn, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, 4, r)
	assert.Equal(t, true, ok)
	intl = []interface{}{1, 2, 3}
	l = NewList(intl...)
	r, ok = Any(fn, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, nil, r)
	assert.Equal(t, false, ok)
	l = NewList()
	r, ok = Any(fn, l)
	assert.Equal(t, 0, Size(l))
	assert.Equal(t, nil, r)
	assert.Equal(t, false, ok)
}
func TestAll(t *T) {
	fn := func(el interface{}) bool {
		return el.(int) > 3
	}
	intl := []interface{}{4, 5, 6}
	l := NewList(intl...)
	ok := All(fn, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, true, ok)
	intl = []interface{}{3, 4, 2, 5}
	l = NewList(intl...)
	ok = All(fn, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, false, ok)
	l = NewList()
	ok = All(fn, l)
	assert.Equal(t, 0, Size(l))
	assert.Equal(t, true, ok)
}
func testFilterGen(t *T, filterFn func(func(interface{}) bool, Seq) Seq) {
	fn := func(el interface{}) bool {
		return el.(int)%2 != 0
	}
	intl := []interface{}{1, 2, 3, 4, 5}
	l := NewList(intl...)
	r := filterFn(fn, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, []interface{}{1, 3, 5}, ToSlice(r))
	l = NewList()
	r = filterFn(fn, l)
	assert.Equal(t, 0, Size(l))
	assert.Equal(t, 0, Size(r))
}
func TestFilter(t *T) {
	testFilterGen(t, Filter)
}
func TestLFilter(t *T) {
	testFilterGen(t, LFilter)
}
func TestFlatten(t *T) {
	intl1 := []interface{}{0, 1, 2}
	intl2 := []interface{}{3, 4, 5}
	l1 := NewList(intl1...)
	l2 := NewList(intl2...)
	blank := NewList()
	intl := []interface{}{-1, l1, l2, 6, blank, 7}
	l := NewList(intl...)
	nl := Flatten(l)
	assert.Equal(t, intl1, ToSlice(l1))
	assert.Equal(t, intl2, ToSlice(l2))
	assert.Equal(t, 0, Size(blank))
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, []interface{}{-1, 0, 1, 2, 3, 4, 5, 6, 7}, ToSlice(nl))
	nl = Flatten(blank)
	assert.Equal(t, 0, Size(blank))
	assert.Equal(t, 0, Size(nl))
}
func testTakeGen(t *T, takeFn func(uint64, Seq) Seq) {
	intl := []interface{}{0, 1, 2, 3, 4}
	l := NewList(intl...)
	nl := takeFn(3, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, []interface{}{0, 1, 2}, ToSlice(nl))
	nl = takeFn(5, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, intl, ToSlice(nl))
	nl = takeFn(6, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, intl, ToSlice(nl))
	empty := NewList()
	nl = takeFn(1, empty)
	assert.Equal(t, 0, Size(empty))
	assert.Equal(t, 0, Size(nl))
	nl = takeFn(0, l)
	assert.Equal(t, intl, ToSlice(l))
	assert.Equal(t, 0, Size(nl))
}
func TestTake(t *T) {
	testTakeGen(t, Take)
}