Padovan sequence: Difference between revisions

Added Quackery.
No edit summary
(Added Quackery.)
Line 1,909:
 
True</pre>
 
=={{header|Quackery}}==
 
<code>v**</code> is defined at [[Exponentiation operator#Quackery]].
 
<lang Quackery>( --------------------- Recurrence -------------------- )
[ dup 0 = iff
[ drop ' [ ] ] done
dup 1 = iff
[ drop ' [ 1 ] ] done
dip [ [] 0 1 1 ]
2 - times
[ dip [ 2dup + ] swap
3 pack dip join
unpack ]
3 times join behead drop ] is padovan1 ( n --> [ )
say "With recurrence: " 20 padovan1 echo cr cr
( ------------------- Floor Function ------------------ )
$ "bigrat.qky" loadfile
[ [ $ "1.324717957244746025960908854"
$->v drop join ] constant
do ] is p ( --> n/d )
[ [ $ "1.0453567932525329623"
$->v drop join ] constant
do ] is s ( --> n/d )
[ 1 -
p rot v** s v/ 1 2 v+ / ] is padovan2 ( n --> n )
say "With floor function: "
[]
20 times [ i^ padovan2 join ]
echo cr cr
( ---------------------- L-System --------------------- )
[ $ "" swap witheach
[ nested quackery join ] ] is expand ( $ --> $ )
[ $ "B" ] is A ( $ --> $ )
[ $ "C" ] is B ( $ --> $ )
[ $ "AB" ] is C ( $ --> $ )
$ "A"
say "First 10 L System strings: "
9 times
[ dup echo$ sp
expand ]
echo$ cr cr
[] $ "A"
31 times
[ dup size
swap dip join
expand ]
size join
32 padovan1 = iff
[ say "The first 32 recurrence terms and L System lengths are the same." ]
else [ say "Oh no! It's all gone pear-shaped!" ]
</lang>
 
{{out}}
 
<pre>With recurrence: [ 1 1 1 2 2 3 4 5 7 9 12 16 21 28 37 49 65 86 114 151 ]
 
With floor function: [ 1 1 1 2 2 3 4 5 7 9 12 16 21 28 37 49 65 86 114 151 ]
 
First 10 L System strings: A B C AB BC CAB ABBC BCCAB CABABBC ABBCBCCAB
 
The first 32 recurrence terms and L System lengths are the same.</pre>
 
 
=={{header|Raku}}==
1,462

edits