This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Grammar/Tokens b/Grammar/Tokens | |
index 618ae81..29bcfeb 100644 | |
--- a/Grammar/Tokens | |
+++ b/Grammar/Tokens | |
@@ -11,6 +11,7 @@ RPAR ')' | |
LSQB '[' | |
RSQB ']' | |
COLON ':' | |
+FUNC_SIGN '=>' | |
COMMA ',' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httpx | |
content = httpx.get("https://philosophy-quotes-api.glitch.me/quotes/author/Rumi") | |
quotes = content.json() | |
print(quotes) | |
from string import ascii_letters | |
name_letters = ascii_letters + "_" | |
NAME_CASES = [("some_name", "some_name"), ("some ", "some"), ("some}", "some")] | |
def tokenize_name(text, i): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generator1 = (a for a in [1, 2, 3, 4]) | |
generator2 = (a for a in [1, 2, 3]) | |
for x1, x2 in zip(generator1, generator2): | |
print(x1, x2) | |
remainder = next(generator1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dis | |
# Run this with python3 : ) | |
class VM: | |
def __init__(self): | |
self.stack = [] | |
def push(self, value): | |
self.stack.append(value) | |
def pop(self): | |
return self.stack.pop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def put_mines(m, n, minecount): | |
flat_area = ["*"]*minecount + [0]*((m*n)-minecount) | |
random.shuffle(flat_area) | |
return [ | |
flat_area[i:i+n] | |
for i in range(0, m*n-n+1, n) | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python | |
>>> map(int, ['10', '20', '30']) | |
[10, 20, 30] | |
# Clojure | |
user=> (map #(Integer/parseInt %) (list "10", "20", "30")) | |
(10 20 30) | |
# Scala | |
scala> Array("10", "20", "30").map(Integer.parseInt) |