Skip to content

Instantly share code, notes, and snippets.

@jamescurran
Created November 3, 2011 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamescurran/1336856 to your computer and use it in GitHub Desktop.
Save jamescurran/1336856 to your computer and use it in GitHub Desktop.
Translating "((if (> b 0) + -) a b))" from lisp into C#
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment