Full functionality.
This commit is contained in:
@@ -132,6 +132,13 @@ class Lisp:
|
|||||||
else:
|
else:
|
||||||
raise ValueError("Undefined variable: " + str(arguments[0]))
|
raise ValueError("Undefined variable: " + str(arguments[0]))
|
||||||
return arguments[0]
|
return arguments[0]
|
||||||
|
case "MAPCAR":
|
||||||
|
if len(arguments) != 3:
|
||||||
|
raise ValueError("Expected 3 arguments")
|
||||||
|
result = []
|
||||||
|
for i in range(0, min(len(arguments[1]), len(arguments[2]))):
|
||||||
|
result.append(self.evaluate([arguments[0], arguments[1][i], arguments[2][i]]))
|
||||||
|
return result
|
||||||
case _:
|
case _:
|
||||||
if operation in self.env.keys():
|
if operation in self.env.keys():
|
||||||
if type(self.env[operation]) == Function:
|
if type(self.env[operation]) == Function:
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import reader
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Welcome message.")
|
print("Welcome to the lisp interpreter! REPL expression results will be stored in an output file, output.txt by default. This can be overridden by passing an argument to the program.\n"
|
||||||
|
"Enter (quit) to exit the program. Supported functionality includes mathematical operations, conditional statements, variables, user-defined functions, logical operations, and list manipulation.")
|
||||||
outputfile = "output.txt" if len(sys.argv) == 1 else sys.argv[1]
|
outputfile = "output.txt" if len(sys.argv) == 1 else sys.argv[1]
|
||||||
interpreter = reader.Reader(outputfile)
|
interpreter = reader.Reader(outputfile)
|
||||||
# REPL Loop
|
# REPL Loop
|
||||||
|
|||||||
Reference in New Issue
Block a user