

Church Numerals - jbarrow
https://karczmarczuk.users.greyc.fr/Essays/church.html

======
alexbecker
I like this, but it is yet another page that makes me wonder whether
professors conspire to use the worst possible color palettes for their sites.

~~~
PaulHoule
Also math is a lot quicker in FORTRAN

------
gamegoblin
For anyone who finds this interesting, I cannot recommend enough investing a
half hour in watching the "Programming With Nothing" talk:

[https://www.youtube.com/watch?v=VUhlNx_-
wYk](https://www.youtube.com/watch?v=VUhlNx_-wYk)

In it, the speaker implements fizzbuzz using only lambda calculus (making
significant use of church encoding).

~~~
tomstuart
Thanks! There’s a transcript at [http://codon.com/programming-with-
nothing](http://codon.com/programming-with-nothing), and the FizzBuzz
implementation was recently added to Ruby itself:
[https://github.com/ruby/ruby/commit/628dac1](https://github.com/ruby/ruby/commit/628dac1)

------
tieTYT
To my surprise, the Haskell was not the difficult part for me. I spent more
time wondering why this is the definition of "zero":

    
    
        zero s z = z
    

My understanding is you can call this like so:

    
    
        zero 3 7 #returns 7
    

So.... in what way does this relate to "zero"?

I got to the definition of "one" and that made me realize that `s` is supposed
to a function (because AFAIK, Haskell can only return 1 thing). This doesn't
clarify my initial confusion, but it does make the type definitions a little
more concrete in my head.

Yeah... I'm going to stop reading. I think this could be written better. Maybe
it would be a good reference if I already had a decent grasp of what Church
Numerals are, but I don't.

~~~
gohrt
`zero` doesn't act on integers, it acts on other functions.

The second argument to `zero` is a placeholder. The intuition is that `zero s`
is "apply the function `s` zero times". What do you get if you apply the
function `s` zero times to an argument `z`? You get `z`.

There's a hint later down in the article about type-checking.

~~~
tieTYT
Technically, it can act on integers:

    
    
        Prelude> let zero s z = z
        Prelude> :t zero
        zero :: t -> t1 -> t1
        Prelude>
    

t and t1 can be integers. Really the point of my comment is that the article
could be written much better (assuming I'm the intended demographic).

------
tel
Similar page in style, form, language choice, and even content!

[http://www.willamette.edu/~fruehr/haskell/evolution.html](http://www.willamette.edu/~fruehr/haskell/evolution.html)

It's just a joke instead.

