#🔒 lambda calculus interpreter in python

6 messages · Page 1 of 1 (latest)

tribal ruin
#

im making a custom lambda calculus interpreter using python, but I can’t figure out how to actually run the lambda code
like it is in traditional lambda calculus
the current code is just my way of taking in input code from a developer
heres my current code:

line = 0
word = 1
variables = []
uses = []
w_ignore = 0
l_ignore = 0
print("Enter your code (press Enter twice to finish):")

while running:
ans = input() # Get user input
if ans == "": # Check for an empty line to break the loop
break
temp = ans.split(" ")
code.append(temp)

while running:
print(code)
print("Now that your code exists, would you like to:")
print("Type 'r' to run")
print("Type 'e' to edit")
print("Type 'f' to finish")
print("Warning: finishing will make the game run every time the code is opened.")
print("You can't edit anymore. I would recommend copying this file.")
ans = input()

if ans == "e":
    print(code)
    print("Type the number of the line you wish to edit")
    line = int(input())
    print("Do you wish to overwrite the line or just change one word?")
    print("Type 'o' to overwrite, otherwise type the number of the word you wish to change")
    ans = input()
    if ans == "o":
        print("Type the new code for the line here")
        ans = input()
        temp = ans.split(" ")
        code[line] = temp
        print(code)
    else:
        word = int(ans)
        print("Type the word here")
        ans = input()
        code[line][word] = ans
elif ans == "r":
    for line in range(len(code[1])):
        if l_ignore <= 0:
            for word in range(len(code[line][1])):
                if w_ignore <= 0:
                    if code[line][word] == "#":
                        w_ignore = 2
                        
                
                w_ignore = w_ignore - 1
        l_ignore = l_ignore - 1
pure thornBOT
#

@tribal ruin

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

hot scroll
#

!code

pure thornBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

pure thornBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.