Follow

@wim_v12e just noticed you were doing lambda experiments in uxntal 👀 keep me posted. I've been scratching my head at writing a uxntal implementation of church numerals and it's kicking my butt. Any idea?

· · Web · 2 · 0 · 5

@wim_v12e If you're interested in scratching at this problem, here's this sample Joy program ported to Uxntal as an example:

LIT BRK LIT DUP LIT POP SWP ( i ) [ #00 STR $1 ] ( i ) [ #00 STR $1 ]

dev.to/palm86/church-encoding-

@wim_v12e The Church bools and AND operator in uxntal:

( true #02 ) LIT POP
( false #03 ) LIT NIP
( and ) DUP [ #00 STR $1 ]

@neauoire @wim_v12e
would be

0 ‚ DROP ‚ SWAP EXECUTE EXECUTE

in Forth
(That is ‚ is tick not comma - Mastodon App uses „smart“ quotes. Can I quote code e.g. like in markdown?)
#forth #joy

@neauoire @wim_v12e
With some editing 🙂

0 ‘ DROP ‘ SWAP EXECUTE EXECUTE

Tha is straight apostrophe not backtick

#forth

@neauoire The ( i ) had me puzzled but it's just an inline comment, isn't it?

I think I will change my quoting approach to be more in line with Joy, that might be a good starting point. Then I can implement cat in my system.

What does the $1 do in your AND operation?

@d6 @neauoire What does that mean? Does it add a 0 byte to the program?

@wim_v12e @neauoire yes, it creates a space to write into with the STR instruction (that won't overwrite anything you care about)

@d6 @wim_v12e It's the same as:

$1 = 00
$2 = 0000
$3 = 0000 00
$4 = 0000 0000

I use that close closing strings usually, and for self-modifying code.

@neauoire I was looking at lambda functions, not at the lambda calculus. I was mainly curious to see if I could have anonymous functions and quoting.
I'll have a look though as it is interesting. But you seem to have already done it?

@wim_v12e no, not completely, I have a draft of some things, but I haven't been able to add 2 church numbers together in uxntal yet :<

@neauoire The main difference with Joy is that in Uxntal you can't have quoted lists on the stack. You could of course put them in memory and that is the approach I've taken, but I imagine that is not what to had in mind, because the list manipulation involves counting so it kind of defeats the purpose. Otoh, the VM also needs to count to manage the stack ...

Sign in to participate in the conversation
Merveilles

Revel in the marvels of the universe. We are a collective of forward-thinking individuals who strive to better ourselves and our surroundings through constant creation. We express ourselves through music, art, games, and writing. We also put great value in play. A warm welcome to any like-minded people who feel these ideals resonate with them.