diff --git a/cp-demo/BinarySortedLists.scala b/cp-demo/BinarySortedLists.scala new file mode 100644 index 0000000000000000000000000000000000000000..17d8862109810c520db79af9734923b30479cc2f --- /dev/null +++ b/cp-demo/BinarySortedLists.scala @@ -0,0 +1,19 @@ +import cp.Definitions._ +import cp.Terms._ + +object BinarySortedLists { + def main(args : Array[String]) : Unit = { + val inRange : Constraint1[Int] = ((x : Int) => x >= 0 && x <= 1) + + val sortedLists = + for(x <- inRange.lazyFindAll; + y <- inRange.lazyFindAll if y >= x; + z <- inRange.lazyFindAll if z >= y) + yield { + x.value; y.value; z.value; + List(x, y, z) + } + + sortedLists.foreach(println(_)) + } +}