projects
/
soc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
17c9a6c
)
replace if elif elif with dictionary trick, and map-plus-lambda
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Mon, 22 Apr 2019 11:14:42 +0000
(12:14 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Mon, 22 Apr 2019 11:14:42 +0000
(12:14 +0100)
TLB/src/LFSR2.py
patch
|
blob
|
history
diff --git
a/TLB/src/LFSR2.py
b/TLB/src/LFSR2.py
index 9cd97c31d8f81961c6a830724a360dd899a107ce..4baf2055db458fc58c17b78faa02caf1a14fe685 100644
(file)
--- a/
TLB/src/LFSR2.py
+++ b/
TLB/src/LFSR2.py
@@
-32,14
+32,8
@@
class LFSRPolynomial(set):
return exponents
def __str__(self):
- retval = []
- for i in self.exponents:
- if i == 0:
- retval.append("1")
- elif i == 1:
- retval.append("x")
- else:
- retval.append(f"x^{i}")
+ expd = {0: "1", 1: 'x', 2: "x^{}"} # case 2 isn't 2, it's min(i,2)
+ retval = map(lambda i: expd[min(i,2)].format(i), self.exponents)
return " + ".join(retval)
def __repr__(self):