Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // function
- int square( int n ) {
- return n * n;
- }
- // procedure
- void display( int n ) {
- printf( "The value is %d", n );
- }
- f(x)=(1+x)
- g(x)=.5*(2+x/2)
- -function
- int sample(int value)
- {
- return value;
- }
- --procedure
- void display(int value)
- {
- echo("The value is ", value );
- }
- // The following is pseudo code:
- g(x) = {
- if (morning()) {
- g = 2 * x;
- }
- else {
- g = x;
- }
- return g;
- }
- // We can immediately translate this definition into a recursive procedure
- // for computing Fibonacci numbers:
- (define (fib n)
- (cond ((= n 0) 0)
- ((= n 1) 1)
- (else (+ (fib (- n 1))
- (fib (- n 2))))))
- make-pies (fruit, milk, flower, eggs, sugar, heat) = {
- return (heat (add fruit (mix eggs flower milk)))
- }
- A function is to a machine
- as a procedure is to a recipe
- as attributes are to ingredients
- as output is to product
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement