CoCoA:Call

From ApCoCoAWiki

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>