Block workarounds (later became :lambda: calculus)


The Alonzo function returns an Church numeral (rounds floats and makes negatives 0) and the Flatten Alonzo function gets it back into Number typed ints.

Hello?Anyone?

btw, :lambda: is lambda, not alonzo. Alonzo is snap's mascot :alonzo:

It's how you represent true in :lambda: calculus
See the If block!
a reply to an absent post :frowning:

This is very nice! Did you look up the arithmetic functions or did you invent them?

The function you call "part of list," which is equivalent to our in front of, is generally called CONS, and the object it reports is called a "pair." Of course you also need the selector functions CAR and CDR.

But the real rite of passage in Church numeralology is to invent subtraction! No fair looking it up. :~)

yes

I'll rename it :slight_smile:

Oh.

I can't look it up either.(no minus function in cheatsheet listed above)
Maybe I can do it like this:
Count the number of F()s (times it will repeat if you push a function to it) and add 1 to number 0 every time except the first (the decrement function)

That's a good idea. Now write the code! :~)

Isn't it just amazing that you don't need arithmetic as primitive in a programming language?

:smiley: I just did it when you posted this.
But Darn Timer

yep
But we need first class functions or rings :~)

Yes. Lambda and call.

And also normal order evaluation (what you get from Unevaluated input types), in order for recursion to work.

Ah, no, no, that's cheating. You don't have SET, just lambda and CALL. That's why it's hard!

ohh


Oh hey,dont I have the list blocks?
I mean cons and car
Made it now :slight_smile:
(b in front of times)

Ah

That's why you had to make CONS, CAR, and CDR!

:slight_smile:
ohhhhh yes
plus i found a way to store a lot of vars in a loop (church nums)
Darn timer forced me to wait a minute

I'm going to sleep, so don't expect an immediate comment on your next pass.

ok
I'll make division function

Brian, I would LOVE to have lesson material from you for Church numerals! I think this would be an AWESOME addition to the materials that we give to teachers and kids. Can we turn it into a CodeWeek activity maybe? THAT's the kind of stuff I'd like to see more!

Here's the BYOB version from a million years ago. I started rewriting it for Snap! a few thousand years ago, but got hung up on the unhelpful behavior of script variables when the same name is declared twice. Then I thought we had reached a compromise, but when we discussed it fairly recently you no longer remembered (?) the compromise that I do remember (?).
church.zip (149.3 KB)
PS @18001767679 no peeking until subtraction is done, purely functionally.

Do you mean division?(minus function has already been done :slight_smile: )

Oh, awesome! Last I saw this you had a stateful decrement function. Great job making it functional. When you're done with arithmetic, you'll have to start in on a serious lambda calculus text. Then you and @theaspiringhacker can start teaching each other.

Because you got to sleep and forgot to reload the page!

Why @theaspiringhacker?

uhhh but im just a student interested in programmming
PS:I have trouble impllementing control structures :frowning:
Look at the bad repeat while block.it just freezes the page if no range and throwing errors if range specifyed