Question 3: Remove All
Implement a function remove_all that takes a Link, and a value, and remove any list node containing that value. You can assume the list already has at least one node containing value and the first element is never removed. Notice that you are not returning anything, so you should mutate the list.
def remove_all(link , value):
"""Remove all the nodes containing value. Assume there exists some
nodes to be removed and the first element is never removed.
>>> l1 = Link(0, Link(2, Link(2, Link(3, Link(1, Link(2, Link(3)))))))
>>> print_link(l1)
<0 2 2 3 1 2 3>
>>> remove_all(l1, 2)
>>> print_link(l1)
<0 3 1 3>
>>> remove_all(l1, 3)
>>> print_link(l1)
<0 1>
"""
"*** YOUR CODE HERE ***"
Use OK to test your code:
python3 ok -q remove_all
I won't make your homework, faggot.
I'm sorry OP, but I only program in assembly via smoke signals, I can't help you there
CS is unfortunately a meme because of people like OP
>>7926064
>doing data structures in anything other than C/C++
Absolutely disgusting.
>>7926064
(define remove_all (lambda (value link)
(if (empty? link) '()
(if (equal? (car link) value)
(remove_all value (cdr link))
(cons (car link) (remove_all value (cdr link)))))))
even works when you remove the head
>not tail recursive
(define remove_all (lambda (value link)
(define remove_all_tail (lambda (value link result)
(if (empty? link) result
(if (equal? (car link) value)
(remove_all_tail value (cdr link) result)
(remove_all_tail value (cdr link) (append result (list (car link)))))))) (remove_all_tail value link '()))
>>7926734
CS was always a meme. It was shit from the very beginning. CS brought nothing of value compared to engineering.
Why are guys not using the best language for list processing in such tasks?
usage: 123123\n1
output: 2323
>>>>,----------[++++++++++[->+>+<<]>[-<+>]>>+>,----------],[-<[<<<-<]>>>>[>>>>]<<<]<[<<<[[-]>+<]>[->[-<<+>>]<]>[-]<<<]>>>>[<<<[.[-]]>>>>>>>]
>>7926064
Is this a joke?
>>7927811
CS is science
>>7927818
No, but that question is like day one programming 101 shit
you may as well ask sci if an electron is positive or negative
also the sticky
>>7927824
what if electron was neutral, and all other particles are actually positive or double-positive
>>7927840
what if python wasn't a piece of shit?
>>7927843
as plausiable as electrons being neutral
i dont think anyone on this board can do CS problems or math problems.
everyone has no confidence. they dont want to be the first person to get it wrong.
math majors dont even have confidence on a fucking anonymously message board.
>>7927870
you are implying that they can solve CS problems.
The reason they are silent is becaust they have no answers
>>7927818
polsci is science