On Thu, 18 Jun 2009, David Mertens wrote:

> Most everybody on this list probably understands the power of regexp's for
> string processing.  Has anybody ever given thought to creating a vector
> regexp (I would call it 'subsetting') for codifying complex slices?

I'm not sure how one would use this in practice but...
> 
> Here's what I've come up with so far:
> 
> Basic Metacharacters
> ====================
> ^   Match the beginning of a vector
> $   Match the end of a vector
> |   Alternation
> ()  Grouping
> .   Match a single number
> 
> Numerical Ranges
> ================
> (a,b)  match any number c such that a <  c <  b
> (a,b]  match any number c such that a <  c <= b
> [a,b)  match any number c such that a <= c <  b
> [a,b]  match any number c such that a <= c <= b
> 
> Quantifiers
> ===========
> *      Match 0 or more times
> +      Match 1 or more times
> ?      Match 1 or 0 times
> {n}    Match exactly n times
> {n,}   Match at least n times
> {n,m}  Match at least n but not more than m times
> 
> Slicing
> =======
> s()  Include this group in the resulting slice.
> 
> Metacharacters
> ==============
> p     matches a positive number
> P     matches a positive number or zero
I'd swap that

  P     matches a negative number or zero
> n     matches a negative number
  N     matches a positive number or zero

so that n is not N, p is not P, as it is in regexps

> N     matches a negative number or zero
> o     matches zero
> O     matches nonzero

Like this is: o is not O 

> M     matches a local maximum
> N     matches any character that is not a local maximum

 conflicts with negative.

> m     mathces a local minimum
> n     matches any character that is not a local minimum
> M{n}  matches a local maximum near index n
> m{n}  mathces a local minimum near index n
> \M    matches the global maximum
> \m    matches the global minimum
> 
> Zero-width Assertions
> =====================
> \c    Match a zero crossing
> \c+   Match a positively sloped zero crossing
> \c-   Match a negatively sloped zero crossing
> \c=a  Match when the time-series crosses the value a
> \c=a+ Match when the time-series crosses the value a with positive slope
> \c=a+ Match when the time-series crosses the value a with negative slope
> \dN   Match where the Nth numerical derivative crosses zero (also for +- and
> =)

I'd add
 S(...) sum the elements matched
 t(...) times: product of the elements matched
 b(...) Bounds of the elements matched
 l(...) length of match, i.e a count
 i      is integer 
 I      is noninteger
 c      is complex 
Possibly
 f{   } f($x) is true in the Perl sense (nonzero), where $x works like
        $a and $b in the sort function, and perldl code goes in {...}

And if you have operators to move forward and backwards you've got the
best part of a Turing machine!

I don't know how one might apply Is a positive maximum, is a negative maximum.
> 
        Hugh

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to