Consider the following Scala code: Consider the following Scala code: def f(coll
ID: 3596224 • Letter: C
Question
Consider the following Scala code:
Consider the following Scala code: def f(collection: List [Int], init-acc: Int): Int = { collection.foldLeft( CI Cl // work which updates the value of in the next iterati acc The following pseudo code represents a similar concept acccollection for ( in-left-to-right // work which updates the value of n the next iteratio Suppose instead we want the analogous pseudo code for foldRight acccollection for in-left-to-right // work which updates the value of in the next iteration init_acc acc in-right-to-left ci collection in-left-to-right CheckExplanation / Answer
Please find my answer
a)
acc = init_acc
for(ci in-left-to-right collection) {
// work which updates the value of acc in the next iterator
}
b)
acc = init_acc
for(ci in-right-to-left collection) {
// work which updates the value of acc in the next iterator
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.