27 lines
452 B
Python
27 lines
452 B
Python
from typing import Any
|
|
|
|
from core.exceptions import syntaxError
|
|
# from core.printer import Representation
|
|
|
|
class LinkedList:
|
|
value = None
|
|
nxt = None
|
|
|
|
def __init__(self, value_, nxt_):
|
|
self.value = value_
|
|
self.nxt = nxt_
|
|
|
|
def car(lst):
|
|
return lst.value
|
|
|
|
def cdr(lst):
|
|
return lst.nxt
|
|
|
|
def cons(val, lst):
|
|
return LinkedList(val, lst)
|
|
|
|
def isList(val):
|
|
return isinstance(val, LinkedList)
|
|
|
|
NIL = cons(None, None)
|