| 847 | } |
| 848 | |
| 849 | func minList(numList ref.Val) ref.Val { |
| 850 | l := numList.(traits.Lister) |
| 851 | size := l.Size().(types.Int) |
| 852 | if size == types.IntZero { |
| 853 | return types.NewErr("math.@min(list) argument must not be empty") |
| 854 | } |
| 855 | min := l.Get(types.IntZero) |
| 856 | for i := types.IntOne; i < size; i++ { |
| 857 | min = minPair(min, l.Get(i)) |
| 858 | } |
| 859 | switch min.Type() { |
| 860 | case types.IntType, types.DoubleType, types.UintType, types.UnknownType: |
| 861 | return min |
| 862 | default: |
| 863 | return types.NewErr("no such overload: math.@min") |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | func maxPair(first, second ref.Val) ref.Val { |
| 868 | cmp, ok := first.(traits.Comparer) |