From afc3a6e54eec48f88a755bf8ae1b86212a1212e7 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Wed, 13 Aug 2025 20:59:15 +0100 Subject: [PATCH 1/2] Add initial project files and configuration --- Kevin/.idea/.idea.Kevin/.idea/.gitignore | 13 ++ Kevin/.idea/.idea.Kevin/.idea/encodings.xml | 4 + Kevin/.idea/.idea.Kevin/.idea/indexLayout.xml | 8 ++ Kevin/.idea/.idea.Kevin/.idea/vcs.xml | 7 + Kevin/Kevin.sln | 16 +++ Kevin/Kevin/Kevin.vbproj | 9 ++ Kevin/Kevin/Program.vb | 133 ++++++++++++++++++ 7 files changed, 190 insertions(+) create mode 100644 Kevin/.idea/.idea.Kevin/.idea/.gitignore create mode 100644 Kevin/.idea/.idea.Kevin/.idea/encodings.xml create mode 100644 Kevin/.idea/.idea.Kevin/.idea/indexLayout.xml create mode 100644 Kevin/.idea/.idea.Kevin/.idea/vcs.xml create mode 100644 Kevin/Kevin.sln create mode 100644 Kevin/Kevin/Kevin.vbproj create mode 100644 Kevin/Kevin/Program.vb diff --git a/Kevin/.idea/.idea.Kevin/.idea/.gitignore b/Kevin/.idea/.idea.Kevin/.idea/.gitignore new file mode 100644 index 0000000..ba5c6f2 --- /dev/null +++ b/Kevin/.idea/.idea.Kevin/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/modules.xml +/contentModel.xml +/.idea.Kevin.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Kevin/.idea/.idea.Kevin/.idea/encodings.xml b/Kevin/.idea/.idea.Kevin/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/Kevin/.idea/.idea.Kevin/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Kevin/.idea/.idea.Kevin/.idea/indexLayout.xml b/Kevin/.idea/.idea.Kevin/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/Kevin/.idea/.idea.Kevin/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Kevin/.idea/.idea.Kevin/.idea/vcs.xml b/Kevin/.idea/.idea.Kevin/.idea/vcs.xml new file mode 100644 index 0000000..62bd7a0 --- /dev/null +++ b/Kevin/.idea/.idea.Kevin/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Kevin/Kevin.sln b/Kevin/Kevin.sln new file mode 100644 index 0000000..a26e4b3 --- /dev/null +++ b/Kevin/Kevin.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Kevin", "Kevin\Kevin.vbproj", "{85526CE4-E046-4FF2-8ED6-8DF98D0A8F28}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {85526CE4-E046-4FF2-8ED6-8DF98D0A8F28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85526CE4-E046-4FF2-8ED6-8DF98D0A8F28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85526CE4-E046-4FF2-8ED6-8DF98D0A8F28}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85526CE4-E046-4FF2-8ED6-8DF98D0A8F28}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Kevin/Kevin/Kevin.vbproj b/Kevin/Kevin/Kevin.vbproj new file mode 100644 index 0000000..2a3bc3d --- /dev/null +++ b/Kevin/Kevin/Kevin.vbproj @@ -0,0 +1,9 @@ + + + + Exe + Kevin + net9.0 + + + diff --git a/Kevin/Kevin/Program.vb b/Kevin/Kevin/Program.vb new file mode 100644 index 0000000..16d8ca5 --- /dev/null +++ b/Kevin/Kevin/Program.vb @@ -0,0 +1,133 @@ +Imports System +Imports System.Numerics + +Module Program + Sub Main(args As String()) + Console.WriteLine("Hello World!") + + Dim empty = ListOf (Of String).Nil + Console.WriteLine("is Nil:" + empty.IsNil().ToString()) + Dim list1 = ListOf (Of String).Cons("World", empty) + Console.WriteLine("is Nil:" + list1.IsNil().ToString()) + Console.WriteLine(list1.Head) + Dim list2 = ListOf (Of String).Cons("Hello", list1) + Console.WriteLine("is Nil:" + list2.IsNil().ToString()) + + Console.WriteLine(list2.ToString()) + + Dim myList as ListOf(Of Integer) = ListOf (Of Integer).Cons(1, ListOf (Of Integer).Cons(2, + ListOf (Of Integer).Cons( + 3, + ListOf _ + ( _ + Of _ + Integer + ) _ + . + Nil))) + Dim total1 = sum(myList) + Console.WriteLine("Sum of list: " + total1.ToString()) + + Dim total2 = Times(myList) + Console.WriteLine("Times of list: " + total2.ToString()) + + Dim Add = Function(x, y) x + y + + Dim AddTen = foldr (Of Integer, Integer)(Add, 10, myList) + Console.WriteLine("Foldr sum of list: " + AddTen.ToString()) + + Dim values As Integer() = {1, 2, 3, 4, 5} + Dim myList2 As ListOf(Of Integer) = BuildList(values) + Console.WriteLine("Built List: " + sum(myList2).ToString()) + + Dim bools1 = {False, False, False} + Dim myListBools1 = BuildList(bools1) + Console.WriteLine("Built List: " + AnyTrue(myListBools1).ToString()) + + Dim bools2 = {True, True, True} + Dim myListBools2 = BuildList(bools2) + Console.WriteLine("Built List: " + AllTrue(myListBools2).ToString()) + + Dim values232 As Integer() = {1, 2, 3, 4, 5} + Dim myList232 As ListOf(Of Integer) = CopyList(BuildList(values232)) + Console.WriteLine("Built List: " + sum(myList232).ToString()) + + Dim values2321 As Integer() = {1, 2} + Dim values2322 As Integer() = {1, 2} + Dim myList2323 As ListOf(Of Integer) = Append(BuildList(values2321), BuildList(values2322)) + Console.WriteLine("Built List: " + sum(myList2323).ToString()) + End Sub + + Function AnyTrue(list As ListOf(Of Boolean)) As Boolean + return Foldr(Function(x, y) x Or y, False, list) + End Function + + Function AllTrue(list As ListOf(Of Boolean)) As Boolean + return Foldr(Function(x, y) x And y, True, list) + End Function + + Function BuildList (Of T)(values as T()) as ListOf(Of T) + if (values.Length = 0) + return ListOf (Of T).Nil + End If + return ListOf (Of T).Cons(values(0), BuildList(values.Skip(1).ToArray())) + End Function + + Function CopyList (Of T)(list As ListOf(Of T)) As ListOf(Of T) + return Foldr(Function(x, y) ListOf (Of T).Cons(x, y), ListOf (Of T).Nil, list) + End Function + + Function Append (Of T)(list1 As ListOf(Of T), list2 As ListOf(Of T)) As ListOf(Of T) + return Foldr(Function(x, y) ListOf (Of T).Cons(x, y), list2, list1) + End Function + + Function Foldr (Of T, TReturn)(func As Func(Of T, TReturn, TReturn), initial As TReturn, list As ListOf(Of T)) _ + As TReturn + If list.IsNil() Then + Return initial + Else + Return func(list.Head, Foldr(func, initial, list.Tail)) + End If + End Function + + Function Sum(list As ListOf(Of Integer)) As Integer + If list.IsNil() Then + Return 0 + Else + Return list.Head + Sum(list.Tail) + End If + End Function + + Function Times(list As ListOf(Of Integer)) As Integer + If list.IsNil() Then + Return 1 + Else + Return list.Head*Times(list.Tail) + End If + End Function +End Module + +Class ListOf (Of T) + Public Property Head As T + Public Property Tail As ListOf(Of T) + + Private Sub New() + End Sub + + Public Overrides Function ToString() As String + Return Head.ToString() + If(Tail.IsNil(), "", Tail.ToString()) + End Function + + Public Shared ReadOnly Nil As ListOf(Of T) = New ListOf(Of T)() + + Public Shared Function Cons(arg1 as T, arg2 as ListOf(Of T)) as ListOf(Of T) + Dim result As New ListOf(Of T)() + result.Head = arg1 + result.Tail = arg2 + Return result + End Function + + Public Function IsNil() as Boolean + return Me Is Nil + End Function +End Class From 336a1d7c8744fa48093d79810730858dfdde8370 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Wed, 13 Aug 2025 21:01:23 +0100 Subject: [PATCH 2/2] Refactor variable names for clarity and consistency in Program.vb --- .../.idea/.idea.Kevin/.idea/.gitignore | 0 .../.idea/.idea.Kevin/.idea/encodings.xml | 0 .../.idea/.idea.Kevin/.idea/indexLayout.xml | 0 .../.idea/.idea.Kevin/.idea/vcs.xml | 0 .../.idea/.gitignore | 13 +++ .../.idea/encodings.xml | 4 + .../.idea.Kevin_Richard_Simon/.idea/vcs.xml | 4 + .../Kevin_Richard_Simon.sln | 2 +- .../Kevin_Richard_Simon.vbproj | 0 .../Kevin_Richard_Simon}/Program.vb | 104 +++++++++--------- 10 files changed, 74 insertions(+), 53 deletions(-) rename {Kevin => Kevin_Richard_Simon}/.idea/.idea.Kevin/.idea/.gitignore (100%) rename {Kevin => Kevin_Richard_Simon}/.idea/.idea.Kevin/.idea/encodings.xml (100%) rename {Kevin => Kevin_Richard_Simon}/.idea/.idea.Kevin/.idea/indexLayout.xml (100%) rename {Kevin => Kevin_Richard_Simon}/.idea/.idea.Kevin/.idea/vcs.xml (100%) create mode 100644 Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/.gitignore create mode 100644 Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/encodings.xml create mode 100644 Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/vcs.xml rename Kevin/Kevin.sln => Kevin_Richard_Simon/Kevin_Richard_Simon.sln (79%) rename Kevin/Kevin/Kevin.vbproj => Kevin_Richard_Simon/Kevin_Richard_Simon/Kevin_Richard_Simon.vbproj (100%) rename {Kevin/Kevin => Kevin_Richard_Simon/Kevin_Richard_Simon}/Program.vb (51%) diff --git a/Kevin/.idea/.idea.Kevin/.idea/.gitignore b/Kevin_Richard_Simon/.idea/.idea.Kevin/.idea/.gitignore similarity index 100% rename from Kevin/.idea/.idea.Kevin/.idea/.gitignore rename to Kevin_Richard_Simon/.idea/.idea.Kevin/.idea/.gitignore diff --git a/Kevin/.idea/.idea.Kevin/.idea/encodings.xml b/Kevin_Richard_Simon/.idea/.idea.Kevin/.idea/encodings.xml similarity index 100% rename from Kevin/.idea/.idea.Kevin/.idea/encodings.xml rename to Kevin_Richard_Simon/.idea/.idea.Kevin/.idea/encodings.xml diff --git a/Kevin/.idea/.idea.Kevin/.idea/indexLayout.xml b/Kevin_Richard_Simon/.idea/.idea.Kevin/.idea/indexLayout.xml similarity index 100% rename from Kevin/.idea/.idea.Kevin/.idea/indexLayout.xml rename to Kevin_Richard_Simon/.idea/.idea.Kevin/.idea/indexLayout.xml diff --git a/Kevin/.idea/.idea.Kevin/.idea/vcs.xml b/Kevin_Richard_Simon/.idea/.idea.Kevin/.idea/vcs.xml similarity index 100% rename from Kevin/.idea/.idea.Kevin/.idea/vcs.xml rename to Kevin_Richard_Simon/.idea/.idea.Kevin/.idea/vcs.xml diff --git a/Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/.gitignore b/Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/.gitignore new file mode 100644 index 0000000..1fecdb9 --- /dev/null +++ b/Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/projectSettingsUpdater.xml +/.idea.Kevin_Richard_Simon.iml +/contentModel.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/encodings.xml b/Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/vcs.xml b/Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/vcs.xml new file mode 100644 index 0000000..d843f34 --- /dev/null +++ b/Kevin_Richard_Simon/.idea/.idea.Kevin_Richard_Simon/.idea/vcs.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Kevin/Kevin.sln b/Kevin_Richard_Simon/Kevin_Richard_Simon.sln similarity index 79% rename from Kevin/Kevin.sln rename to Kevin_Richard_Simon/Kevin_Richard_Simon.sln index a26e4b3..4c0b048 100644 --- a/Kevin/Kevin.sln +++ b/Kevin_Richard_Simon/Kevin_Richard_Simon.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Kevin", "Kevin\Kevin.vbproj", "{85526CE4-E046-4FF2-8ED6-8DF98D0A8F28}" +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Kevin_Richard_Simon", "Kevin_Richard_Simon\Kevin_Richard_Simon.vbproj", "{85526CE4-E046-4FF2-8ED6-8DF98D0A8F28}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Kevin/Kevin/Kevin.vbproj b/Kevin_Richard_Simon/Kevin_Richard_Simon/Kevin_Richard_Simon.vbproj similarity index 100% rename from Kevin/Kevin/Kevin.vbproj rename to Kevin_Richard_Simon/Kevin_Richard_Simon/Kevin_Richard_Simon.vbproj diff --git a/Kevin/Kevin/Program.vb b/Kevin_Richard_Simon/Kevin_Richard_Simon/Program.vb similarity index 51% rename from Kevin/Kevin/Program.vb rename to Kevin_Richard_Simon/Kevin_Richard_Simon/Program.vb index 16d8ca5..0f83cbc 100644 --- a/Kevin/Kevin/Program.vb +++ b/Kevin_Richard_Simon/Kevin_Richard_Simon/Program.vb @@ -5,57 +5,57 @@ Module Program Sub Main(args As String()) Console.WriteLine("Hello World!") - Dim empty = ListOf (Of String).Nil - Console.WriteLine("is Nil:" + empty.IsNil().ToString()) - Dim list1 = ListOf (Of String).Cons("World", empty) - Console.WriteLine("is Nil:" + list1.IsNil().ToString()) - Console.WriteLine(list1.Head) - Dim list2 = ListOf (Of String).Cons("Hello", list1) - Console.WriteLine("is Nil:" + list2.IsNil().ToString()) - - Console.WriteLine(list2.ToString()) - - Dim myList as ListOf(Of Integer) = ListOf (Of Integer).Cons(1, ListOf (Of Integer).Cons(2, - ListOf (Of Integer).Cons( - 3, - ListOf _ - ( _ - Of _ - Integer - ) _ - . - Nil))) - Dim total1 = sum(myList) - Console.WriteLine("Sum of list: " + total1.ToString()) - - Dim total2 = Times(myList) - Console.WriteLine("Times of list: " + total2.ToString()) - - Dim Add = Function(x, y) x + y - - Dim AddTen = foldr (Of Integer, Integer)(Add, 10, myList) - Console.WriteLine("Foldr sum of list: " + AddTen.ToString()) - - Dim values As Integer() = {1, 2, 3, 4, 5} - Dim myList2 As ListOf(Of Integer) = BuildList(values) - Console.WriteLine("Built List: " + sum(myList2).ToString()) - - Dim bools1 = {False, False, False} - Dim myListBools1 = BuildList(bools1) - Console.WriteLine("Built List: " + AnyTrue(myListBools1).ToString()) - - Dim bools2 = {True, True, True} - Dim myListBools2 = BuildList(bools2) - Console.WriteLine("Built List: " + AllTrue(myListBools2).ToString()) - - Dim values232 As Integer() = {1, 2, 3, 4, 5} - Dim myList232 As ListOf(Of Integer) = CopyList(BuildList(values232)) - Console.WriteLine("Built List: " + sum(myList232).ToString()) - - Dim values2321 As Integer() = {1, 2} - Dim values2322 As Integer() = {1, 2} - Dim myList2323 As ListOf(Of Integer) = Append(BuildList(values2321), BuildList(values2322)) - Console.WriteLine("Built List: " + sum(myList2323).ToString()) + Dim emptyStringList = ListOf (Of String).Nil + Console.WriteLine("is Nil:" + emptyStringList.IsNil().ToString()) + Dim worldList = ListOf (Of String).Cons("World", emptyStringList) + Console.WriteLine("is Nil:" + worldList.IsNil().ToString()) + Console.WriteLine(worldList.Head) + Dim helloWorldList = ListOf (Of String).Cons("Hello", worldList) + Console.WriteLine("is Nil:" + helloWorldList.IsNil().ToString()) + + Console.WriteLine(helloWorldList.ToString()) + + Dim integerList as ListOf(Of Integer) = ListOf (Of Integer).Cons(1, ListOf (Of Integer).Cons(2, + ListOf (Of Integer) _ + .Cons( + 3, + ListOf _ + ( _ + Of _ + Integer + ) _ + .Nil))) + Dim sumOfIntegerList = sum(integerList) + Console.WriteLine("Sum of list: " + sumOfIntegerList.ToString()) + + Dim productOfIntegerList = Times(integerList) + Console.WriteLine("Times of list: " + productOfIntegerList.ToString()) + + Dim addFunction = Function(x, y) x + y + + Dim foldrSumWithTen = foldr (Of Integer, Integer)(addFunction, 10, integerList) + Console.WriteLine("Foldr sum of list: " + foldrSumWithTen.ToString()) + + Dim numbersToBuild As Integer() = {1, 2, 3, 4, 5} + Dim builtIntegerList As ListOf(Of Integer) = BuildList(numbersToBuild) + Console.WriteLine("Built List: " + sum(builtIntegerList).ToString()) + + Dim boolArrayAllFalse = {False, False, False} + Dim allFalseList = BuildList(boolArrayAllFalse) + Console.WriteLine("Built List: " + AnyTrue(allFalseList).ToString()) + + Dim boolArrayAllTrue = {True, True, True} + Dim allTrueList = BuildList(boolArrayAllTrue) + Console.WriteLine("Built List: " + AllTrue(allTrueList).ToString()) + + Dim numbersToCopy As Integer() = {1, 2, 3, 4, 5} + Dim copiedIntegerList As ListOf(Of Integer) = CopyList(BuildList(numbersToCopy)) + Console.WriteLine("Built List: " + sum(copiedIntegerList).ToString()) + + Dim firstAppendArray As Integer() = {1, 2} + Dim secondAppendArray As Integer() = {1, 2} + Dim appendedIntegerList As ListOf(Of Integer) = Append(BuildList(firstAppendArray), BuildList(secondAppendArray)) + Console.WriteLine("Built List: " + sum(appendedIntegerList).ToString()) End Sub Function AnyTrue(list As ListOf(Of Boolean)) As Boolean @@ -74,7 +74,7 @@ Module Program End Function Function CopyList (Of T)(list As ListOf(Of T)) As ListOf(Of T) - return Foldr(Function(x, y) ListOf (Of T).Cons(x, y), ListOf (Of T).Nil, list) + return Foldr(AddressOf ListOf (Of T).Cons, ListOf (Of T).Nil, list) End Function Function Append (Of T)(list1 As ListOf(Of T), list2 As ListOf(Of T)) As ListOf(Of T)