// sliceIQ creates an infinite buffered channel taking input on
// in and sending output to next.  SliceIQ should be run in its
// own goroutine.
339142
func sliceIQ(in <-chan Command, next chan<- Command) {
	defer close(next)

	// pending events (this is the "infinite" part)
	pending := []Command{}

recv:
	for {
		// Ensure that pending always has values so the select can
		// multiplex between the receiver and sender properly
		if len(pending) == 0 {
			v, ok := <-in
			if !ok {
				// in is closed, flush values
				break
			}

			// We now have something to send
			pending = append(pending, v)
		}

		select {
		// Queue incoming values
		case v, ok := <-in:
			if !ok {
				// in is closed, flush values
				break recv
			}
			pending = append(pending, v)

		// Send queued values
		case next <- pending[0]:
			pending[0] = nil
			pending = pending[1:]
		}
	}

	// After in is closed, we may still have events to send
	for _, v := range pending {
		next <- v
	}
}
666486
func Slice(list, start, end cty.Value) (cty.Value, error) {
	return SliceFunc.Call([]cty.Value{list, start, end})
}
499266
func makeReq(url string) ([]byte, error) {
  response, err := http.Get(url)
  if err != nil {
    fmt.Printf("%s", err)
    return nil, Error(fmt.Sprintf("%s", err))
  } else {
    defer response.Body.Close()
    contents, err := ioutil.ReadAll(response.Body)
    if err != nil {
      fmt.Printf("%s", err)
      return nil, Error(fmt.Sprintf("%s", err))
    }
    // fmt.Printf("%s\n", string(contents))
    return contents, nil
  }
}
87769
func (s *Selection) Slice(start, end int) *Selection {
	if start < 0 {
		start += len(s.Nodes)
	}
	if end < 0 {
		end += len(s.Nodes)
	}
	return pushStack(s, s.Nodes[start:end])
}
589487
func (dec *Decoder) SliceInt(s *[]int) error {
	err := dec.Array(DecodeArrayFunc(func(dec *Decoder) error {
		var i int
		if err := dec.Int(&i); err != nil {
			return err
		}
		*s = append(*s, i)
		return nil
	}))

	if err != nil {
		return err
	}
	return nil
}
1338921
func (s *Shuffler) Slice(slice Interface) {
	rv := reflect.ValueOf(slice)
	swap := reflect.Swapper(slice)
	(*rand.Rand)(s).Shuffle(rv.Len(), swap)
}
201432
func (b *Builder) Slice() (Slice, error) {
	if b.buf.IsEmpty() {
		return Slice{}, nil
	}
	bytes, err := b.Bytes()
	return bytes, WithStack(err)
}
1225305
func (enc *Encoder) SliceInt(s []int) {
	enc.Array(EncodeArrayFunc(func(enc *Encoder) {
		for _, i := range s {
			enc.Int(i)
		}
	}))
}
927304
func StringSlice(s Interface) []string {
	slice := make([]string, 0)
	for _, item := range s.List() {
		v, ok := item.(string)
		if !ok {
			continue
		}

		slice = append(slice, v)
	}
	return slice
}
1171946
func SliceOf(in interface{}) interface{} {
	value := reflect.ValueOf(in)

	sliceType := reflect.SliceOf(reflect.TypeOf(in))
	slice := reflect.New(sliceType)
	sliceValue := reflect.MakeSlice(sliceType, 0, 0)
	sliceValue = reflect.Append(sliceValue, value)
	slice.Elem().Set(sliceValue)

	return slice.Elem().Interface()
}
1309351
func (ns *Namespace) Uniq(seq interface{}) (interface{}, error) {
	if seq == nil {
		return make([]interface{}, 0), nil
	}

	v := reflect.ValueOf(seq)
	var slice reflect.Value

	switch v.Kind() {
	case reflect.Slice:
		slice = reflect.MakeSlice(v.Type(), 0, 0)
	case reflect.Array:
		slice = reflect.MakeSlice(reflect.SliceOf(v.Type().Elem()), 0, 0)
	default:
		return nil, errors.Errorf("type %T not supported", seq)
	}

	seen := make(map[interface{}]bool)
	for i := 0; i < v.Len(); i++ {
		ev, _ := indirectInterface(v.Index(i))
		if !ev.Type().Comparable() {
			return nil, errors.New("elements must be comparable")
		}
		key := normalize(ev)
		if _, found := seen[key]; !found {
			slice = reflect.Append(slice, ev)
			seen[key] = true
		}
	}

	return slice.Interface(), nil

}
681741
func (fc *Flow) Slices(slices [][]interface{}) (ret *Dataset) {

	ret = fc.NewNextDataset(1)
	step := fc.AddOneToOneStep(nil, ret)
	step.IsOnDriverSide = true
	step.Name = "Slices"
	step.Function = func(readers []io.Reader, writers []io.Writer, stat *pb.InstructionStat) error {
		for _, slice := range slices {
			stat.InputCounter++
			err := util.NewRow(util.Now(), slice).WriteTo(writers[0])
			if err != nil {
				return err
			}
			stat.OutputCounter++
		}
		return nil
	}
	return

}
1075950
func (i *Iter) returnSlice(a, b int) []byte {
	if i.rb.src.bytes == nil {
		return i.buf[:copy(i.buf[:], i.rb.src.str[a:b])]
	}
	return i.rb.src.bytes[a:b]
}
357863
func (s *SliceQueue) Dequeue() (interface{}, error) {
	if s.IsEmpty() {
		return nil, errors.New("unable to dequeue element, queue is empty")
	}

	item := s.backing[0]
	// https://github.com/golang/go/wiki/SliceTricks
	s.backing = append(s.backing[:0], s.backing[1:]...)
	s.size--
	return item, nil
}
125520
func Uniq(list interface{}) ([]interface{}, error) {
	l, err := interfaceSlice(list)
	if err != nil {
		return nil, err
	}

	out := []interface{}{}
	for _, v := range l {
		if !Has(out, v) {
			out = append(out, v)
		}
	}
	return out, nil
}
1008414
func (s *SeriesIDSet) Slice() []uint64 {
	s.RLock()
	defer s.RUnlock()

	a := make([]uint64, 0, s.bitmap.GetCardinality())
	for _, seriesID := range s.bitmap.ToArray() {
		a = append(a, uint64(seriesID))
	}
	return a
}
160370
func Slice(slice interface{}) {
	rv := reflect.ValueOf(slice)
	swap := reflect.Swapper(slice)
	n := rv.Len()
	for i := n - 1; i >= 0; i-- {
		j := rand.Intn(i + 1)
		swap(i, j)
	}
}