@shirleyquirk:

Sorry, I somehow missed seeing your reply:

> I've only seen them (predecessor functions - GBG) based upon church pairs 
> before, what was your inspiration?

I got it [from Wikipedia Church 
Encoding](https://en.wikipedia.org/wiki/Church_encoding#Calculation_with_Church_numerals)
 as follows: `pred = \ n f x -> n (\ g h -> h (g f)) (const x) id` in Haskell 
notation.

> Purely cosmetically speaking, I think all the -chuch suffixes are 
> distracting. And i thought about cleaning up some of the meta boiler plate...

Different strokes, and you are particularly adept at the use of Nim macros and 
templates.

> Which for me is a syntax I shall now stare at until I understand what 
> wizardry is going on...

It's taken me quite a while to grok it ;-) The `g h` function sets up the 
conditions to reduce the argument `n` by one function in the composed chain, 
and the last two applications take care of whether `n` is zero or not, with the 
first application reducing the function chain if it is not zero and the second 
meaning the when the argument `n` is zero then zero is returned.

> (in C++ -GBG) What is [&](){return y} able to do that proc(x:auto):auto = 
> return y can't do?

Can't help you there, as I've turned my back on C++ for quite some time. I take 
most interest in functional languages now, other than Nim.

I've [now implemented a new RosettaCode Church 
Numerals](https://rosettacode.org/wiki/Church_numerals#Almost_Functional_Version)
 that doesn't use casting/punning at all by using Nim's Variant Objects, and 
this also works in a lot of other languages although in some, one needs to 
emulate these...

Reply via email to