Concatenative topics
Concatenative meta
Other languages
Meta
Quackery is an open source, lightweight, entry level concatenative language for educational and recreational programming.
It is coded as a Python 3 function in around 48k of Pythonscript, about half of which is a string of Quackery code.
The Quackery GitHub repository, which includes the Quackery manual The Book of Quackery in pdf form, is at https://github.com/GordonCharlton/Quackery.
More examples can be found at http://rosettacode.org/wiki/Category:Quackery.
[ dup 2 < if done dup 1 - recurse swap 2 - recurse + ] is fibonacci ( n --> n )
[ stack ] is sort.test ( --> s ) [ ]'[ sort.test put [] swap witheach [ swap 2dup findwith [ over sort.test share do ] [ ] nip stuff ] sort.test release ] is sortwith ( [ --> [ ) [ sortwith > ] is sort ( [ --> [ )
sort.test
is an ancillary stack. There are no variables in Quackery, ancillary stacks include serving as local variables amongst their uses.]'[
is called "meta-quote" - it grants the behaviour of '
("quote") to sortwith
as syntactic sugar. Without the meta-quote in sortwith
, sort
would be defined as [ ' > sortwith ] is sort
[ this unbuild $ " is quine" join quackery ]
This nest creates a Quackery word called quine that creates a copy of itself.
this
-- put a copy of the nest it is in (a nest is items bounded by [
and ]
) on the stack.unbuild
-- decompile the item on the top of stack.$ " is quine"
-- put the string literal " is quine" on the top of stack.join
-- concatenate top two items.quackery
-- compile and evaluate ToS. (quackery
is defined as [ build do ] is quackery
)This revision created on Thu, 14 Nov 2024 21:19:35 by GordonCharlton (chanced "under" to "around" for the sake of accuracy.)