Re: [stack] Barebone implementation of concatenative language in c or c++

<[email protected]> Wed, 12 May 2010 14:28:26 -0500
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Wed, 12 May 2010 18:23:27 -0000, "blazeski" <[email protected]> wrote:

> For example from reading Brent Kerby Theory of concatenative combinators
> http://tunes.org/~iepos/joy.html if I implement : swap, dup, zap, unit,
> cat, cons, i, dip + (numbers and symbols) would that be enough to have a
> primitive joy like language? 

The "classical" base seems to be swap, dup, drop, dip, cons, uncons, null,
and if. These are easy to implement in any sort of extended lambda
calculus
by treating the stack as nested tuples (with ':' as cons and '->,' as
cond):

swap   = \(a, (b, s)). (b, (a, s))
dup    = \(a, s). (a, (a, s))
drop   = \(a, s). s
dip    = \(a, (b, s)). (b, a s)
null   = \s. ([], s)
cons   = \(a, (b, s)). (a:b, s)
uncons = \(a:b, s). (a, (b, s))
if     = \(a, (b, (c, s))). a -> b s, c s

More minimal bases are possible, but the above set is the most direct.

- jn