Convert some Python code to C++
Loic Mahe
loic.mahe at nospam.fr
Wed Nov 14 06:42:59 EST 2007
meyousikmann at yahoo.com a écrit :
> For those that understand algorithms and can talk Python, I want to
> convert the Python code in the section "Reading out all LCSs" into C++
> code but I don't understand some of the syntax. Can anyone give me a
> hand?
>
> def backTrackAll(C, X, Y, i, j):
> if i == 0 or j == 0:
> return set([""])
> elif X[i-1] == Y[j-1]:
> return set([Z + X[i-1] for Z in backTrackAll(C, X, Y, i-1,
> j-1)])
> else:
> R = set()
> if C[i][j-1] >= C[i-1][j]:
> R.update(backTrackAll(C, X, Y, i, j-1))
> if C[i-1][j] >= C[i][j-1]:
> R.update(backTrackAll(C, X, Y, i-1, j))
> return R
>
> Thanks!
>
just have a look at this tutorial: and look for Lists and Sets
http://docs.python.org/tut/tut.html
and look in the reference index for set() and list() in
http://docs.python.org/lib/genindex.html
or just pick the algo in another language in the url you give
or tell us precisely what part of the python algo you do not understant!
More information about the Python-list
mailing list