I am currently working in the elm syntax. An example would be like this:
(Sequence ('a') ('b')) ('c') ['a', 'b', 'c', 'd'] . In this example, i only test if the elements 'a', 'b', 'c' are members of the list. If yes, then i partition it and obtain (['a','b','c'],['d'])
I encountered problems in the following case:
(Sequence ('a') ('b')) ('c') ['a', 'b', 'c', 'a']
obtaining the result : (['a','b','c','a'],[])
My question is: what condition should i put such that the elements 'a' and 'b' must be consecutive avoiding the case when they are matched alone?
This answer assumes that if you have Sequence 'a' 'b' 'c'
and test it against the list ['a', 'b', 'c', 'a']
, you want to receive the result (['a', 'b', 'c'], ['a'])
(as asked in this comment).
In pseudo-code:
list1
and list2
. list1
should have the same length as your sequence. Elm provides List.take and List.drop for thatlist_sequence
with a helper functionlist1
and list_sequence
are equal(list1, list2)
And here is the actual Elm code: https://ellie-app.com/bjBLns4dKkra1