~jasper/type_stack_calc

ref: 6aca66fb1a7cf1e10f7dd3263f04537c8ff37590 type_stack_calc/type_stack_calc/util/types_eq.py -rw-r--r-- 351 bytes
6aca66fb — Jasper den Ouden Apparently `to_c` can already read ahead one, hopefully its this simple... 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
def types_key(stack):
    """Makes a key from a stack"""
    return tuple(a.tkey for a in stack)

def types_eq(stack_a, stack_b):
    """See if two stacks have the same types."""
    return types_key(stack_a) == types_key(stack_b)

def types_keyval(dict):
    return tuple((key, types_key(dict[key]))
                 for key in sorted(dict.keys()))