Professional Documents
Culture Documents
Chapter 01
Chapter 01
Programming Languages
• A stack-oriented language
• Postscript language used by printers is
similar
• Could be called imperative, but has little in
common with most imperative languages
fact n =
foldl (*) 1 [1..n]
OR
fact n =
foldl (\t m->t*m) 1 [1..n]
class Fubar {
public static void main (String[] args) {
// whole program here!
}
}
• The above code prints out the prime numbers less than 100, which is
equivalent to:
f (a,b,c) { main() {
b/a<=1 ? f(a,b+1,c) f (100, 0, 0);
: !(b%a) ? f(a,b+1,0) }
: b%a==b/a && !c ? (printf("%d\t",b/a),f(a,b+1,0)) Output:
: b%a>1 && b%a<b/a ? f(a,1+b,c+!(b/a%(b%a))) 2 3 5 7 11 13 17
: b<a*a ? f(a,b+1,c) 19 23 29 31 37 41
: 0; 43 47 53 59 61 67
} 71 73 79 83 89 97
Output: map 36 42