projects
/
soc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2f76a43
)
use join trick instead of manually creating the exponent string
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Mon, 22 Apr 2019 10:10:04 +0000
(11:10 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Mon, 22 Apr 2019 10:10:04 +0000
(11:10 +0100)
TLB/src/LFSR2.py
patch
|
blob
|
history
diff --git
a/TLB/src/LFSR2.py
b/TLB/src/LFSR2.py
index e4d4a5ac2455bdf9a0bbda521aeb01092a5dbc18..3adfc3596276598ba6b4817ec446c16122bcdbcc 100644
(file)
--- a/
TLB/src/LFSR2.py
+++ b/
TLB/src/LFSR2.py
@@
-29,18
+29,15
@@
class LFSRPolynomial(frozenset):
def __str__(self):
exponents = list(self)
exponents.sort(reverse=True)
- retval = ""
- separator = ""
+ retval = []
for i in exponents:
- retval += separator
- separator = " + "
if i == 0:
- retval
+= "1"
+ retval
.append("1")
elif i == 1:
- retval
+= "x"
+ retval
.append("x")
else:
- retval
+= f"x^{i}"
- return retval
+ retval
.append(f"x^{i}")
+ return retval
.join(" + ")
def __repr__(self):
exponents = list(self)