CoCoA:Call

From ApCoCoAWiki
Revision as of 10:02, 24 October 2007 by XMLBot (talk | contribs) (pushing XML rev. 1.46, again)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Call

apply a function to given arguments

Description

This function applies the function F to the arguments X_1,...X_n.

Example

  -- The following function MyMax takes a function LessThan as parameter,
  -- and returns the maximum of X and Y w.r.t. the ordering defined by the
  -- function LessThan.

  Define MyMax(LessThan,X,Y)
    If Call(LessThan,X,Y) Then Return Y Else Return X EndIf
  EndDefine;

  -- Let's use MyMax by giving two different orderings.

  Define LT_Standard(X,Y)
    Return X < Y;
  EndDefine;
  Define LT_First(X,Y)
    Return TRUE;
  EndDefine;

  MyMax(Function(<quotes>LT_Standard</quotes>),3,5);
5
-------------------------------
  MyMax(Function(<quotes>LT_First</quotes>),5,3);
3
-------------------------------
  MyMax(Function(<quotes>LT_First</quotes>),3,5);
5
-------------------------------
  MyMax(Function(<quotes>LT_First</quotes>),5,3);
3
-------------------------------

Syntax

Call(F:FUNCTION,X_1,...,X_n):OBJECT

where X_1,...,X_n are the arguments for the function F.

Function

   <type>function</type>