├── .gitignore ├── .idea └── .idea.FSharpVsCSharp │ └── .idea │ ├── encodings.xml │ ├── indexLayout.xml │ ├── projectSettingsUpdater.xml │ ├── vcs.xml │ └── workspace.xml ├── .vs └── FSharpVsCSharp │ ├── DesignTimeBuild │ └── .dtbcache.v2 │ └── v16 │ └── .suo ├── CSharpConsoleApp ├── CSharpConsoleApp.csproj ├── DiscriminatedUnions.cs ├── Equality.cs ├── Expressions.cs ├── HappyPathCoding.cs ├── HappyPathCodingBasics.cs ├── Merging.cs ├── Pipes.cs ├── Program.cs ├── Records.cs └── SingleCaseDiscriminatedUnions.cs ├── FSharpConsoleApp ├── DiscriminatedUnions.fs ├── Equality.fs ├── Expressions.fs ├── FSharpConsoleApp.fsproj ├── HappyPathCoding.fs ├── HappyPathCodingBasics.fs ├── Merging.fs ├── Pipes.fs ├── Program.fs ├── Records.fs └── SingleCaseDiscriminatedUnions.fs ├── FSharpVsCSharp.sln ├── FSharpVsCSharp.sln.DotSettings ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | /packages/ 4 | riderModule.iml 5 | /_ReSharper.Caches/ -------------------------------------------------------------------------------- /.idea/.idea.FSharpVsCSharp/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/.idea.FSharpVsCSharp/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea.FSharpVsCSharp/.idea/projectSettingsUpdater.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/.idea.FSharpVsCSharp/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/.idea.FSharpVsCSharp/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FSharpConsoleApp/FSharpConsoleApp.fsproj 5 | CSharpConsoleApp/CSharpConsoleApp.csproj 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 26 | 27 | 28 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 94 | 95 | 112 | 113 | 114 | 115 | 116 | 117 | 1610113830869 118 | 135 | 136 | 137 | 138 | 140 | 141 | 142 | 143 | 152 | 154 | 155 | 158 | -------------------------------------------------------------------------------- /.vs/FSharpVsCSharp/DesignTimeBuild/.dtbcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ursenzler/FSharpVsCSharp/b1ee84740fb3cc5b32834d5e25e8919e2e8189c5/.vs/FSharpVsCSharp/DesignTimeBuild/.dtbcache.v2 -------------------------------------------------------------------------------- /.vs/FSharpVsCSharp/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ursenzler/FSharpVsCSharp/b1ee84740fb3cc5b32834d5e25e8919e2e8189c5/.vs/FSharpVsCSharp/v16/.suo -------------------------------------------------------------------------------- /CSharpConsoleApp/CSharpConsoleApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /CSharpConsoleApp/DiscriminatedUnions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace CSharpConsoleApp 4 | { 5 | public class DiscriminatedUnions 6 | { 7 | public interface ITemperature { } 8 | 9 | public record Celsius(double Value) : ITemperature; 10 | 11 | public record Fahrenheit(int Value) : ITemperature; 12 | 13 | public bool IsItWarm(ITemperature temperature) 14 | { 15 | return 16 | temperature switch 17 | { 18 | Celsius { Value: > 25.0 } => true, 19 | Fahrenheit { Value: > 77 } => true, 20 | _ => false 21 | }; 22 | } 23 | 24 | public string GetMeasure(ITemperature temperature) 25 | { 26 | return 27 | temperature switch 28 | { 29 | Celsius => "Celsius", 30 | Fahrenheit => "Fahrenheit", 31 | _ => throw new Exception("will never happen, until we add a new variant") 32 | }; 33 | } 34 | 35 | public string AsText(ITemperature temperature) 36 | { 37 | return 38 | temperature switch 39 | { 40 | Celsius c => $"{c.Value}°C", 41 | Fahrenheit f => $"{f.Value}°F", 42 | _ => throw new Exception("will never happen, until we add a new variant") 43 | }; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /CSharpConsoleApp/Equality.cs: -------------------------------------------------------------------------------- 1 | namespace CSharpConsoleApp 2 | { 3 | public class Equality 4 | { 5 | public record Data(string Name, string[] Values); 6 | 7 | public bool Compute() 8 | { 9 | var a = new Data( 10 | "Charles", 11 | new[] {"1", "2"}); 12 | 13 | var b = new Data( 14 | "Charles", 15 | new[] {"1", "2"}); 16 | 17 | return a == b; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /CSharpConsoleApp/Expressions.cs: -------------------------------------------------------------------------------- 1 | namespace CSharpConsoleApp 2 | { 3 | public class Expressions 4 | { 5 | public int Compute(bool b) 6 | { 7 | var result = 17; 8 | if (b) 9 | { 10 | result = 42; 11 | } 12 | 13 | return result; 14 | } 15 | 16 | public int Compute2(bool b) 17 | { 18 | return b ? 42 : 17; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /CSharpConsoleApp/HappyPathCoding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace CSharpConsoleApp 5 | { 6 | public class HappyPathCoding 7 | { 8 | public record Customer(int Id, string? Name); 9 | public record Data(int Id, int Amount); 10 | 11 | private async Task GetCustomer( 12 | int customerId) 13 | { 14 | return customerId == 42 ? 15 | new Customer(customerId, "Charles") : 16 | default; 17 | } 18 | 19 | private async Task GetData( 20 | int dataId) 21 | { 22 | return new(dataId, 100); 23 | } 24 | 25 | private string? GetNameOfCustomer( 26 | Customer customer) 27 | { 28 | return customer.Name; 29 | } 30 | 31 | public async Task<(string Name, int Amount)?> 32 | GetCustomerNameAndAmount( 33 | int customerId, int dataId) 34 | { 35 | var customer = await GetCustomer(customerId) 36 | .ConfigureAwait(false); 37 | 38 | if (customer == null) 39 | { 40 | return null; 41 | } 42 | 43 | var data = await GetData(dataId) 44 | .ConfigureAwait(false); 45 | 46 | if (data == null) 47 | { 48 | return null; 49 | } 50 | 51 | var name = GetNameOfCustomer(customer); 52 | 53 | if (name == null) 54 | { 55 | return null; 56 | } 57 | 58 | return (name, data.Amount); 59 | } 60 | 61 | public async Task Compute() 62 | { 63 | var result = await GetCustomerNameAndAmount(42, 17); 64 | if (result != null) 65 | { 66 | Console.WriteLine($"customer = {result.Value.Name}, amount = {result.Value.Amount}"); 67 | } 68 | else 69 | { 70 | Console.WriteLine("error"); 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /CSharpConsoleApp/HappyPathCodingBasics.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace CSharpConsoleApp 4 | { 5 | public class HappyPathCodingBasics 6 | { 7 | public async Task Asynchronous(int id) 8 | { 9 | return id + 1; 10 | } 11 | 12 | public async Task Caller(int id) 13 | { 14 | var r = await Asynchronous(id); 15 | return r; 16 | } 17 | 18 | public int? Optional(int id) 19 | { 20 | var r = 21 | id % 2 == 0 ? 22 | (int?)id : 23 | null; 24 | return r; 25 | } 26 | 27 | public (int?, string?) Result(int id) 28 | { 29 | var r = id % 2 == 0 ? 30 | ((int?)id, null) : 31 | (default(int?), "odd number"); 32 | return r; 33 | } 34 | 35 | public async Task<(int?, string?)> AsyncResult( 36 | int id) 37 | { 38 | var async = 39 | await Asynchronous(id).ConfigureAwait(false); 40 | 41 | var optional = Optional(id); 42 | if (optional == null) 43 | { 44 | return (null, "no value"); 45 | } 46 | 47 | var result = Result(id); 48 | if (result.Item1 == null) 49 | { 50 | return result; 51 | } 52 | 53 | return 54 | ( 55 | async + optional.Value + result.Item1.Value, 56 | null 57 | ); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /CSharpConsoleApp/Merging.cs: -------------------------------------------------------------------------------- 1 | namespace CSharpConsoleApp 2 | { 3 | public class Merging 4 | { 5 | public int Compute( 6 | string s, 7 | int i) 8 | { 9 | return s.Length + i; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /CSharpConsoleApp/Pipes.cs: -------------------------------------------------------------------------------- 1 | namespace CSharpConsoleApp 2 | { 3 | public class Pipes 4 | { 5 | public record Customer(string Name); 6 | 7 | public Customer GetCustomer(int id) 8 | => new Customer("Charles"); 9 | 10 | public string GetNameOfCustomer(Customer customer) 11 | => customer.Name; 12 | 13 | public string GetNameOfCustomerFromId(int id) 14 | { 15 | return GetNameOfCustomer( 16 | GetCustomer( 17 | id)); 18 | } 19 | 20 | public string GetNameOfCustomerFromIdVariant(int id) 21 | { 22 | var customer = GetCustomer(id); 23 | return GetNameOfCustomer(customer); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /CSharpConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace CSharpConsoleApp 5 | { 6 | public static class Program 7 | { 8 | public static async Task Main(string[] args) 9 | { 10 | new Pipes().GetNameOfCustomerFromId(42); 11 | new Pipes().GetNameOfCustomerFromIdVariant(42); 12 | new Records().Instantiate(); 13 | var m = new DiscriminatedUnions().GetMeasure(new DiscriminatedUnions.Celsius(3.0)); 14 | var b = new DiscriminatedUnions().IsItWarm(new DiscriminatedUnions.Celsius(3.0)); 15 | await new HappyPathCoding().Compute(); 16 | 17 | var result = new Equality().Compute(); 18 | Console.WriteLine(result); 19 | 20 | var t = await new HappyPathCodingBasics().AsyncResult(17); 21 | var r = await new HappyPathCodingBasics().Caller(17); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /CSharpConsoleApp/Records.cs: -------------------------------------------------------------------------------- 1 | namespace CSharpConsoleApp 2 | { 3 | public class Records 4 | { 5 | public record A(string Name, int Id); 6 | 7 | public record B 8 | { 9 | public string Name { get; init; } 10 | public int Id { get; init; } 11 | } 12 | 13 | public void Instantiate() 14 | { 15 | var a = new A("Hugo", 42); 16 | var b = new B { Name = "Hugo2", Id = 42 }; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /CSharpConsoleApp/SingleCaseDiscriminatedUnions.cs: -------------------------------------------------------------------------------- 1 | namespace CSharpConsoleApp 2 | { 3 | public class SingleCaseDiscriminatedUnions 4 | { 5 | public class Lazy 6 | { 7 | public bool Compute() 8 | { 9 | var customerId = 17; 10 | var itemId = 17; 11 | 12 | var same = customerId == itemId; // no compile error 13 | 14 | return same; 15 | } 16 | } 17 | 18 | // public class WithRecords 19 | // { 20 | // public record CustomerId(int Value); 21 | // public record ItemId(int Value); 22 | // 23 | // public bool Compute() 24 | // { 25 | // var customerId = new CustomerId(17); 26 | // var itemId = new ItemId(17); 27 | // 28 | // var same = customerId == itemId; // compile error 29 | // 30 | // return same; 31 | // } 32 | // } 33 | } 34 | } -------------------------------------------------------------------------------- /FSharpConsoleApp/DiscriminatedUnions.fs: -------------------------------------------------------------------------------- 1 | module FSharpConsoleApp.DiscriminatedUnions 2 | 3 | type Temperature = 4 | | Celsius of float 5 | | Fahrenheit of int 6 | 7 | let isItWarm temperature = 8 | match temperature with 9 | | Celsius c when c > 25.0 -> true 10 | | Fahrenheit f when f > 77 -> true 11 | | _ -> false 12 | 13 | let getMeasure temperature = 14 | match temperature with 15 | | Celsius _ -> "Celsius" 16 | | Fahrenheit _ -> "Fahrenheit" 17 | 18 | let asText temperature = 19 | match temperature with 20 | | Celsius c -> $"{c}°C" 21 | | Fahrenheit f -> $"{f}°F" 22 | 23 | 24 | let (|IsWarm|IsCold|) temperature = 25 | match temperature with 26 | | Celsius c when c > 25.0 -> IsWarm 27 | | Celsius _ -> IsCold 28 | | Fahrenheit f when f > 77 -> IsCold 29 | | Fahrenheit _ -> IsCold 30 | 31 | let isItWarm' temperature = 32 | match temperature with 33 | | IsWarm -> true 34 | | IsCold -> false 35 | 36 | 37 | module Bob = 38 | 39 | open System.Text.RegularExpressions 40 | 41 | let response (input: string): string = 42 | let (|Silence|_|) x = if x = "" then Some() else None 43 | let (|Asking|_|) (x: string) = if x.EndsWith("?") then Some() else None 44 | let (|Shouting|_|) (x: string) = if x.ToUpper() = x then Some() else None 45 | let (|HasText|_|) x = if Regex.IsMatch(x, "[a-zA-Z]") then Some() else None 46 | 47 | match input.Trim() with 48 | | Shouting & Asking & HasText -> "Calm down, I know what I'm doing!" 49 | | Shouting & HasText -> "Whoa, chill out!" 50 | | Silence -> "Fine. Be that way!" 51 | | Asking -> "Sure." 52 | | _ -> "Whatever." -------------------------------------------------------------------------------- /FSharpConsoleApp/Equality.fs: -------------------------------------------------------------------------------- 1 | module FSharpConsoleApp.Equality 2 | 3 | type Data = { Name : string ; Values : string[] } 4 | 5 | let compute () = 6 | let a = 7 | { 8 | Name = "Charles" 9 | Values = [| "1" ; "2" |] 10 | } 11 | 12 | let b = 13 | { 14 | Name = "Charles" 15 | Values = [| "1" ; "2" |] 16 | } 17 | 18 | a = b -------------------------------------------------------------------------------- /FSharpConsoleApp/Expressions.fs: -------------------------------------------------------------------------------- 1 | module FSharpConsoleApp.Expressions 2 | 3 | let compute b = 4 | let result = 5 | if b then 42 6 | else 17 7 | result 8 | 9 | 10 | let compute' () = 11 | () 12 | -------------------------------------------------------------------------------- /FSharpConsoleApp/FSharpConsoleApp.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /FSharpConsoleApp/HappyPathCoding.fs: -------------------------------------------------------------------------------- 1 | module FSharpConsoleApp.HappyPathCoding 2 | 3 | open FsToolkit.ErrorHandling 4 | 5 | type Customer = 6 | { 7 | Id : int 8 | Name : string option 9 | } 10 | 11 | type Data = 12 | { 13 | Id : int 14 | Amount : int 15 | } 16 | 17 | let loadCustomer customerId = 18 | asyncResult { 19 | do! customerId = 42 20 | |> Result.requireTrue 21 | "customer not found" 22 | return 23 | { 24 | Customer.Id = customerId 25 | Name = Some "Charles" 26 | } 27 | } 28 | 29 | let loadCustomer' customerId = 30 | asyncResult { 31 | return! Error "customer not found" 32 | } 33 | 34 | let loadCustomerCaller () = 35 | async { 36 | let! customerResult = loadCustomer 42 37 | 38 | return 39 | match customerResult with 40 | | Ok customer -> "we have a customer" 41 | | Error error -> "we have no customer" 42 | } 43 | 44 | let loadData dataId = 45 | asyncResult { 46 | return 47 | { 48 | Data.Id = dataId 49 | Amount = 100 50 | } 51 | } 52 | 53 | let getNameOfCustomer customer = 54 | option { 55 | let! name = customer.Name 56 | return name 57 | } 58 | 59 | let getCustomerNameAndAmount customerId dataId = 60 | asyncResult { 61 | let! customer = loadCustomer customerId 62 | let! data = loadData dataId 63 | 64 | let! name = 65 | customer 66 | |> getNameOfCustomer 67 | |> Result.requireSome 68 | "customer has no name" 69 | 70 | return name, data.Amount 71 | } 72 | 73 | let compute () = 74 | async { 75 | let! result = getCustomerNameAndAmount 42 17 76 | match result with 77 | | Ok (name, amount) -> printf $"customer = {name}, amount = {amount}" 78 | | Error error -> printf $"error is {error}" 79 | } -------------------------------------------------------------------------------- /FSharpConsoleApp/HappyPathCodingBasics.fs: -------------------------------------------------------------------------------- 1 | module FSharpConsoleApp.HappyPathCodingBasics 2 | 3 | open FsToolkit.ErrorHandling 4 | 5 | let asynchronous id = 6 | async { 7 | return id + 1 8 | } 9 | 10 | let caller id = 11 | async { 12 | let! r = asynchronous id 13 | return r 14 | } 15 | 16 | let optional id = if id % 2 = 0 then Some id else None 17 | 18 | let optionalPlus17 id = 19 | option { 20 | let! r = optional id 21 | return r + 17 22 | } 23 | 24 | let getResult id = 25 | if id % 2 = 0 then Ok id 26 | else Error "odd number" 27 | 28 | let resultPlus17 id = 29 | result { 30 | let! r = getResult id 31 | return r + 17 32 | } 33 | 34 | let callResult () = 35 | let r = getResult 42 36 | match r with 37 | | Ok value -> "value" 38 | | Error error -> "error" 39 | -------------------------------------------------------------------------------- /FSharpConsoleApp/Merging.fs: -------------------------------------------------------------------------------- 1 | module FSharpConsoleApp.Merging 2 | 3 | let compute 4 | (s : string) 5 | i = 6 | s.Length + i 7 | -------------------------------------------------------------------------------- /FSharpConsoleApp/Pipes.fs: -------------------------------------------------------------------------------- 1 | module FSharpConsoleApp.Pipes 2 | 3 | type Customer = { Name : string ; Id : int } 4 | 5 | let loadCustomer id = { Name = "Charles" ; Id = id } 6 | 7 | let getNameOfCustomer customer = customer.Name 8 | 9 | let getNameOfCustomerFromId id = 10 | id 11 | |> loadCustomer 12 | |> getNameOfCustomer 13 | 14 | let getNameOfCustomerFromId' = loadCustomer >> getNameOfCustomer 15 | -------------------------------------------------------------------------------- /FSharpConsoleApp/Program.fs: -------------------------------------------------------------------------------- 1 | open FSharpConsoleApp 2 | 3 | [] 4 | let main argv = 5 | Equality.compute() |> printf "%b" 6 | 0 -------------------------------------------------------------------------------- /FSharpConsoleApp/Records.fs: -------------------------------------------------------------------------------- 1 | module FSharpConsoleApp.Records 2 | 3 | type A = 4 | { 5 | Name : string 6 | Id : int 7 | } 8 | 9 | type A' = { Name : string ; Id : int } 10 | 11 | let a = 12 | { 13 | Name = "Name" 14 | Id = 42 15 | } -------------------------------------------------------------------------------- /FSharpConsoleApp/SingleCaseDiscriminatedUnions.fs: -------------------------------------------------------------------------------- 1 | module FSharpConsoleApp.SingleCaseDiscriminatedUnions 2 | 3 | //type CustomerId = CustomerId of int 4 | //type ItemId = ItemId of int 5 | // 6 | //let compute () = 7 | // let customerId = CustomerId 17 8 | // let itemId = ItemId 17 9 | // 10 | // let same = customerId = itemId // compile error 11 | // 12 | // same 13 | 14 | 15 | -------------------------------------------------------------------------------- /FSharpVsCSharp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpConsoleApp", "FSharpConsoleApp\FSharpConsoleApp.fsproj", "{ABE937E0-30FA-4699-82CF-8F3476B5A2D0}" 4 | EndProject 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpConsoleApp", "CSharpConsoleApp\CSharpConsoleApp.csproj", "{2713FD58-A70D-4160-BA4A-970B5C9EA5CD}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Any CPU = Debug|Any CPU 10 | Release|Any CPU = Release|Any CPU 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {ABE937E0-30FA-4699-82CF-8F3476B5A2D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 14 | {ABE937E0-30FA-4699-82CF-8F3476B5A2D0}.Debug|Any CPU.Build.0 = Debug|Any CPU 15 | {ABE937E0-30FA-4699-82CF-8F3476B5A2D0}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 | {ABE937E0-30FA-4699-82CF-8F3476B5A2D0}.Release|Any CPU.Build.0 = Release|Any CPU 17 | {2713FD58-A70D-4160-BA4A-970B5C9EA5CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 18 | {2713FD58-A70D-4160-BA4A-970B5C9EA5CD}.Debug|Any CPU.Build.0 = Debug|Any CPU 19 | {2713FD58-A70D-4160-BA4A-970B5C9EA5CD}.Release|Any CPU.ActiveCfg = Release|Any CPU 20 | {2713FD58-A70D-4160-BA4A-970B5C9EA5CD}.Release|Any CPU.Build.0 = Release|Any CPU 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /FSharpVsCSharp.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | HINT 3 | HINT -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FSharpVsCSharp 2 | Some samples to compare C# and F# 3 | --------------------------------------------------------------------------------