Created
November 3, 2011 15:57
-
-
Save jamescurran/1336856 to your computer and use it in GitHub Desktop.
Translating "((if (> b 0) + -) a b))" from lisp into C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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