Reputation: 15
How do I add an improper tail (e.g. |<<>>) to a proper Erlang list "Parent" with an arbitrary number of elements? I need this to create a range scan upper limit value for matchspecs on a MNESIA table where list keys represent object hierarchy.
To my understanding (inspired by the sext project) any children of a parent key Parent=[T1,T2,T3]
(T1,T2,T2 are arbitrary Erlang Terms) can be found with matchspecs asking for:
Child > [T1,T2,T3] and Child < [T1,T2,T3|<<>>]
Given only Parent as a whole, how do I calculate the upper value?
Upvotes: 1
Views: 89
Reputation: 20014
To get the improper list you're looking for, just append the empty binary <<>>
to the list:
Parent ++ <<>>.
For example, if Parent
is [t1,t2,t3]
:
1> Parent = [t1,t2,t3].
[t1,t2,t3]
2> Parent ++ <<>>.
[t1,t2,t3|<<>>]
Upvotes: 3