FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Working with lists

Description
A series of examples showing some of Mosel's list handling functionality:
  • definining lists and initializing lists with values (listinit.mos)
  • enumeration and reversal of lists (listenum.mos)
  • operators on lists (listops.mos)
  • enumeration and reversal of lists (listenum.mos)
  • list access functions (merging two ordered lists, listmerge.mos)
Further explanation of this example: 'Mosel User Guide', Section 8.4 Initializing lists, Section 8.5 Working with lists


Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
listenum.mos[download]
listinit.mos[download]
listmerge.mos[download]
listops.mos[download]

Data Files





listops.mos

(!******************************************************
   Mosel User Guide Example Problems
   ================================= 

   file listops.mos 
   ```````````````` 
   List operations.
 
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Nov. 2006
*******************************************************!)

model "List operations"

 declarations
  L,M: list of integer
 end-declarations
 
 L:= [1,2,3] + [4,5]; writeln("L (1): ", L) 
 L+= [6,7,8]; writeln("L (2): ", L) 
 L-= [1,2,3]; writeln("L (3): ", L) 

 M:= sum(l in L) [l*2]; writeln("M: ", M)
 
 writeln("L and M are different: ", L<>M)
 
end-model

Back to examples browserPrevious exampleNext example