File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -666,8 +666,7 @@ sum (x:xs) = x + sum xs
666666Is also equivalent in C#:
667667
668668``` csharp
669- public static int Sum (IEnumerable < int > l ) => l switch
670- {
669+ public static int Sum (IEnumerable < int > l ) => l switch {
671670 [] => 0 ,
672671 [var x , .. var xs ] => x + Sum (xs ),
673672};
@@ -700,8 +699,7 @@ evaluate (Add a b) = evaluate a + evaluate b
700699Since `Expression ` is closed in Haskell we will have no problems detected by the compiler , but C # needs an extra line :
701700
702701```csharp
703- public static int Evaluate (Expression e ) => e switch
704- {
702+ public static int Evaluate (Expression e ) => e switch {
705703 Const c => c .Value ,
706704 Add (var l , var r ) => Evaluate (l ) + Evaluate (r ),
707705 _ => throw new ArgumentException (" Unknown expression" )
You can’t perform that action at this time.
0 commit comments