filter - List-Comprehension in Erlang - Variable unbound in guard -
i trying build list recursively method. ol (occurence list of characters) list shrink []. need use q in guard check if item can subtracted. shall produce filtered cartesian product.
b([[]], _)->[[]]; b(_, [])-> [[]]; b(ol, keys)->[y++[q] || y <- b(subtract(q,ol), keys), q <-keys, len(subtract(q,ol)) < len(ol)].
but error:
variable 'q' unbound
is there way use value @ place?
the subtract-method filters characters out of list. subtract([{$a,1}],[{$a, 5},{$b, 1}]) returns [{$a, 5},{$b, 1}].
len() sums integer values of each tuple. len([{$a, 5},{$b, 1}]) returns 6.
try put q generator before usage in y generator. guess definitions applied left right when y applied there no q defined.
Comments
Post a Comment