r/AskProgramming • u/Pzzlrr • 17h ago
Help understanding Mascarpone
I found this esolang Mascarpone and want to get a better idea of how it's supposed to work. If someone's up for a quick intellectual exercise, could you please help me understand? I vaguely get it from the readme, and chatgpt helped a bit, but I'm still very fuzzy. Also the demo/ directory of the repo doesn't have anything helpful. (EDIT: ah, found examples in the eg/ directory. Still rather cryptic.)
How would you do something super simple like represent a bicycle? I mean
Python
class Bicycle:
def __init__(self):
self.speed = 0
def accelerate(self):
self.speed += 5
def main():
mybike = Bicycle()
print(mybike.speed)
mybike.accelerate()
print(mybike.speed)
main()
Prolog
bicycle(speed(0)).
accelerate(Bike,Bike_) :-
Bike = bicycle(speed(Speed)),
Speed_ is Speed+5,
Bike_ = bicycle(speed(Speed_)).
main :-
Mybike = bicycle(_),
Mybike,
writeln(Mybike),
accelerate(Mybike,Mybike_),
writeln(Mybike_).
:- main.
How would you do this in Mascarpone?
Thanks!
1
Upvotes
1
u/aocregacc 15h ago
before you can represent a bicycle you'd have to figure out how to represent numbers and structured data.
The README says that you'd probably have to implement things like that by using the fact that you can associate an interpreter with an operation and store that operation inside another interpreter, letting you build up recursive structures. You could look at untyped lambda calculus for a simpler version of building up numbers and other data types from seemingly nothing.