Re: regular expression problem



borges2003xx@xxxxxxxx wrote:
> hi everyone
> there is a way, using re, to test (for es) in
> a=[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14] if a list b is
> composed by three "sublists" of a separated or not by elements.

Heya,

Is there any particular reason why you need to use re?

If you're using Python 2.3 or greater, the sets module might be easier
to deal with here:

>>> from sets import Set
>>> a = Set([1,2,3,4,5,6,7,8,9,10,11,12,13,14])
>>> b = Set([2,3,4,7,8,12,13])
>>> b.issubset(a)
True
>>> b = Set([1,2,5,14])
>>> b.issubset(a)
True
>>> b = Set([3,7,23,200])
>>> b.issubset(a)
False

Sets are unsorted, I'm uncertain if that's a requirement for you.

Hope this helps.
-alex23

.



Relevant Pages

  • Re: hints for my homework please
    ... > and a number and produces a list of the sublists of the list ... > each of which contains exactly m members of the original ... > of (cdr l). ... Prev by Date: ...
    (comp.lang.scheme)
  • Re: hints for my homework please
    ... Pascal Bourguignon writes: ... >> I just need a simple explanation or a sample of what a sublist is. ... >> example what are the sublists of 2 items of the list ' ... Prev by Date: ...
    (comp.lang.scheme)
  • Re: hints for my homework please
    ... Sublists means that the elements must be contiguous, ... it's not something like permutation. ... Meaning that if you have a list ... Prev by Date: ...
    (comp.lang.scheme)
  • Re: how to create a big list of list
    ... of those sublists? ... Recent Python versions have a built-in type ...
    (comp.lang.python)
  • Re: hints for my homework please
    ... > sublist of (cdr l) means?" ... Suppose you already knew the definition of "sublist" for all sublists ... Matthias ... Prev by Date: ...
    (comp.lang.scheme)