10.07.2015 Views

An Introduction to Functional Programming Through Lambda Calculus

An Introduction to Functional Programming Through Lambda Calculus

An Introduction to Functional Programming Through Lambda Calculus

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

- 189 -10.4. Logictis the primitive for TRUE and:nilis the primitive for FALSE.not and orare the primitives for the logical negation, conjunction and disjunction functions respectively. These may be used <strong>to</strong>construct simple logical expressions as forms, for example:(not t) ->nil(and t nil) ->nil(or (and t nil) (not nil)) ->tIn LISP, unlike most programming languages, and and or may have more than two arguments. For and, the finalvalue is the conjunction of all the arguments, for example:(and t nil t) ->nilFor or, the final value is the disjunction of all the arguments, for example:(or t nil t) ->t10.5. Arithmetic and numeric comparison+ - * /are the primitives for the addition, subtraction, multiplication and division functions. These may be used with numbers<strong>to</strong> construct simple arithmetic expressions, for example:(+ 40 2) ->42(- 46 4) ->42(* 6 (+ 3 4)) ->42(/ (+ 153 15) (- 7 3)) ->42As with and and or, these functions may have more than two arguments, so + returns the sum, - the difference, *the product and / the overall quotient, for example:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!