Question

Write a function split [list, $s]$ that takes two lists as arguments. The first list, list, is any list, the second list, $s$, is a list of nonnegative integers. The result should be the partitioning of the first list into sublists whose lengths are given by the elements of $s$ in turn. (Table Cant Copy) This partitioning is possible only if the sum of the elements of $s$ is equal to the length of list. Formally, the result of $$ \operatorname{split}\left[\left\{e_1, e_2, \ldots, e_n\right\},\left\{s_1, s_2, \ldots, s_m\right\}\right] $$ is equal to $$ \left\{\left\{e_1, \ldots, e_{s_1}\right\},\left\{e_{s_1+1}, \ldots, e_{s_1+s_2}\right\}, \ldots,\left\{e_{s_1+\ldots+s_{m-1}+1}, \ldots, e_{s_1+\ldots+s_m}\right\}\right\}, $$ with $n=s_1+\ldots+s_m$.

   Write a function split [list, $s]$ that takes two lists as arguments. The first list, list, is any list, the second list, $s$, is a list of nonnegative integers. The result should be the partitioning of the first list into sublists whose lengths are given by the elements of $s$ in turn.
(Table Cant Copy)
This partitioning is possible only if the sum of the elements of $s$ is equal to the length of list. Formally, the result of
$$
\operatorname{split}\left[\left\{e_1, e_2, \ldots, e_n\right\},\left\{s_1, s_2, \ldots, s_m\right\}\right]
$$
is equal to
$$
\left\{\left\{e_1, \ldots, e_{s_1}\right\},\left\{e_{s_1+1}, \ldots, e_{s_1+s_2}\right\}, \ldots,\left\{e_{s_1+\ldots+s_{m-1}+1}, \ldots, e_{s_1+\ldots+s_m}\right\}\right\},
$$
with $n=s_1+\ldots+s_m$.
Show more…
Computer science with Mathematica: theory and practice for science, mathematics, and engineering
Computer science with Mathematica: theory and practice for science, mathematics, and engineering
Roman Maeder 1st Edition
Chapter 8, Problem 2 ↓

Instant Answer

verified

Step 1

```python def split(lst, s): ```  Show more…

Show all steps

lock
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
Write a function split [list, $s]$ that takes two lists as arguments. The first list, list, is any list, the second list, $s$, is a list of nonnegative integers. The result should be the partitioning of the first list into sublists whose lengths are given by the elements of $s$ in turn. (Table Cant Copy) This partitioning is possible only if the sum of the elements of $s$ is equal to the length of list. Formally, the result of $$ \operatorname{split}\left[\left\{e_1, e_2, \ldots, e_n\right\},\left\{s_1, s_2, \ldots, s_m\right\}\right] $$ is equal to $$ \left\{\left\{e_1, \ldots, e_{s_1}\right\},\left\{e_{s_1+1}, \ldots, e_{s_1+s_2}\right\}, \ldots,\left\{e_{s_1+\ldots+s_{m-1}+1}, \ldots, e_{s_1+\ldots+s_m}\right\}\right\}, $$ with $n=s_1+\ldots+s_m$.
Close icon
Play audio
Feedback
Powered by NumerAI
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever