// Ljust returns a copied string slice where each element is left justified to
// match the width of the longest element in the set.
320913
func Ljust(strs []string) []string {
	llen := len(Longest(strs))

	dup := make([]string, len(strs), cap(strs))
	copy(dup, strs)

	for i, str := range strs {
		width := MaxInt(0, llen-len(str))
		padding := strings.Repeat(" ", width)

		dup[i] = str + padding
	}

	return dup
}
411135
func Equal(left Value, right Value) bool {
	// TODO: Stop-gap for now, this will need to be much more sophisticated.
	return CoerceString(left) == CoerceString(right)
}
1295304
func (s *StringOffset) Less(other Offset) bool {
	if s == nil {
		return other != nil
	} else if other == nil {
		return false
	}
	otherS, ok := other.(*StringOffset)
	if !ok {
		panic(fmt.Sprintf("Can't compare against non-string offset: %T", other))
	}
	return string(*s) < string(*otherS)
}
303849
func Pad(s, pad string, width int) string {
	gap := width - DisplayWidth(s)
	if gap > 0 {
		gapLeft := int(math.Ceil(float64(gap / 2)))
		gapRight := gap - gapLeft
		return strings.Repeat(string(pad), gapLeft) + s + strings.Repeat(string(pad), gapRight)
	}
	return s
}
912714
func (tb *LTable) Len() int {
	if tb.array == nil {
		return 0
	}
	var prev LValue = LNil
	for i := len(tb.array) - 1; i >= 0; i-- {
		v := tb.array[i]
		if prev == LNil && v != LNil {
			return i + 1
		}
		prev = v
	}
	return 0
}
597933
func InStringSlice(sl []string, val string) bool {
	for _, s := range sl {
		if s == val {
			return true
		}
	}

	return false
}
255715
func Relaxed() *regexp.Regexp {
	re := regexp.MustCompile(relaxedExp())
	re.Longest()
	return re
}
712808
func LtF(field1, field2 string) Matcher {
	return NewField2FieldMatcher(field1, field2, token.LSS)
}
1199611
func (c *replaceFunctionClass) fixLength(args []Expression) int {
	charLen := args[0].GetType().Flen
	oldStrLen := args[1].GetType().Flen
	diff := args[2].GetType().Flen - oldStrLen
	if diff > 0 && oldStrLen > 0 {
		charLen += (charLen / oldStrLen) * diff
	}
	return charLen
}
904354
func (s Seq) FoldRight(mapfn func(i int, v0, v float64) float64) (v0 float64) {
	if s.Len() == 0 {
		return 0
	}

	if s.Len() == 1 {
		return s.GetValue(0)
	}

	v0 = s.GetValue(s.Len() - 1)
	for i := s.Len() - 2; i >= 0; i-- {
		v0 = mapfn(i, v0, s.GetValue(i))
	}
	return
}
979996
func removeElementFromStringSlice(list []string, elem string) []string {
	for i, e := range list {
		if e == elem {
			return append(list[:i], list[i+1:]...)
		}
	}
	return list
}
575822
func padRight(in, pad string, length int) string {
	for {
		in += pad
		if len(in) > length {
			return in[0:length]
		}
	}
}
1279716
func (list *List) SetIndent(indent int) {
	list.indent = "" + strings.Repeat(" ", indent)
}
532350
func (r *Redis) LSet(key string, index int, value string) error {
	rp, err := r.ExecuteCommand("LSET", key, index, value)
	if err != nil {
		return err
	}
	return rp.OKValue()
}
1203315
func (db *DB) LTrim(key []byte, start, stop int64) error {
	return db.ltrim2(key, start, stop)
}
1360549
func truncateWithEllipsis(str string, maxWidth int, leftTruncate bool) string {
	if len(str) <= maxWidth {
		return str
	}
	if leftTruncate {
		return fmt.Sprintf("...%s", str[len(str)-(maxWidth-3):])
	}
	return fmt.Sprintf("%s...", str[:maxWidth-3])
}
1220267
func flattenStepAdjustments(adjustments []*autoscaling.StepAdjustment) []map[string]interface{} {
	result := make([]map[string]interface{}, 0, len(adjustments))
	for _, raw := range adjustments {
		a := map[string]interface{}{
			"scaling_adjustment": aws.Int64Value(raw.ScalingAdjustment),
		}
		if raw.MetricIntervalUpperBound != nil {
			a["metric_interval_upper_bound"] = fmt.Sprintf("%g", aws.Float64Value(raw.MetricIntervalUpperBound))
		}
		if raw.MetricIntervalLowerBound != nil {
			a["metric_interval_lower_bound"] = fmt.Sprintf("%g", aws.Float64Value(raw.MetricIntervalLowerBound))
		}
		result = append(result, a)
	}
	return result
}