Python Forum
Having hard time understanding the function self-returning itself twice
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Having hard time understanding the function self-returning itself twice
#2
One could have better named the parameters as
def subsetsRecur(self, chosen, candidates):
    ...
This function returns the list of all subsets containing all the chosen items plus some of the candidates. This list will be the sum of two lists: the list of all subsets containing all the chosen items plus some of the candidates but the first candidate, and the list of all subsets containing all the chosen items and the first candidate plus some of the remaining candidates.

That is the meaning of this sum of two lists. Of course there is a special case when the list of candidates is empty. In this case, there is only one subset, the list of chosen items, and the function returns a list containing this single subset.
Reply


Messages In This Thread
RE: Having hard time understanding the function self-returning itself twice - by Gribouillis - Aug-15-2020, 07:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Hard time trying to figure out the difference between two strings carecavoador 2 724 Aug-16-2023, 04:53 PM
Last Post: carecavoador
  return next item each time a function is executed User3000 19 2,466 Aug-06-2023, 02:29 PM
Last Post: deanhystad
  Understanding a function ebolisa 3 833 Jul-14-2023, 06:03 PM
Last Post: snippsat
  Understanding venv; How do I ensure my python script uses the environment every time? Calab 1 2,393 May-10-2023, 02:13 PM
Last Post: Calab
  Why my function is returning None? PauloDAS 6 1,876 Jul-17-2022, 11:17 PM
Last Post: Skaperen
  time function does not work tester_V 4 3,133 Oct-17-2021, 05:48 PM
Last Post: tester_V
  Why recursive function consumes more of processing time than loops? M83Linux 9 4,368 May-20-2021, 01:52 PM
Last Post: DeaD_EyE
  Pausing and returning to function? wallgraffiti 1 2,195 Apr-29-2021, 05:30 PM
Last Post: bowlofred
  Can you end the Time.sleep function boier96 9 9,711 Jan-16-2021, 10:09 PM
Last Post: Serafim
  Why is the function returning None for a * b instead of number? omm 10 4,442 Nov-05-2020, 01:17 PM
Last Post: omm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020