@@ -57,7 +57,7 @@ def evaluate(ast, env=None):
5757 "list" , "append" , "index" , ">" , "<" , ">=" , "<=" , "==" , "!=" ,
5858 "true" , "false" , "&" , "|" , "sqrt" , "pow" , "mod" , "abs" ,
5959 "len" , "reverse" , "concat" , "strlen" , "substr" ,
60- "fn" , "call" , "native" , "use" , "return"
60+ "fn" , "call" , "native" , "use" , "return" , "max" , "min" , "&" , "|" , "not" , "push-front" , "print" , "range"
6161 ] # we are transitioning from putting builtings in the KW to the core and lib folder
6262
6363 E = lambda x : evaluate (x , env ) # lambda func cause it looks cool and does stuff xD
@@ -109,6 +109,9 @@ def evaluate(ast, env=None):
109109 if token == "pow" : return math .pow (E (ast [idx + 1 ]), E (ast [idx + 2 ]))
110110 if token == "sqrt" : return math .sqrt (E (ast [idx + 1 ]))
111111 if token == "abs" : return abs (E (ast [idx + 1 ]))
112+ if token == "max" : return max (E (ast [idx + 1 ]), E (ast [idx + 2 ]))
113+ if token == "min" : return min (E (ast [idx + 1 ]), E (ast [idx + 2 ]))
114+
112115
113116 # comapritives
114117 if token == ">" : return E (ast [idx + 1 ]) > E (ast [idx + 2 ])
@@ -121,6 +124,8 @@ def evaluate(ast, env=None):
121124 # logic
122125 if token == "&" : return bool (E (ast [idx + 1 ]) and E (ast [idx + 2 ]))
123126 if token == "|" : return bool (E (ast [idx + 1 ]) or E (ast [idx + 2 ]))
127+ if token == "not" : return not E (ast [idx + 1 ])
128+
124129
125130 # return as in return
126131 if token == "return" : raise _Return (E (ast [idx + 1 ]))
@@ -132,6 +137,20 @@ def evaluate(ast, env=None):
132137 env [name ] = value
133138 return (name , value )
134139
140+ if token == "push-front" :
141+ name = ast [idx + 1 ]
142+ value = E (ast [idx + 2 ])
143+ if not isinstance (env [name ], list ):
144+ raise TypeError
145+ env [name ].insert (0 , value )
146+ return env [name ]
147+
148+ #for print
149+ if token == "print" :
150+ val = E (ast [idx + 1 ])
151+ print (val )
152+ return val
153+
135154 # Array stuff
136155 # list for initiating a dynamic array
137156 if token == "list" :
@@ -293,7 +312,12 @@ def evaluate(ast, env=None):
293312 exec (code , NATIVE_GLOBALS , native_locals )
294313 env .update (native_locals )
295314 return None
296-
315+ if token == "range" :
316+ args = [E (a ) for a in ast [idx + 1 :]]
317+ if len (args ) == 1 :
318+ return list (range (args [0 ]))
319+ return list (range (args [0 ], args [1 ]))
320+
297321 #finally out of kw hell
298322 elif isinstance (ast , (int , float )):
299323 return ast
0 commit comments