Sequences - Xref - Sequences - step


App: regression/framework Page: sequence/a_sequence_term_in_an_expression_takes_the_parameter_second
PHP
HTML
sequence/a_sequence_term_in_an_expression_takes_the_parameter_second.pad
Result
a[{echo sequence:add(3, 10)}] b[{echo sequence:multiple(4, 5)}] c[{echo sequence:power(3, 2)}] d[{echo sequence:step(3, 5)}] e[{echo sequence:loop(3, 5)}] f[{echo sequence:add(3)}]

App: regression/framework Page: sequence/build_function_is_the_term_at_each_position_of_a_type_that_steps_itself
PHP
HTML
sequence/build_function_is_the_term_at_each_position_of_a_type_that_steps_itself.pad
Result
[{sequence step=3, build='function', from=2, to=4}{$sequence} {/sequence}][{sequence '2;3;4', make, step=3, build='function'}{$sequence} {/sequence}][{sequence '2;3;4', make, even, build='function'}{$sequence} {/sequence}][{sequence even, build='function', from=2, to=4}{$sequence} {/sequence}][{sequence '1..6', make, odd, build='function'}{$sequence} {/sequence}][{sequence odd, build='function', from=2, to=4}{$sequence} {/sequence}][{sequence step=3, rows=4}{$sequence} {/sequence}][{sequence '2;3;4', make, step=3}{$sequence} {/sequence}][{sequence multiple=3, build='function', from=2, rows=3}{$sequence} {/sequence}][{sequence '1..3', make, multiple=3, build='function'}{$sequence} {/sequence}][{sequence step=3, build='function', increment=2, rows=3}{$sequence} {/sequence}][{sequence even, build='function', rows=3}{$sequence} {/sequence}]

App: regression/framework Page: sequence/build_function_on_a_type_that_steps_itself_gives_the_term_past_the_ceiling
PHP
HTML
sequence/build_function_on_a_type_that_steps_itself_gives_the_term_past_the_ceiling.pad
Result
[{sequence even, build='function', from=3000000, rows=3}{$sequence} @else@none{/sequence}][{sequence odd, build='function', from=1000000, rows=3}{$sequence} @else@none{/sequence}][{sequence step=3, build='function', from=1000000, rows=3}{$sequence} @else@none{/sequence}][{sequence multiple=3, build='function', from=1000000, rows=3}{$sequence} @else@none{/sequence}][{sequence '999999;1000000;1000001', make, even, build='function'}{$sequence} @else@none{/sequence}][{sequence even, build='function', from=4611686018427387902, rows=3}{$sequence} @else@none{/sequence}][{sequence step=2.5, build='function', from=3, rows=3}{$sequence} @else@none{/sequence}]

App: regression/framework Page: sequence/step
PHP
HTML
sequence/step.pad
Result
{sequence step=3, rows=8}
{$sequence},
{/sequence}

App: regression/framework Page: sequence/step_takes_a_range_or_a_store_as_its_step
PHP
HTML
sequence/step_takes_a_range_or_a_store_as_its_step.pad
Result
[{sequence step='3..3', rows=3}{$sequence} {/sequence}][{sequence '4;9', push='st'}{sequence step='st', rows=3}{$sequence} {/sequence}][{sequence step, rows=3}{$sequence} {/sequence}]

App: sequence Page: basic/step

App: sequence Page: examples
PHP
examples.php
HTML
examples.pad
Result
<?php

// Examples page: picks the group of examples to show and the one item out of it.
//
// example= names a directory of the application, so it is only used when it is one of the
// groups the page offers - the same list examples.pad walks. Interpolating it unchecked
// meant a ../ read the file names of any directory the server could reach, and an unknown
// group ended the request with a 500. item= is checked against the group's own contents,
// which it already was.

$examples = [ 'sequences', 'specials', 'random', 'play/single', 'play/double', 'keepRemoveFlag' ];

if ( ! isset (
$example ) or ! in_array ( $example, $examples ) )
$example = 'specials';

if (
$example == 'specials' )
if ( ! isset (
$item ) or ! $item )
$item = 'basic';

if (
$example == 'sequences')
$exam = sequenceDir ( APP . "basic" ) ;
else
$exam = sequenceDir ( APP . "$example" ) ;

if ( !
count ( $exam ) )
$exam = [ 'basic' ];

if ( isset (
$item ) and ! in_array ( $item, $exam) )
$item = $exam [0];

if ( ! isset (
$item ) or ! $item )
$item = $exam [0];

?>
{data 'list'} 
(
'sequences',
'specials',
'random',
'play/single',
'play/double',
'keepRemoveFlag'
)
{/data}

{block}

<p>Examples ! Many are generated and do not always make sence, <br>the examples from 'specials' are hand crafted and gives a good view of what the Sequences subsystem of PAD can do.</p>

{/block}

<br>
{lines}
{list}
{if $example eq $list}
<b>{$list}</b>
@else@
<a href="?examples&example={$list}{?item}">{$list}</a>
{/if}
{notLast} | {/notLast}
{/list}
{/lines}

<br>

{block}<center>

{exam}
{if $item eq $exam}
<b>{$exam}</b>
@else@
<a href="?examples&example={$example}&item={$exam}">{$exam}</a>
{/if}
&nbsp;
{/exam}

<br><br><hr>

{if $example eq 'sequences' }
<h3>{$item}</h3>
{exists APP . 'basic/{$item}.pad'}
<h5>{echo 'basic/{$item}.pad'}</h5>
{example 'basic/{$item}', onlyResult}
{/exists}
{list}
{exists APP . '{$list}/{$item}.pad'}
<h5>{echo '{$list}/{$item}.pad'}</h5>
{example '{$list}/{$item}', onlyResult}
{/exists}
{/list}
@else@
{example '{$example}/{$item}', onlyResult, include}
{/if}

</center>{/block}

App: sequence Page: gallery
PHP
gallery.php
HTML
gallery.pad
Result
<?php

// The gallery: every sequence type that needs no parameter, its first 24 terms drawn as a
// {sparkline}, the first eight written out, and the OEIS entry the terms come from - a
// link to oeis.org, found in the table the oeis type reads (seqFunOeis in _lib/fun.php).

$drawn = [];

foreach (
seqFunTypes () as $type ) {

$terms = seqFunTerms ( $type, 24 );
$oeis = seqFunOeis ( $terms, $type );

$drawn [] = [
'type' => $type,
'first' => implode ( ', ', array_slice ( $terms, 0, 8 ) ),
'oeis' => $oeis ? sprintf ( 'A%06d', $oeis ) : ''
];

}

?>
<p>Every sequence type that needs no parameter, its first 24 terms drawn by
<code>{sparkline sequence=$type, rows=24}</code>, beside the
<a href="https://oeis.org">OEIS</a> entry the terms come from. Follow a name to hear it.</p>

<table cellpadding="4">
{drawn}
<tr>
<td align="right"><a href="?listen&type={$type}">{$type}</a></td>
<td>{sparkline sequence=$type, rows=24}</td>
<td align="left"><small>{$first}, ...</small></td>
<td>{if $oeis ne ''}<a href="https://oeis.org/{$oeis}">{$oeis}</a>{/if}</td>
</tr>
{/drawn}
</table>

App: sequence Page: listen
PHP
listen.php
HTML
listen.pad
Result
<?php

// Listen: a sequence played as notes. Each of the first 32 terms becomes a note - the
// term modulo 60, five octaves up from C2, the way the OEIS 'listen' button folds a term
// into the keyboard - and the notes are written as a WAV file into the page itself
// (seqFunWav in _lib/fun.php), so an <audio> element plays them without JavaScript.
// Recamán's sequence, which jumps back and forth, is the famous one to listen to.
//
// type arrives from the query string and is used only when it names a type the gallery
// draws.

$choices = seqFunTypes ();

if ( ! isset (
$type ) or ! is_string ( $type ) or ! in_array ( $type, $choices ) )
$type = 'recaman';

$terms = seqFunTerms ( $type, 32 );
$oeis = seqFunOeis ( $terms, $type );
$oeis = $oeis ? sprintf ( 'A%06d', $oeis ) : '';
$list = implode ( ', ', $terms );
$notes = implode ( ' ', array_map ( 'seqFunNoteName', seqFunNotes ( $terms ) ) );
$audio = seqFunWav ( $terms );

?>
<p>{choices}{notFirst} | {/notFirst}{if $choices eq $type}<b>{$choices}</b>@else@<a href="?listen&type={$choices}">{$choices}</a>{/if}{/choices}</p>

<h3>{$type | ucfirst}{if $oeis ne ''} - <a href="https://oeis.org/{$oeis}">{$oeis}</a>{/if}</h3>

{chart 'line', data='terms', title='{$type | ucfirst}, the first 32 terms', width=640, height=220}

<p><audio controls preload="none" src="{$audio}"></audio></p>

<p>Each term is a note: the term modulo 60, counted in semitones up from C2.</p>

<p><small>{$list}</small></p>

<p><small>{$notes}</small></p>

App: sequence Page: play/single/step

App: sequence Page: sequences
PHP
sequences.php
HTML
Result
<?php

echo "{table}";

echo
str_pad ( "{demo}{sequence}", 38) . "{\$sequence} {/sequence} {/demo}";

foreach (
types () as $type ) {

$parm = pqParm ( $type );

if (
$type == 'oeis' ) $gox = "oeis=87";
elseif (
$type == 'list' ) $gox = "list='1;8;5;2;9;66'";
elseif (
$type == 'range' ) $gox = "range='1..10'";
elseif (
$type == 'eval' ) $gox = "eval='@ * 10 | @ - 1'";
elseif (
$type == 'random' ) $gox = 'random, maximal=99';
else
$gox = "$type$parm";

echo
str_pad ( "{demo}{sequence $gox}", 38) . "{\$sequence} {/sequence} {/demo}";

}

echo
"{/table}";

?>

App: sequence Page: specials/basic

App: sequence Page: types/step