public
Created

Translating "((if (> b 0) + -) a b))" from lisp into C#

  • Download Gist
gistfile1.cs
C#
1 2 3 4 5 6 7
static readonly Func<int, int, int> add = (int x, int y) => x + y;
static readonly Func<int, int, int> subtract = (int x, int y) => x - y;
 
public static int a_plus_abs_b(int a, int b)
{
return ((b > 0) ? add : subtract)(a, b);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.