- [Class]
palindrome
Enumerates data forwards and backwards. Sub-patterns continue to produce their own (local) orderings.
palindrome
supports the following slot initializations:
:elide
{boolean |:first
|:last
| pattern}-
Determines how the first and last data elements are treated when the
pattern reverses direction. If the value is false then these values
are repeated as the pattern reverses direction. If the value is true
then neither are repeated. Otherwise the
:first
or the:last
can be elided. The value can also be a pattern, in which case a new elision value will be chosen each period of the pattern. The default value is false.
See generic pattern initializations for documentation on additional keyword initializations to the pattern.
Examples:
Example 1. The palindrome pattern.
(define pat1 (new palindrome :of '(a b c d))) (next pat1 16) ⇒ (a b c d d c b a a b c d d c b a) (define pat1 (new palindrome :of '(a b c d) :elide #t)) (next pat1 12) ⇒ (a b c d c b a b c d c b a b c d)
Example 2. The effect of eliding.
(define (play-pal reps trope rate) (let ((p (new palindrome :keynums trope :repeat reps :elide (new cycle :of '(#f #t :first :last))))) (process for k = (next p) until (eod? p) output (new midi :time (now) :duration (* rate 1.5) :keynum k) wait rate))) (events (play-pal 8 '(a4 b c5 d e) .2) "test.mid") ⇒ "test.mid"
See also:
- Pattern classes [Topic]