Contributions
Re: String with two variables failing
def asdf = ["B","S"] def qwer = ["B"] log.info asdf String result = getExpectedResult(asdf,qwer) log.info result public String getExpectedResult(def dbList, def inputCom) { def masterSet = [A:'A',B:'BS',C:'CDE'] def status= "true" for(e in inputCom){ masterValOfCom = masterSet[e] log.info masterValOfCom dbList.each{ if(!masterValOfCom.contains(it)){ status="false" return status } } } return status } The above returns true which is good. Now I have list of values coming from the loop as for asdf as [A,B] [A] [B] and so on.. and values for qwer are [A],[B],[C] now hyow to insert these asdf and qwer ingetExpectedResult because now I use the above code its throwing me error stating MissingPropertyException703Views0likes0CommentsString with two variables failing
I have two questions 1. String asdf = ['B','S'] String qwer = ['B'] def result = getExpectedResult(asdf, qwer) log.info result Its failing am expecting it takes something likegetExpectedResult(['B','S'], ['B']). How to achieve 2. am getting outputs from database like [A,B] [A] [B,S,L,N] [E] [P] and so on ... All these results are generated in a loop. How to achieve as ['A',B'] ['A'] ['B','S','L','N'] ['E'] ['P']733Views0likes2CommentsRe: How to print all possible combinations of a given array
Awesome this helps himanshu. I have found another way to do it in a simple format. def Z = ['a','b','c','d','e'] def result =[Z,Z,Z].combinations().findAll{x,y,z -> x<y&y<z} def result2 = [Z,Z].combinations().findAll{x,y -> x<y} def finalresult = result + result2 log.info finalresult result :[[a, b, c], [a, b, d], [a, c, d], [b, c, d], [a, b, e], [a, c, e], [b, c, e], [a, d, e], [b, d, e], [c, d, e], [a, b], [a, c], [b, c], [a, d], [b, d], [c, d], [a, e], [b, e], [c, e], [d, e]]977Views0likes1CommentHow to print all possible combinations of a given array
Hello Team I have an array of def Z = ['a','b','c','d','e','f','g'] how to get all possible 3 alphabet combinations without each element repeat by itself. Output required: [a.b.c],[a,b,d] and so on but shouldnt have [a,a,a] or [a,a,b] something like this1.2KViews0likes3Comments