swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
Prerequisite Concepts     Related Topics  

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
 
  Related Topics
 
 

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

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:35:14 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.