Return to Snippet

Revision: 32311
at October 6, 2010 05:44 by laurenceosx


Updated Code
def paramNames  = request.getParameterNames().collect { it }
def paramValues = request.getParameterNames().collect { request.getParameter(it) }

// -----------------------------------------------
def getEvenNumbers(l) {
        l.findAll {it % 2 == 0}
    }
 
    def getFilesGreaterThan(size, folder) {
        new File(folder).listFiles().findAll {it.isFile() && it.length() > size}
    }
 
    def solveProblem() {
        (1..9).each { a->
            (0..9).each { b->
                (0..9).each { c->
                    (0..9).each { d->
                        if ((1000*a + 100*b + 10*c + d)*4 == 1000*d +100*c + 10*b + a) {
                            println "$a, $b, $c, $d"
                        }
                    }
                }
            }
        }
    }

Revision: 32310
at September 22, 2010 05:09 by laurenceosx


Initial Code
def getEvenNumbers(l) {
        l.findAll {it % 2 == 0}
    }
 
    def getFilesGreaterThan(size, folder) {
        new File(folder).listFiles().findAll {it.isFile() && it.length() > size}
    }
 
    def solveProblem() {
        (1..9).each { a->
            (0..9).each { b->
                (0..9).each { c->
                    (0..9).each { d->
                        if ((1000*a + 100*b + 10*c + d)*4 == 1000*d +100*c + 10*b + a) {
                            println "$a, $b, $c, $d"
                        }
                    }
                }
            }
        }
    }

Initial URL
https://www.ist-dresden.de/blog/?p=11

Initial Description

                                

Initial Title
Groovy \"List Comprehension\" example

Initial Tags
groovy

Initial Language
Groovy