Hi all,<br><br>I'm having trouble creating a qlc expression which does what I want.  I'm basically trying to create a filter for QH1 with a predicate that depends on QH2.  <br>In the example below, test2/0 gives me the result I'm looking for, but it requires the second QH to be eval'd.  I'd like the expression to look like what's in the test1/0 function.  Any suggestions?<br>
<br>Thanks,<br>-Adam<br><br>session:<br>8> test_qlc:test2().<br>[{1,6,7},{2,8,9}]<br>9> test_qlc:test1().<br>[{1,4,5},<br> {1,2,3},<br> {1,6,7},<br> {1,6,7},<br> {2,4,5},<br> {2,2,3},<br> {2,8,9},<br> {2,8,9},<br> {3,4,5},<br>
 {3,2,3}]<br><br>code:<br><br>-module(test_qlc).<br>-include_lib("stdlib/include/qlc.hrl").<br>-export([test1/0,test2/0,handroll/0]).<br><br>-define(DB,[<br>  {1,4,5},{1,2,3},{1,6,7},<br>  {2,4,5},{2,2,3},{2,8,9},<br>
  {3,4,5},{3,2,3}<br>]).<br>-define(OBJ,[{2,3},{4,5}]).<br><br>test1() -><br>    qlc:eval(qlc:q([ {O1,C1,V1} ||<br>                       {O1,C1,V1} <- ?DB,<br>                       {C2,V2} <- ?OBJ,<br>                       C1 /= C2,<br>
                       V1 /= V2])).<br>test2() -><br>    qlc:eval(qlc:q([ {O1,C1,V1} ||<br>                     {O1,C1,V1} <- ?DB,<br>                     lists:member({C1,V1},?OBJ) == false ])).<br><br>handroll() -><br>
    S = mkset(?DB),<br>    O = mkobj(?OBJ),<br>    to_table(difference(O,related(O,S))).<br><br>related(S1,D) -><br>    dict:filter(fun(_,S2) -><br>                        sets:is_subset(S1,S2)<br>                end,D).<br>
<br>difference(S1,D) -><br>    dict:filter(fun(_,S2) -><br>                        sets:size(S2) > 0<br>                end,<br>                dict:map(fun(_,S2) -><br>                                 sets:subtract(S2,S1)<br>
                         end,D)).<br><br>to_table(D) -><br>    lists:flatmap(fun({K,V}) -><br>                          lists:map(fun({X,Y}) -><br>                                            {K,X,Y}<br>                                    end,<br>
                                    sets:to_list(V))<br>                  end,<br>                  dict:to_list(D)).<br><br>mkset(DB) -><br>    dict:map(fun(_,V) -><br>                     sets:from_list(V)<br>             end,<br>
             lists:foldl(fun({O,C,V},Acc) -><br>                                  dict:append(O,{C,V},Acc)<br>                         end,<br>                         dict:new(),DB)).<br><br>mkobj(OBJ) -><br>    sets:from_list(OBJ).<br>
<br>