.net - Invalid cast exception error when implementing Power set function -


i trying generate powerset of list of node elements in graph. have identified , adapted following code previous post (unique combination of set)

public function powerset(byval s list(of node)) list(of list(of node))      dim ini list(of list(of node)) = new list(of list(of node))     return s.aggregate(ini, function(a, b) a.concat(a.select(function(x) x.concat({b}))))  end function 

i testing function using

for each x in g.powerset(g.internal_nodes_in_path)     console.writeline(x) next 

however, invalid cast exception error pointing @ function(a,b) in powerset function:

additional information: unable cast object of type 'whereselectlistiterator2[system.collections.generic.list1[cdag_with_classes.node],system.collections.generic.ienumerable1[cdag_with_classes.node]]' type 'system.collections.generic.ienumerable1[system.collections.generic.list`1[cdag_with_classes.node]]'.

can offer advice on might going wrong?

thanks

so got tumbleweed badge one. don't know if that's or bad thing?! anyway, went basics, got books out , came better solution (and more importantly 1 worked). tumble(-weed)s across in future...

public function powerset(of t)(byval s ienumerable(of t)) ienumerable(of ienumerable(of t))     s = p.nodes_in_path     dim result = m in enumerable.range(0, 1 << s.count)             select                in enumerable.range(0, s.count)                (m , (1 << i)) <> 0                    select s(i)     return result  end function 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -