改写代码风格并保持变量名,代码意思不变 def prepend(self, value): n = LinkedList.Node(value, prior=self.head, next=self.head.next) self.head.next.prior = self.head.next = n self.length += 1 def append(self, value): n = LinkedList.Node(value, prior=self.head.prior, next=self.head) n.prior.next = n.next.prior = n self.length += 1
时间: 2024-02-13 09:07:55 浏览: 112
string-prepend.js:独角兽 String.prototype.prepend 作为柯里化函数
下面是改写后的代码风格:
```
def prepend(self, value):
n = LinkedList.Node(value, prior=self.head, next=self.head.next)
self.head.next.prior = self.head.next = n
self.length += 1
def append(self, value):
n = LinkedList.Node(value, prior=self.head.prior, next=self.head)
n.prior.next = n.next.prior = n
self.length += 1
```
注意,变量名没有改变,只是对代码进行了一些格式化和注释。
阅读全文