Created
September 18, 2011 16:37
-
-
Save kijuky/1225246 to your computer and use it in GitHub Desktop.
佐賀Groovy勉強会 - 演習1:小町算
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovyx.gpars.GParsPool | |
GParsPool.withPool { | |
def array = ["+", "-", "*", "/"] | |
def combi = GroovyCollections.combinations((1..2).collectParallel{ array }) // arrayから2つ選びだす順列 | |
println combi //=> [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3]] | |
combi.each { | |
def s = "1" | |
def i = 2 | |
it.each { | |
s += it + (i++) | |
} | |
//println s | |
def eval = new Eval() | |
eval.me("if (" + s + " == 6) println \"" + s + "\"") // evaluation! と表示する | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment