// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package jwj

class X {
    int a
    String b
    String toString() {
        return "(" + a + "," + b + ")"
    }
}

lst = [ new X(a: 1, b: "A"), new X(a: 2, b: "BB"), new X(a: 3, b: "CCC") ]
println(lst)

lst2 = GQ { from elm in lst where elm.a > 1 select elm.b }
println(lst2)

class Y {
    String b
    double c
    String toString() {
        return "(" + b + "," + c + ")"
    }
}

lst3 = [ new Y(b: "A", c: 1.2), new Y(b:"BB", c: 3.4) ] 
println(lst3)

lst4 = GQ { from elm in lst join elm3 in lst3 on elm.b == elm3.b select elm.a, elm3.c }
for(o4 in lst4) println(o4.a + " " + o4.c)
