home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / program / language / bob / !ArmBob / progs / Apply < prev    next >
Encoding:
Text File  |  1994-12-12  |  349 b   |  21 lines

  1. /* Example Apply */
  2. /* functions and vectors can be arguments or components */
  3.  
  4. apply(pair)
  5. {
  6.  return pair[function](pair[argument]);
  7. }
  8.  
  9. f(x)               // f takes functions as arguments
  10. { return x(0); }  
  11.  
  12. g(x)
  13. { return (100+x); }
  14.  
  15. main()
  16. {
  17.  enum { function, argument };
  18.  x = vector { f; g; };  // a vector of functions
  19.  print(apply(x),"\n");
  20. }
  21.