Sequences - Xref - Sequences - repeat


App: regression/errors Page: syntax/a_literal_of_another_sequence_call_lets_no_eval_run
PHP
syntax/a_literal_of_another_sequence_call_lets_no_eval_run.php
HTML
syntax/a_literal_of_another_sequence_call_lets_no_eval_run.pad
Result
<?php

// Only a literal parameter of the eval sequence is an expression the template wrote: the
// value spliced into sequence:repeat(2, '...') was taken for one, and sequence:eval(2, $q),
// refused on its own, then ran the same value from the request.

$q = '0 + php:abs(-3)';

?>
{echo sequence:repeat(2, '{$q}')}{echo sequence:eval(2, $q)}

App: regression/framework Page: sequence/a_count_or_range_given_to_a_type_without_a_parameter_is_read_as_such
PHP
HTML
sequence/a_count_or_range_given_to_a_type_without_a_parameter_is_read_as_such.pad
Result
[{prime 5}{$prime} {/prime}][{fibonacci 5}{$fibonacci} {/fibonacci}][{keep:prime '1..10'}{$sequence} {/keep:prime}][{flag:even '1;2;3'}{$sequence}{/flag:even}][{multiply 3, rows=3}{$multiply} {/multiply}][{repeat 'x', rows=2}{$repeat}{/repeat}]

App: regression/framework Page: sequence/a_random_range_with_an_end_past_the_float_range_draws_inside_it
PHP
sequence/a_random_range_with_an_end_past_the_float_range_draws_inside_it.php
HTML
sequence/a_random_range_with_an_end_past_the_float_range_draws_inside_it.pad
Result
<?php

$up
= '1...1e400';
$down = '-1e400...-5';

?>
[{sequence 'repeat', $up, rows=20}{if $sequence lt 1}low {/if}{/sequence}][{sequence 'repeat', $down, rows=20}{if $sequence gt -5}high {/if}{/sequence}][{sequence '1;1;1;1;1;1', make, add=$up}{if $sequence lt 2}low {/if}{/sequence}]

App: regression/framework Page: sequence/a_type_store_or_action_given_as_the_first_parameter_is_run
PHP
HTML
sequence/a_type_store_or_action_given_as_the_first_parameter_is_run.pad
Result
[{sequence 'prime'}{$sequence} {/sequence}][{set $t = 'fibonacci'}{sequence $t, rows=5}{$sequence} {/sequence}]{sequence '1..5', push='s'}{/sequence}[{sequence 's'}{$sequence} {/sequence}][{action 's', reverse}{$sequence} {/action}][{keep 'odd', s}{$sequence} {/keep}][{pull:s 'reverse'}{$sequence} {/pull:s}][{repeat 'prime', rows=2}{$repeat} {/repeat}][{sequence 'sum', from=1, to=4}{$sequence}{/sequence}]

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

App: regression/framework Page: sequence/the_bare_parameter_and_the_parameter_1_keep_their_terms_apart
PHP
HTML
sequence/the_bare_parameter_and_the_parameter_1_keep_their_terms_apart.pad
Result
[{echo sequence:repeat(2)}][{echo sequence:repeat(2, 1)}][{echo sequence:repeat(5, 1)}][{echo sequence:repeat(5)}][{sequence '1..5', keep, range}{$sequence} {/sequence}][{sequence '1..5', keep, range=1}{$sequence} {/sequence}][{sequence '1..5', keep, repeat}{$sequence} {/sequence}][{sequence '1..5', keep, repeat=1}{$sequence} {/sequence}][{sequence '1..5', keep, range}{$sequence} {/sequence}]

App: regression/framework Page: sequence/unique_drops_repeats
PHP
HTML
sequence/unique_drops_repeats.pad
Result
{sequence repeat=5, rows=4, unique}
{$sequence},
{/sequence}

App: sequence Page: basic/repeat

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/repeat

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/other

App: sequence Page: types/repeat