[go: up one dir, main page]

File: gpath.py

package info (click to toggle)
solfege 3.10.3-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,408 kB
  • ctags: 4,270
  • sloc: python: 22,161; xml: 7,536; ansic: 4,442; makefile: 685; sh: 308
file content (24 lines) | stat: -rw-r--r-- 451 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

class Path(tuple):
    def first(self):
        v = list(self)
        v[-1] = 0
        return Path(v)
    def next(self):
        v = list(self)
        v[-1] += 1
        return Path(v)
    def prev(self):
        v = list(self)
        v[-1] -= 1
        return Path(v)
    def child(self):
        v = list(self)
        v.append(0)
        return Path(v)
    def parent(self):
        v = list(self)
        v = v[:-1]
        return Path(v)