diff --git a/lab 5/CircleAndCylinder/CircleAndCylinder.fsproj b/lab 5/CircleAndCylinder/CircleAndCylinder.fsproj new file mode 100755 index 0000000..299cf40 --- /dev/null +++ b/lab 5/CircleAndCylinder/CircleAndCylinder.fsproj @@ -0,0 +1,12 @@ + + + + Exe + net7.0 + + + + + + + diff --git a/lab 5/CircleAndCylinder/Program.fs b/lab 5/CircleAndCylinder/Program.fs new file mode 100755 index 0000000..e45b2ab --- /dev/null +++ b/lab 5/CircleAndCylinder/Program.fs @@ -0,0 +1,42 @@ +// For more information see https://aka.ms/fsharp-console-apps +printfn "Hello from F#" + +// Функция для вычисления площади круга +let circleArea radius = System.Math.PI * radius * radius + +// Функция для вычисления объема цилиндра через суперпозицию +let cylinderVolume radius height = + circleArea radius * height + +// Функция для вычисления объема цилиндра через каррирование +let cylinderVolumeCurried radius = + fun height -> circleArea radius * height + +// Функция для чтения числа с консоли +let readFloat() = + System.Console.ReadLine() + |> System.Double.Parse + |> float + +// Основная функция +[] +let main argv = + System.Console.WriteLine("Введите радиус круга:") + let radius = readFloat() + + System.Console.WriteLine("Введите высоту цилиндра:") + let height = readFloat() + + // Вычисление через суперпозицию + let volume1 = cylinderVolume radius height + System.Console.WriteLine($"Объем цилиндра (через суперпозицию): {volume1:F2}") + + // Вычисление через каррирование + let volume2 = (cylinderVolumeCurried radius) height + System.Console.WriteLine($"Объем цилиндра (через каррирование): {volume2:F2}") + + // Демонстрация частичного применения + let area = circleArea radius + System.Console.WriteLine($"Площадь круга: {area:F2}") + + 0