我有这两个列表[@,a,@,b,c,@,@,@,(de),@,@,@,f,g,@,h]
,["","","+","","","?","|","","","","","*","","","|",""]
我想通过使用scanl or map
函数来覆盖第二个列表,并在第一个列表中提取它前面的元素。这两个列表具有不同类型的元素。
例如,如果第二个列表中的元素是/= ""
然后提取第一个列表中它后面的元素(例如 for for +
to get a
, for ? -> c
,*->(de)
|->g
),我想要。
我尝试过这样的事情
map(\x-> if x /= "" then l2 !! (((elemIndices x l1)!!0)-1) else Epsilon)l1
where l1 is ["","","+","","","?","|","","","","","*","","","|",""]
and l2 is [@,a,@,b,c,@,@,@,(de),@,@,@,f,g,@,h]
but 它不起作用,而且@ = Epsilon
and 它来自data Reg = Epsilon | Literal Char | Or Reg Reg | Then Reg Reg | Star Reg deriving Eq
.
有人能帮我吗 ?