15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

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.

µML, a very simple Functional Programming Language<br />

Plan: Only consider the bare-bones core of a language (we only interested in principles)<br />

We will call this language µML (micro ML)<br />

no types: all values have type int, use 0 for false all other numbers for true.<br />

Definition 472 microML µML is a simple functional programming languages with<br />

functional variables (declare and bind with val 〈〈name〉〉 = 〈〈exp〉〉)<br />

named functions (declare with fun 〈〈name〉〉 (〈〈args〉〉) = 〈〈exp〉〉)<br />

arithmetic/logic/control expressions with variables/functions referenced by name<br />

(no statements)<br />

c○: Michael Kohlhase 306<br />

To make the concepts involved concrete, we look at a concrete example: the procedure on the<br />

next slide computes 10 2 ..<br />

Example: A µML Program for 10 Squared<br />

Example 473 (Computing Twelve Factorial)<br />

let (* begin declarations *)<br />

fun exp (x,n) = (* function declaration *)<br />

if n

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

Saved successfully!

Ooh no, something went wrong!