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
# This example assumes binary operators, but this is easy to extend. | |
# Comes from this excellent article: http://blog.reverberate.org/2013/07/ll-and-lr-parsing-demystified.html | |
ops = { | |
"+": (lambda a, b: a + b), | |
"-": (lambda a, b: a - b), | |
"*": (lambda a, b: a * b), | |
"/": (lambda a, b: a / b) | |
} | |
def eval(expression): |
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
// BynaryTree.cs | |
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
// all code copy pasted in haste |
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
#list construction | |
my_dict = dict() | |
for l in lists: | |
for name in lst: | |
my_dict[name] = my_dict.get(name, 0)+1 | |
# dict.get(key, default) return value associated with key or default if none is found |