Ejemplo n.º 1
0
def underride(a:tvstruct, b:tvstruct) -> tvstruct:
    answer = tvstruct(a)
    for k, v in b._nvs():
        if k not in answer:
            answer[k] = v
        # answer._setdefault(k, v)      # this doesn't respect insertion order!!
    return answer
Ejemplo n.º 2
0
def override(a:tvstruct, b:tvstruct) -> tvstruct:
    answer = tvstruct(a)
    answer._update(b._nvs())
    return answer
Ejemplo n.º 3
0
def override(a:pydict, b:tvstruct) -> pydict:
    answer = dict(a)
    answer.update(b._nvs())
    return answer
Ejemplo n.º 4
0
def sort(x: tvstruct) -> tvstruct:
    return tvstruct(sorted(x._nvs(), key=None, reverse=False))
Ejemplo n.º 5
0
def count(x:tvstruct) -> tCount:
    return len(x._names())
Ejemplo n.º 6
0
def select(pm: tvstruct, f2) -> tvstruct:
    filteredKVs = []
    for k, v in pm._nvs():
        if f2(k, v): filteredKVs.append((k, v))
    return tvstruct(pm._t, filteredKVs)
Ejemplo n.º 7
0
def both(a:tvstruct, fn, b:tvstruct) -> pylist:
    return a._nvs()  \
        >> both  \
        >> (lambda aFV, bFV: fn(aFV[0], aFV[1], bFV[0], bFV[1]))  \
        >> b._nvs()