Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. // function
  2. int square( int n ) {
  3. return n * n;
  4. }
  5.  
  6. // procedure
  7. void display( int n ) {
  8. printf( "The value is %d", n );
  9. }
  10.  
  11. f(x)=(1+x)
  12. g(x)=.5*(2+x/2)
  13.  
  14. -function
  15. int sample(int value)
  16. {
  17. return value;
  18. }
  19.  
  20. --procedure
  21. void display(int value)
  22. {
  23. echo("The value is ", value );
  24. }
  25.  
  26. // The following is pseudo code:
  27. g(x) = {
  28. if (morning()) {
  29. g = 2 * x;
  30. }
  31. else {
  32. g = x;
  33. }
  34. return g;
  35. }
  36.  
  37. // We can immediately translate this definition into a recursive procedure
  38. // for computing Fibonacci numbers:
  39.  
  40. (define (fib n)
  41. (cond ((= n 0) 0)
  42. ((= n 1) 1)
  43. (else (+ (fib (- n 1))
  44. (fib (- n 2))))))
  45.  
  46. make-pies (fruit, milk, flower, eggs, sugar, heat) = {
  47. return (heat (add fruit (mix eggs flower milk)))
  48. }
  49.  
  50. A function is to a machine
  51. as a procedure is to a recipe
  52. as attributes are to ingredients
  53. as output is to product
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement