From 9740e9610f52a1de884240e85595cdede4abdcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Sinan=20K=C3=B6ksal?= <alisinan@gmail.com> Date: Wed, 13 Jul 2011 17:20:51 +0000 Subject: [PATCH] parsing functions with underscores as constraints --- cp-demo/PaperExamples.scala | 6 +++--- src/cp/CallTransformation.scala | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cp-demo/PaperExamples.scala b/cp-demo/PaperExamples.scala index acfa87ed0..573d27ce0 100644 --- a/cp-demo/PaperExamples.scala +++ b/cp-demo/PaperExamples.scala @@ -55,8 +55,8 @@ object PaperExamples extends App { c*y+d*u == 1).find def boundedUnimodular(m : Int) = { - boundedQ(m) && - ((a : Int, b : Int, c : Int, d : Int) => isUnimodular(a,b,c,d)) // TODO would be great if we could write this as isUnimodular _ :) + boundedQ(m) && (isUnimodular _) + // ((a : Int, b : Int, c : Int, d : Int) => isUnimodular(a,b,c,d)) // TODO would be great if we could write this as isUnimodular _ :) } def action : Unit = { @@ -211,7 +211,7 @@ object PaperExamples extends App { } def action : Unit = { - (1 to 7).foreach(i => { + (1 to 3).foreach(i => { val num = ((t : Tree) => validTree(t) && valuesWithin(t,i) && size(t) == i).findAll.size p("# of RBTs with " + i + " distinct els", num) }) diff --git a/src/cp/CallTransformation.scala b/src/cp/CallTransformation.scala index 1ae9a8e95..ff42189e7 100644 --- a/src/cp/CallTransformation.scala +++ b/src/cp/CallTransformation.scala @@ -50,6 +50,11 @@ trait CallTransformation val Function(funValDefs, funBody) = function extracted += (function.pos -> extractFunction(unit, funValDefs, funBody)) } + case Apply(TypeApply(Select(Select(cpIdent, definitionsName), func2termName), typeTreeList), List(Block(Nil, function: Function))) if + (definitionsName.toString == "Definitions" && func2termName.toString.matches("func2term\\d")) => { + val Function(funValDefs, funBody) = function + extracted += (function.pos -> extractFunction(unit, funValDefs, funBody)) + } case Apply(Select(lhs, withFilterName), List(predicate: Function)) if withFilterName.toString == "withFilter" && hasLIteratorType(lhs) => { val Function(funValDefs, funBody) = predicate extracted += (predicate.pos -> extractWithFilterPredicate(unit, funValDefs, funBody)) -- GitLab