[erlang-questions] bitstring ets:select

Sid Muller sid5@REDACTED
Fri Nov 20 17:42:13 CET 2015

Is there a way to do a select on a bitstring based on a value in ets table?
The X:'$2'/bitstring below results in an illegal bit size, which makes sense because '$2' doesn't exits yet.

How do I dynamically create that X value based on external B value and '$2' that will be selected from ets table? Is that even possible?

	table = ets:new(table, [set, named_table]),

	A = <<2#000111110001100010101:21>>,
	true = ets:insert(table, {A, 21}),

	B = <<31,24,171,44>>,

	Ret = ets:select(table, [{{'$1','$2'},[{'==','$1', fun()-><<X:'$2'/bitstring,_Rest/bitstring>> = B, X end}],[['$1', '$2']]}]),


More information about the erlang-questions mailing list