This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
(define (change k list1)
(cond((< k 0) 0)
((= k 0) 1)
((null? list) 0)
(else ( (change k (cdr list1))
(change (- k (car list1))
list1)))))
In this code, can someone explain what the else statement is doing? Let's say list1 is (1 2 3 4) So is it adding (change k (2 3 4)) (change(k - 1)) and then it outputs list1? but for k - 1, wouldn't it just have one variable left after you subtract k and 1? This code is supposed to show you the amount of diff answers you can have from a combination. Thank you for your help!! If someone can walk me through line by line too that would mean a lot, thank you!!
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...