scyros 0.3.1

A framework to design sound, reproducible and scalable mining repositories studies on GitHub.
// Function demonstrating use of `defer`, `recover`, and floating-point panic
func safeDivision(a, b float64) (result float64) {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println("Recovered from panic:", r)
			result = math.NaN()
		}
	}()
	if b == 0 {
		panic("division by zero")
	}
	return a / b
}

func main() {
	// Demonstrate variadic function
	fmt.Println("Sum of floats:", sumFloats(1.1, 2.2, 3.3))

	// Demonstrate multiple return values
	x, y := polarToCartesian(1, Pi/4)
	fmt.Printf("Polar to Cartesian: (x, y) = (%.2f, %.2f)\n", x, y)

	// Demonstrate complex number function
	c := complex(3, 4)
	fmt.Printf("Magnitude of complex number: %.2f\n", complexMagnitude(c))

	// Demonstrate deferred division
	fmt.Printf("Deferred division: %.2f\n", deferredDivision(10, 0))

	// Demonstrate recursive square root approximation
	fmt.Printf("Approximate sqrt(2): %.5f\n", approximateSqrt(2, 1))

	// Demonstrate floating-point precision issues
	precisionDemo()

	// Demonstrate floating-point map
	trigMap := trigonometricMap()
	for k, v := range trigMap {
		fmt.Printf("%s = %.5f\n", k, v)
	}

	// Demonstrate floating-point channels
	sineWave := make(chan float64)
	go generateSineWave(1, 1, 10, sineWave)
	fmt.Println("Sine wave samples:")
	for sample := range sineWave {
		fmt.Printf("%.5f ", sample)
	}
	fmt.Println()

	// Demonstrate switch with floating-point values
	fmt.Println("Classify float:", classifyFloat(math.NaN()))

	// Demonstrate labeled break with floating-point loop
	values := []float64{0.1, 0.2, 0.3, 0.4, 0.5}
	if v, found := findFirstAboveThreshold(0.35, values); found {
		fmt.Printf("First value above threshold: %.2f\n", v)
	} else {
		fmt.Println("No value above threshold found")
	}

	// Demonstrate select with floating-point channels
	selectFromChannels()

	// Demonstrate safe division with panic and recover
	fmt.Printf("Safe division: %.2f\n", safeDivision(10, 0))

	// Demonstrate runtime.GOARCH for floating-point architecture
	fmt.Printf("Floating-point architecture: %s\n", runtime.GOARCH)
}