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





listmerge.mos

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

   file listmerge.mos 
   `````````````````` 
   Merging two ordered lists into one ordered list.
 
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Aug. 2006
*******************************************************!)

model "Merging lists"

 declarations
  K,L,M: list of integer
 end-declarations
 
 K:= [1,4,5,8,9,10,13]
 L:= [-1,0,4,6,7,8,9,9,11,11] 

 writeln(K,L)
 
 forall(k in K) do
  while (L<>[] and k >= getfirst(L))  M += splithead(L,1)
  M+= [k]
 end-do  
 
 writeln(M)

end-model

Back to examples browserPrevious exampleNext example