Summary
###########################################################################
File: pdco.icn
Subject: Procedures for programmer-defined control operations
Authors: Ralph E. Griswold and Robert J. Alexander
Date: June 10, 2001
###########################################################################
This file is in the public domain.
###########################################################################
These procedures use co-expressions to used to model the built-in
control structures of Icon and also provide new ones.
AddTabbyPDCO{e, i} adds tabby to treadling sequence
AllparAER{e1,e2, ...}
parallel evaluation with last result
used for short sequences
AltPDCO{e1,e2} models e1 | e2
BinopPDCO{op,e1,e2} produces the result of applying op to e1 and e2
CFapproxPDCO{e} produce sequence of approximations for the
continued-fraction sequence e
ComparePDCO{e1,e2} compares result sequences of e1 and e2
ComplintPDCO{e} produces the integers not in e
CondPDCO{e1,e2, ...}
models the generalized Lisp conditional
CumsumPDCO{e} generates the cumulative sum of the terms of e
CycleparAER{e1,e2, ...}
parallel evaluation with shorter sequences
re-evaluated
DecimatePDCO{e1, e2}
"decimate" e1 by deleting e2-numbered terms
(e2 is assumed to be an increasing sequence).
DecimationPDCO{e} produce a decimation sequence from e1 by
deleting even-valued terms and replacing
odd-valued terms by their position.
DecollatePDCO{e, i} decollate e according to parity of i
DeltaPDCO{e1} produces the difference of the values in e1
ElevatePDCO{e1, m, n}
elevate e1 mod n to n values
EveryPDCO{e1,e2} models every e1 do e2
ExtendSeqPDCO{e1,i} extends e1 to i results
ExtractAER{e1,e2, ...}
extract results of even-numbered arguments
according to odd-numbered values
FifoAER{e1,e2, ...} reversal of lifo evaluation
FriendlyPDCO{m, k, e3}
friendly sequence starting at k shaft mod m
GaltPDCO{e1,e2, ...}
produces the results of concatenating the
sequences for e1, e2, ...
GconjPDCO{e1,e2,...}
models generalized conjunction: e1 & e2 & ...
The programmer-defined control operation above shows an interesting
technique for modeling conjunction via recursive generative
procedures.
HistoPDCO{e,i} generates histogram for e limited to i terms;
default 100.
IncreasingPDCO{e} filters out non-increasing values in integer
sequence
IndexPDCO{e1,e2} produce e1-th terms from e2
InterPDCO{e1,e2, ...}
produces results of e1, e2, ... alternately
LcondPDCO{e1,e2, ...}
models the Lisp conditional
LengthPDCO{e} returns the length of e
LifoAER{e1,e2, ...} models standard Icon "lifo" evaluation
LimitPDCO{e1,e2} models e1 \ e2
ListPDCO{e,i} produces a list of the first i results from e
LowerTrimPDCO{e} lower trim
MapPDCO{e1,e2} maps values of e1 in the order they first appear
to values of e2 (as needed)
OddEven{e} forces odd/even sequence
PalinPDCO{e} x produces results of concatenating the
sequences for e and then its reverse.
ParallelPDCO{e1,e2, ...}
synonym for InterPDCO{e1, e2, ...}
ParallelAER{e1,e2, ...}
parallel evaluation terminating on
shortest sequence
PatternPalinPDCO{e, i}
produces pattern palindrome. If i is given,
e is truncated to length i.
PeriodPDCO{e, i} generates the periodic part of e; i values are
used to find the period
PermutePDCO{e1,e2} permutes each n-subsequence of e1 by the
n positional values in lists from e2. If a list does
not consist of all the integers in the range 1 to
n, "interesting" things happen (see the use
of map() for transpositions).
PivotPDCO{e, m} produces pivot points from e % m; m default 100
PosDiffPDCO{e1,e2} produces positions at which e1 and e2 differ
PositionsPDCO{e, i} generates the positions at which i occurs in e.
RandomPDCO{e1,e2, ...}
produces results of e1, e2, ... at random
ReducePDCO{op, x, e}
"reduces" the sequence e by starting with the value x
and repetitively applying op to the current
value and values from e.
RemoveDuplPDCO{e} removes duplicate adjacent values.
RepaltPDCO{e} models |e
RepeatPDCO{e1, e2} repeats the sequence for e1 e2 times
ReplPDCO{e1,e2} replicates each value in e1 by the corresponding
integer value in e2.
ResumePDCO{e1,e2,e3}
models every e1 \ e2 do e3
ReversePDCO{e, i} produces the results of e in reverse order. If i
is given, e is truncated to i values.
RotatePDCO(e, i) rotates the sequence for e left by i; negative
i rotates to the right
SelfreplPDCO{e1,i} produces e1 * j copies of e1
SeqlistPDCO{e1, i} produce list with first i values of e1; i
defaults to all values
SimpleAER{e1,e2, ...}
simple evaluation with only success or
failure
SkipPDCO{e1,e2} generate e1 skipping each e2 terms
SmodPDCO{e1,e2} reduce terms in e1 (shaft) modulus e2
SpanPDCO{e,m} fill in between consecutive (integer) values in
e % m; m default 100
SumlimitPDCO{e, i, j}
produces values of e until their sum exceeds
i. Values less than j are discarded.
TrinopPDCO{op,e2,e2,e3}
produces the result of applying op to e1, e2, and e3
UniquePDCO{e} produces the unique results of e in the order
they first appear
UnopPDCO{e1,e2} produces the result of applying e1 to e2
UpperTrimPDCO{e} upper trim
ValrptPDCO{e1,e2} synonym for ReplPDCO
WobblePDCO{e} produces e(1), e(2), e(1), e(2), e(3), e(2), ...
Comments:
Because of the handling of the scope of local identifiers in
co-expressions, expressions in programmer-defined control
operations cannot communicate through local identifiers. Some
constructions, such as break and return, cannot be used in argu-
ments to programmer-defined control operations.
###########################################################################
Requires: co-expressions
###########################################################################
Links: lists, periodic, rational
###########################################################################
Procedures:
AddTabbyPDCO, AllparAER, AltPDCO, BinopPDCO, CFapproxPDCO, ComparePDCO, ComplintPDCO, CondPDCO, CumsumPDCO, CycleparAER, DecimatePDCO, DecimationPDCO, DecollatePDCO, DeltaPDCO, ElevatePDCO, EveryPDCO, ExtendSeqPDCO, ExtractAER, FifoAER, FriendlyPDCO, GaltPDCO, GconjPDCO, Gconj_, HistoPDCO, IncreasingPDCO, IndexPDCO, InterPDCO, LcondPDCO, LengthPDCO, LifoAER, LimitPDCO, ListPDCO, LowerTrimPDCO, MapPDCO, OddEvenPDCO, PalinPDCO, ParallelAER, ParallelPDCO, PatternPalinPDCO, PeriodPDCO, PermutePDCO, PivotPDCO, PosDiffPDCO, PositionsPDCO, RandomPDCO, ReducePDCO, RemoveDuplPDCO, RepaltPDCO, RepeatPDCO, ReplPDCO, ResumePDCO, ReversePDCO, RotatePDCO, SelfreplPDCO, SeqlistPDCO, SimpleAER, SkipPDCO, SmodPDCO, SpanPDCO, SumlimitPDCO, TrinopPDCO, UniquePDCO, UnopPDCO, UpperTrimPDCO, ValrptPDCO, WobblePDCO
Links:
lists.icn, periodic.icn, rational.icn
This file is part of the (main) package.
Source code.
AddTabbyPDCO(L)
: PDCO to add tabby to treadling
AllparAER(L)
: PDAE for parallel evuation with repeats
AltPDCO(L)
: PDCO to model alternation
BinopPDCO(L)
: PDCO to apply binary operation to sequences
CFapproxPDCO(L)
: PDCO for continued-fraction approximations
ComparePDCO(L)
: PDCO to compare sequences
ComplintPDCO(L)
: PDCO to generate integers not in sequence
CondPDCO(L)
: PDCO for generalized Lisp conditional
CumsumPDCO(L)
: PDCO to produce cumulative sum
CycleparAER(L)
: PDAE for parallel evaluation with cycling
DecimatePDCO(L)
: PDCO to decimate sequence
DecimationPDCO(L)
: PDCO to create decimation sequence
DecollatePDCO(L)
: PDCO to decollate sequence
DeltaPDCO(L)
: PDCO to generate difference sequence
ElevatePDCO(L)
: PDCO to elevate sequence
EveryPDCO(L)
: PDCO to model iteration
ExtendSeqPDCO(L)
: PDCO to extend sequence
ExtractAER(L)
: PDAE to extract values
FifoAER(L)
: PDAE for reversal of lifo evaluation
FriendlyPDCO(L)
PDCO for friendly sequences
GaltPDCO(L)
: PDCO to concatenate sequences
GconjPDCO(L)
: PDCO for generalized conjunction
Gconj_(L, i, v)
HistoPDCO(L)
: histogram
IncreasingPDCO(L)
: PDCO to filter out non-increasing values
IndexPDCO(L)
: PDCO to select terms by position
InterPDCO(L)
: PDCO to interleave sequences
LcondPDCO(L)
: PDCO for Lisp conditional
LengthPDCO(L)
: PDCO to produce length of sequence
LifoAER(L)
: PDAE for standard lifo evaluation
LimitPDCO(L)
: PDCO to model limtation
ListPDCO(L)
: list from sequence
LowerTrimPDCO(L)
: lower trimming
MapPDCO(L)
: PDCO to map values
OddEvenPDCO(L)
: PDCO to force odd/even sequence
PalinPDCO(L)
: PDCO to produce palindromic sequence
ParallelAER(L)
: PDAE for parallel evaluation
ParallelPDCO(L)
: synonym for Inter
PatternPalinPDCO(L)
: PDCO to produce pattern palindrome
PeriodPDCO(L)
: PDCO for periodic part of sequence
PermutePDCO(L)
: PDCO for permutations
PivotPDCO(L)
: PDCO to generate pivot points
PosDiffPDCO(L)
PDCO to generate positions of difference
PositionsPDCO(L)
positions in e of i
RandomPDCO(L)
: PDCO to generate from sequences at random
ReducePDCO(L)
: PDCO to reduce sequence using binary operation
RemoveDuplPDCO(L)
: PDCO for remove duplicate values in a sequence
RepaltPDCO(L)
: PDCO to model repeated alternation
RepeatPDCO(L)
: PDCO to repeat sequence
ReplPDCO(L)
: PDCO to replicate values in a sequence
ResumePDCO(L)
: PDCO to model limited iteration
ReversePDCO(L)
: PDCO to reverse sequence
RotatePDCO(L)
: PDCO to rotate sequence
SelfreplPDCO(L)
: PDCO to produce multiple of values in sequence
SeqlistPDCO(L)
: PDCO to return list of values
SimpleAER(L)
: PDAE for simple evaluation
SkipPDCO(L)
: PDCO to skip terms
SmodPDCO(L)
: generalized modular reduction
SpanPDCO(L)
: fill in gaps in integer sequences
SumlimitPDCO(L)
: PDCO to sum sequence to a limit
TrinopPDCO(L)
: PDCO to apply trinary operator to sequneces
UniquePDCO(L)
: PDCO to filter out duplication values
UnopPDCO(L)
: PDCO to apply unary operation to sequence
UpperTrimPDCO(L)
: upper sequence trimming
ValrptPDCO(L)
: synonym for Repl
WobblePDCO(L)
: PDCO to produce sequence values alternately
This page produced by UniDoc on 2021/04/15 @ 23:59:54.