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)
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.
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.
uhhh but im just a student interested in programmming
PS:I have trouble impllementing control structures
Look at the bad repeat while block.it just freezes the page if no range and throwing errors if range specifyed
The problem is in your ?: function. It breaks everything that depends on it; your subtraction didn't work for me, even though its code is correct. I blush that I didn't actually try it before. :~(
You correctly declare the second and third inputs to be of type Any (Unevaluated) because otherwise a recursion will just keep going when it hits its base case. But, having done that, in order to report the value of the chosen branch, you have to CALL whichever branch you choose: