Min generic function

Report a typo

Eugene wants to create a generic variadic function min. It must return the smallest item among two or more arguments and should have Ordered as its type constraint.

Eugene has already declared the Ordered constraint and has written a part of the algorithm of the min function. Your task is to help him write the rest of the algorithm of the min function, and also the missing code in the generic function declaration.

Sample Input 1:

Mike John Vicky
1 2 3

Sample Output 1:

John
1
Write a program in Go
package main

import (
"fmt"
"log"
)

type Ordered interface {
int | float64 | rune | string
}

// Write the additional required code to make the min function work
func min[T ?](? ...T) ? {
// Eugene has written the code block below:
if len(x) == 0 {
log.Fatal("min: no arguments")
}
m := x[0]

// Finish the algorithm for the min function below:
for _, v := range ? {
if ? {
?
}
}
return m
}

// DO NOT delete or modify the contents of the main function!
func main() {
var str1, str2, str3 string
fmt.Scanln(&str1, &str2, &str3)

var num1, num2, num3 int
fmt.Scanln(&num1, &num2, &num3)

___

Create a free account to access the full topic