swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
Prerequisite Concepts     Related Syntax  

Functions: infix

Infix functions are functions that work like operators. That is, the name of the function goes between its two arguments, just as the + symbol goes between the two values to be added. In fact, an operator and an infix function are really two different names for the same thing. You can create an operator, therefore, by defining an infix function.

Here is an example of an infix function that calculates the distance between two points. It uses the symbol ">>>" to represent the concept of distance. The points are represented by records.

  import "omfloat.xmd" unprefixed

  declare record point
   field float x
   field float y

  define float infix-function
   value point a
   >>>
   value point b
   as
     return sqrt(((a:x - b:x) ** 2) + ((a:y - b:y) ** 2))

  process
     local point Ghent
     local point Aix

     set Ghent:x to 137.5
     set Ghent:y to 83.2

     set Aix:x to 219.7
     set Aix:y to 345.9

     output "d" % Ghent >>> Aix

Prerequisite Concepts
     Functions
 
  Related Syntax
   define infix-function
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACYLIBRARIES ] [ ERRORS ]

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:44:36 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.