swirl
Guide to OmniMark 8   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 ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:25:49 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.