left outer join of two lists or records

10 views
Skip to first unread message

Gregg Fiehler

unread,
Dec 9, 2016, 6:28:28 PM12/9/16
to Erlang Questions
below is a simplified version of what I need to accomplish.

-record(record_a, {key1, fruit}).
-record(record_b, {key1, like}).
-record(record_all, {key1, fruit, like}).

key1 is a unique key for all records.

record_b key1 values will always be a subset of record_a key1 values.

If I have lists that look like

X = [{record_a, {1, apple}}, {record_a, {2, orange}}, {record_a,{3, pear}}],

Y = [{record_b, {1, true}}, {record_b, {2, false}}]

I am looking to get a list of record_all's that looks like

Z = [{record_all, {1, apple, true}}, {record_all, {2, orange, false}}, {record_all,{3, pear, undefined}}],


record_a and record_b are tables, I have tried to join with qlc but cannot get this result.  I wanted to know if there was any good way to do this efficiently or if I need to just iterate thru record_a and search for possible 'like' values in record_b to create record_c??  Basically it is a left outer join of record_a and record_b, but I cannot find anyway to do this efficiently.  Worse case I can iterate and do this, the data sets are not that large, but would prefer to be efficient as possible.

thanks
Gregg 


Reply all
Reply to author
Forward
0 new messages