// choose returns a random unicode character from the given range, using the
// given randomness source.
346995
func (r *charRange) choose(rand *rand.Rand) rune {
	count := int64(r.last - r.first)
	return r.first + rune(rand.Int63n(count))
}
942327
func (session *Session) Select(str string) *Session {
	session.statement.Select(str)
	return session
}
56783
func (p *Pollster) Select(l List) (string, error) {
	return p.SelectVerify(l, VerifyOptions(l.Singular, l.Options, l.Default != ""))
}
971467
func (c *Client) Random(args []string) (Random, error) {
	argsStr := strings.Join(args, " ")

	req, err := c.NewRequest("/gifs/random?tag=" + argsStr)
	if err != nil {
		return Random{}, err
	}

	var random Random
	if _, err = c.Do(req, &random); err != nil {
		return Random{}, err
	}

	// Check if the first character in Data is a [
	if random.RawData == nil || random.RawData[0] == '[' {
		return Random{}, ErrNoImageFound
	}

	var d RandomData

	err = json.Unmarshal(random.RawData, &d)
	if err != nil {
		return Random{}, err
	}

	random.Data = d

	return random, nil
}
1373187
func (t *Object) Select(name interface{}) Type {
	for _, p := range t.static {
		if util.Compare(p.Key, name) == 0 {
			return p.Value
		}
	}
	if t.dynamic != nil {
		if Contains(t.dynamic.Key, TypeOf(name)) {
			return t.dynamic.Value
		}
	}
	return nil
}
470027
func Select(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "select", Listener: listener}
}
213413
func (r *Random) Select(pool HostPool) *UpstreamHost {
	// instead of just generating a random index
	// this is done to prevent selecting a down host
	var randHost *UpstreamHost
	count := 0
	for _, host := range pool {
		if host.Down() {
			continue
		}
		count++
		if count == 1 {
			randHost = host
		} else {
			r := rand.Int() % count
			if r == (count - 1) {
				randHost = host
			}
		}
	}
	return randHost
}
191920
func choose(n, k int) int {
	if k == 0 {
		return 1
	} else if n == 0 {
		return 0
	}
	result := float32(n - (k - 1))
	for i := 2; i <= k; i++ {
		result *= float32(n-(k-i)) / float32(i)
	}

	return int(result)
}
877982
func Choose(message string, choices []string, defaultChoice string) string {
	return (&Prompter{
		Message: message,
		Choices: choices,
		Default: defaultChoice,
	}).Prompt()
}
797133
func (session *Session) Select(str string) *Session {
	session.Statement.Select(str)
	return session
}
880427
func choose(args jet.Arguments) reflect.Value {
	args.RequireNumOfArguments("choose", 2, -1)

	var v reflect.Value
	for i, n := 0, args.NumOfArguments(); i < n; i++ {
		v = args.Get(i)
		if !reflects.IsEmpty(v) {
			return reflects.Indirect(v)
		}
	}
	return reflects.Indirect(v)
}
235156
func (h *HCI) Option(opts ...Option) error {
	var err error
	for _, opt := range opts {
		err = opt(h)
	}
	return err
}
168494
func (u *Ugen) Rand() Input {
	return unaryOpRand(u.Rate, u, u.NumOutputs)
}
1153691
func (s *RRSetsService) Select(k RRSetKey) ([]RRSet, error) {
	// TODO: Sane Configuration for timeouts / retries
	maxerrs := 5
	waittime := 5 * time.Second

	rrsets := []RRSet{}
	errcnt := 0
	offset := 0

	for {
		reqRrsets, ri, res, err := s.SelectWithOffset(k, offset)
		if err != nil {
			if res != nil && res.StatusCode >= 500 {
				errcnt = errcnt + 1
				if errcnt < maxerrs {
					time.Sleep(waittime)
					continue
				}
			}
			return rrsets, err
		}

		log.Printf("ResultInfo: %+v\n", ri)
		for _, rrset := range reqRrsets {
			rrsets = append(rrsets, rrset)
		}
		if ri.ReturnedCount+ri.Offset >= ri.TotalCount {
			return rrsets, nil
		}
		offset = ri.ReturnedCount + ri.Offset
		continue
	}
}
318834
func GetSelection(ctx context.Context, prompt, usage string, choices []string) (string, int) {
	if ctxutil.IsAlwaysYes(ctx) || !ctxutil.IsInteractive(ctx) {
		return "impossible", 0
	}

	if prompt != "" {
		prompt += " "
	}

	if err := termbox.Init(); err != nil {
		panic(err)
	}
	defer termbox.Close()

	const coldef = termbox.ColorDefault
	termbox.Clear(coldef, coldef)

	cur := 0
	for {
		// check for context cancelation
		select {
		case <-ctx.Done():
			return "aborted", cur
		default:
		}
		termbox.Clear(coldef, coldef)
		tbprint(0, 0, coldef, coldef, prompt+"Please select:")
		_, h := termbox.Size()
		offset := 0
		if len(choices)+2 > h && cur > h-3 {
			offset = cur
		}
		for i := offset; i < len(choices) && i-offset < h; i++ {
			c := choices[i]
			mark := " "
			if cur == i {
				mark = ">"
			}
			tbprint(0, 1+i-offset, coldef, coldef, fmt.Sprintf("%s %s", mark, c))
		}
		tbprint(0, h-1, coldef, coldef, formatUsageLine(ctx, usage, offset, cur, choices))
		_ = termbox.Flush()
		var act string
		if act, cur = tbpoll(cur, len(choices)); act != "" {
			return act, cur
		}
	}
}
81341
func (sess *Session) Select(column ...string) *SelectStmt {
	b := Select(prepareSelect(column)...)
	b.runner = sess
	b.EventReceiver = sess.EventReceiver
	b.Dialect = sess.Dialect
	return b
}
434706
func (s *RandomHostSelectionStrategy) Select(hosts []h.Host) (h.Host, error) {
	n := len(hosts)
	if n == 0 {
		return h.Host{}, ErrNoHosts
	}
	return hosts[rand.Intn(n)], nil
}