Skip to content

Instantly share code, notes, and snippets.

@mohanrajendran
Last active August 29, 2015 14:03
Show Gist options
  • Save mohanrajendran/3f8e28608fa308f7d365 to your computer and use it in GitHub Desktop.
Save mohanrajendran/3f8e28608fa308f7d365 to your computer and use it in GitHub Desktop.
SICP Exercise 1.4
(define (a-plus-abs-b a b)
  ((if (> b 0) + -) a b))

When the if function is evaluated, based on the condition, the operator + or - is applied on the operands a and b. If b > 0, + operator is used, evaluating to a+b. Otherwise, - operator is issued which yields a-b. Ultimately, we evaluate a+|b|.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment