| (!******************************************************
   Mosel User Guide Example Problems
   ================================= 
   file prime.mos 
   ``````````````
   Working with sets.
 
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, 2001
*******************************************************!)
model Prime 
 parameters
  LIMIT=100                     ! Search for prime numbers in 2..LIMIT
 end-parameters
 declarations
  SNumbers: set of integer      ! Set of numbers to be checked
  SPrime: set of integer        ! Set of prime numbers
 end-declarations
 SNumbers:={2..LIMIT} 
 
 writeln("Prime numbers between 2 and ", LIMIT, ":")
 n:=2
 repeat
   while (not(n in SNumbers)) n+=1
   SPrime += {n}                ! n is a prime number
   i:=n
   while (i<=LIMIT) do          ! Remove n and all its multiples
     SNumbers-= {i}
     i+=n
   end-do
 until SNumbers={}    
 
 writeln(SPrime)
 writeln(" (", getsize(SPrime), " prime numbers.)")
 
end-model
 | 
| (!******************************************************
   Mosel User Guide Example Problems
   ================================= 
   file setcomp.mos
   ````````````````
   Comparison operators for sets.
 
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, 2001
*******************************************************!)
model "Set comparisons"
 declarations
  RAINBOW = {"red", "orange", "yellow", "green", "blue", "purple"}
  BRIGHT = {"yellow", "orange"}
  DARK = {"blue", "brown", "black"}
 end-declarations
 writeln("BRIGHT is included in RAINBOW: ", BRIGHT <= RAINBOW) 
 writeln("RAINBOW is a superset of DARK: ", RAINBOW >= DARK)
 writeln("BRIGHT is different from DARK: ", BRIGHT <> DARK)
 writeln("BRIGHT is the same as RAINBOW: ", BRIGHT = RAINBOW)
end-model
 | 
| (!******************************************************
   Mosel User Guide Example Problems
   ================================= 
   file setops.mos
   ```````````````
   Performing set operations.
 
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, 2001
*******************************************************!)
model "Set example"
 declarations 
  Cities={"rome", "bristol", "london", "paris", "liverpool"}
  Ports={"plymouth", "bristol", "glasgow", "london", "calais", "liverpool"}
  Capitals={"rome", "london", "paris", "madrid", "berlin"}
 end-declarations
 Places:= Cities+Ports+Capitals        ! Create the union of all 3 sets 
 In_all_three:= Cities*Ports*Capitals  ! Create the intersection of all 3 sets 
 Cities_not_cap:= Cities-Capitals      ! Create the set of all cities that
                                       ! are not capitals
 writeln("Union of all places: ", Places)
 writeln("Intersection of all three: ", In_all_three)
 writeln("Cities that are not capitals: ", Cities_not_cap)
end-model
 |