commit 03e7be38dd1adf5d6a2cf24a06ba277a1644a0f8 Author: davidon-top Date: Wed Jan 15 08:39:24 2025 +0100 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..87097a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +obj +bin +*.user \ No newline at end of file diff --git a/ulohyfs.sln b/ulohyfs.sln new file mode 100644 index 0000000..27b0e4e --- /dev/null +++ b/ulohyfs.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ulohyfs", "ulohyfs\ulohyfs.fsproj", "{E2CE65C1-992E-4503-9F45-D81EE577A417}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E2CE65C1-992E-4503-9F45-D81EE577A417}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2CE65C1-992E-4503-9F45-D81EE577A417}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2CE65C1-992E-4503-9F45-D81EE577A417}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2CE65C1-992E-4503-9F45-D81EE577A417}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/ulohyfs/src/Attributes.fs b/ulohyfs/src/Attributes.fs new file mode 100644 index 0000000..f3bd7e3 --- /dev/null +++ b/ulohyfs/src/Attributes.fs @@ -0,0 +1,7 @@ +module UlohyFs.Attributes + +open System + +type UlohaAttribute(id: int) = + inherit Attribute() + member _.Id = id diff --git a/ulohyfs/src/Program.fs b/ulohyfs/src/Program.fs new file mode 100644 index 0000000..7cb2c4b --- /dev/null +++ b/ulohyfs/src/Program.fs @@ -0,0 +1,30 @@ +module UlohyFs.Program + +open System +open System.Reflection +open UlohyFs.Attributes + +[] +let main args = + let ulohy = + Assembly.GetExecutingAssembly().GetTypes() + |> Array.map _.GetMethods() + |> Array.collect id + |> Array.filter (fun m -> m.GetCustomAttributes(typeof, false).Length > 0) + printfn "Zadaj cislo ulohy:" + let uloha = Console.ReadLine() + let uloha = Convert.ToInt32(uloha) + let ulohameta = + ulohy + |> Array.map (fun m -> ( + let ua = + m.GetCustomAttributes(typeof, false) + |> Array.map (fun a -> a :?> UlohaAttribute) + (ua[0], m) + )) + |> Array.find (fun (a, _) -> a.Id = uloha) + + let _, m = ulohameta + m.Invoke(null, null) |> ignore + + 0 \ No newline at end of file diff --git a/ulohyfs/src/u15.fs b/ulohyfs/src/u15.fs new file mode 100644 index 0000000..d603ff7 --- /dev/null +++ b/ulohyfs/src/u15.fs @@ -0,0 +1,24 @@ +module UlohyFs.u15 + +open System.IO +open System.Text.Unicode +open UlohyFs.Attributes +open System + +let path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/spokojnost.txt" +let npath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/nespokojnost.txt" + +[] +let uloha15() = + let spokojnost = + File.ReadAllLines(path) + |> Array.map (fun l -> Convert.ToInt32(l)) + let nfile = File.Create(npath) + spokojnost |> Array.iter (fun s -> ( + if s <= 5 then + nfile.Write(Text.Encoding.UTF8.GetBytes(s.ToString() + "\n")) + )) + nfile.Flush() + nfile.Close() + printfn "Pocet zakaznikov: %d" spokojnost.Length + printfn "Priemer: %f" (spokojnost |> Array.map (fun f -> float f) |> Array.average) \ No newline at end of file diff --git a/ulohyfs/src/u16.fs b/ulohyfs/src/u16.fs new file mode 100644 index 0000000..d758d8f --- /dev/null +++ b/ulohyfs/src/u16.fs @@ -0,0 +1,16 @@ +module UlohyFs.u16 + +open System +open UlohyFs.Attributes + +[] +let uloha16() = + let original = "mATURITNÁ SKÚŠKA Z iNFORMATIKY" + let added = sprintf $"{original} aktuálny rok, v ktorom maturujete" + printfn "%s" added + original.IndexOf "SKÚŠKA" + |> printfn "Index SKÚŠKA: %d" + printfn "inverted case: %s" (original |> Seq.map (fun c -> if Char.IsLower c then Char.ToUpper c else Char.ToLower c) |> Seq.toArray |> System.String) + printfn "replaced %s" (original.Replace("Informatiky", "Programovania")) + + printfn "all operations: %s" (added |> Seq.map (fun c -> if Char.IsLower c then Char.ToUpper c else Char.ToLower c) |> Seq.toArray |> System.String |> fun s -> s.Replace("Informatiky", "Programovania")) diff --git a/ulohyfs/src/u17.fs b/ulohyfs/src/u17.fs new file mode 100644 index 0000000..e85a4d5 --- /dev/null +++ b/ulohyfs/src/u17.fs @@ -0,0 +1,15 @@ +module UlohyFs.u17 + +open System.IO +open UlohyFs.Attributes +open System + +let eur2usd euro = + euro * 1.0245 + +[] +let uloha15() = + printfn "Eur?: " + let eur = System.Console.ReadLine() |> float + let usd = eur2usd eur + printfn "USD: %f" usd diff --git a/ulohyfs/ulohyfs.fsproj b/ulohyfs/ulohyfs.fsproj new file mode 100644 index 0000000..5055383 --- /dev/null +++ b/ulohyfs/ulohyfs.fsproj @@ -0,0 +1,17 @@ + + + + Exe + net9.0 + UlohyFs + + + + + + + + + + +