g | x | w | all
Bytes Lang Time Link
056Red250512T141324ZGalen Iv
012APLNARS250512T090229ZRosLuP
003Uiua240703T124054Znoodle p
009Pyth250218T184125ZGlory2Uk
004Husk210812T113852ZDominic
003Uiua231014T055322Zchunes
004Nekomata231014T150057Zalephalp
036Arturo230117T225002Zchunes
025WolframLanguage Mathematica210807T022421Ztheorist
039PowerShell Core220308T011348ZJulian
002Vyxal210807T013400Zlyxal
008K ngn/k210810T135410Zcoltim
117Desmos210809T062939ZAiden Ch
005MATL210807T123120ZLuis Men
025Julia 1.0210807T202134ZKirill L
003Japt m210807T073734ZShaggy
064Scala210807T174154Zuser
029R >= 4.1210807T061551ZNick Ken
003Jelly210807T012406Zhyperneu
003APL Dyalog Extended210807T013934Zrak1507
034Haskell210807T130318ZWheat Wi
058C gcc210807T130723ZNoodle9
034Haskell210807T130406Zorthocre
044JavaScript ES6210807T063733ZArnauld
010Charcoal210807T103941ZNeil
039Python 2210807T075611Zxnor
4426Ruby210807T064051ZJonah
003Stax210807T062729ZRazetime
00505AB1E210807T054136Zovs
007Brachylog210807T044955Zxash
042Python 2210807T043401Zdingledo
024Factor210807T014336Zchunes
006J210807T014233ZJonah
076Python 3210807T014214Zwasif

Red, 56 bytes

func[s b][collect[forall b[keep/only take/part s b/1]]]	

Try it online!

APL(NARS), 12 chars

{⍺⊂⍨∊⍵⍴¨⍳≢⍵}

Input array to break in ⍺, the array of lenghts in ⍵, where +/⍵ has to be the same number of ≢⍺.

test:

  1 2  3 4 5 6  7 8 9 7 8  {⍺⊂⍨∊⍵⍴¨⍳≢⍵}2 4 5
┌3─────────────────────────────┐
│┌2───┐ ┌4───────┐ ┌5─────────┐│
││ 1 2│ │ 3 4 5 6│ │ 7 8 9 7 8││
│└~───┘ └~───────┘ └~─────────┘2
└∊─────────────────────────────┘
  1 2  3 4 5 6  7 8 9 7 8  {⍺⊂⍨∊⍵⍴¨⍳≢⍵}2 5 4
┌3─────────────────────────────┐
│┌2───┐ ┌5─────────┐ ┌4───────┐│
││ 1 2│ │ 3 4 5 6 7│ │ 8 9 7 8││
│└~───┘ └~─────────┘ └~───────┘2
└∊─────────────────────────────┘

it seems

  2 3 4⍴¨1 2 3
┌3─────────────────────────┐
│┌2───┐ ┌3─────┐ ┌4───────┐│
││ 1 1│ │ 2 2 2│ │ 3 3 3 3││
│└~───┘ └~─────┘ └~───────┘2
└∊─────────────────────────┘

Uiua, 3 bytes

⊕□⊚

Try it online!

Read "group by boxing where".

(where) takes a nonnegative integer list and for each gives that many of the corresponding nonnegative integer:

⊚ [3 2 5 1] # -> [0 0 0 1 1 2 2 2 2 2 3]
            # 3 zeroes, 2 ones, 5 twos, 1 three

⊕□ (group by boxing) takes a nonnegative integer list B and a list A with the same length, and groups the elements of A into boxes based on those indices in B:

⊕□ [0 0 0 1 1 2 2 2 2 2 3] "abcdefghijk"
            # -> {"abc" "de" "fghij" "k"}
            # curly braces mean the items are boxed

Pyth, 9 bytes

fqlMTQ./E

Try it online!

Commented:

      ./E  ## create every possible partition
f          ## filter the partition,
  lMT      ## where the lengths of its elements
 q         ## are equal to
     Q     ## the first input

Husk, 5 4 bytes

CmR¹

Try it online!

CmR¹      # 5-byte program, but this is equivalent to
CzR⁰⁰²    # 6-byte program using the ¹ shortcut to use the 1st arg twice and implicit 2nd arg
 m        # map over
   ⁰      # the list of the 1st argument
  R ⁰     # by repeating arg1 this number of times;
          # now use the lengths of this list of lists to
C    ²    # cut the list of the 2nd argument

Uiua, 5 3 bytes

⊕□⊚

Try it!

-2 thanks to Bubbler

⊕□⊚
  ⊚  # where
⊕□   # group with boxing

Nekomata, 4 bytes

J$ᶻL

Attempt This Online!

J$ᶻL    Input L and R
J       Non-deterministically split L into parts
 $      Swap to get R
  ᶻL    Check that the length of each part is equal to the corresponding element of R

Arturo, 36 bytes

$[a,b][map b'i[take a i a:drop a i]]

Try it

$[a,b][             ; a function taking two arguments a and b
  map b'i[          ; map over b and assign current elt to i
    take a i        ; the first i elts of a
    a:drop a i      ; assign a sans the first i elts to a
  ]                 ; end map
]                   ; end function

WolframLanguage (Mathematica), 28 25 bytes

TakeDrop~FoldPairList~##&

–3 bytes from att.

Try it online!

With the prohibitied built-in (introduced in 2017 with v. 11.2), it's 8 bytes:

TakeList

PowerShell Core, 39 bytes

param($u,$v)$u|%{,$v[$s..(($s+=$_)-1)]}

Try it online!

Two test cases are not working because PowerShell flattens simple jagged arrays, i.e. [[7]] becomes [7]

Vyxal, 2 bytes

ɾ•

Try it Online!

If generators weren't so broken, it'd just be vɾ• and flagless. Thank goodness for Vyxal 2.8 lol.

Explained

ɾ•
ɾ    # vectorise range for each item in the shape list
•   # and mold that to the shape list

So essentially, a port of hyper's jelly

K (ngn/k), 8 bytes

{.=x!&y}

Try it online!

Takes the list of values as x and the lengths of the chunks as y.

Desmos, 128 117 bytes

a=length(B)
g(l)=\sum_{k=1}^{[1...length(l)]}l[k]
f=\prod_{n=1}^a\{g(B)[n]+n=[1...\length(L)+a]:0,1\}
h(L,B)=L[g(f)]f

Implements a function \$h(L,B)\$. Output is a list of numbers, with each sublist separated by a zero.

Try It On Desmos!

Try It On Desmos! - Verbose

Explanation:

a=length(B): A helper value that stores the length of the list B specified in the challenge description.

g(l)=\sum_{k=1}^{[1...length(l)]}l[k]: A helper function that returns the running total(as a list) of the list argument l.

f=\prod_{n=1}^a\{g(B)[n]+n=[1...\length(L)+a]:0,1\}: Creates a list of 0's and 1's, which will be used later to determine the format of the final outputted list(0's mean sublist separator, 1's mean to put an element of L there, where L is specified in the challenge description.).

h(L,B)=L[g(f)]f: The actual function that outputs the answer, with each sublist separated by a zero.

MATL, 5 bytes

"@:&)

Inputs B, then L. Displays each sublist on a separate line.

Try it online!

Explanation

"      % Implicit input: numeric vector B. For each k in B
  @    %   Push k
  :    %   Range [1 2 ... k]
  &)   %   Two-ouput indexing. The first time this takes as implicit input
       %   the numeric vector L; in subsequent iterations it uses as input
       %   what remains of L. Pushes a smaller vector according to the
       %   specified indices, and another vector with the remaining entries
       % Implicit end. Implicit display stack

Julia 1.0, 33 30 25 bytes

l/b=b.|>a->splice!(l,1:a)

Try it online!

Thanks to dingledooper for -3 bytes and to MarcMush to further -5.

Japt -m, 3 bytes

Takes B as the first input.

VvU

Try it

VvU     :Implicit map of each U in first input (B)
V       :Second input (L)
 vU     :Remove and return the first U elements

Scala, 64 bytes

s=>_./:(Seq[Any]()->s){case(a->s,x)=>(a:+s.take(x),s drop x)}._1

Try it online!

Called as f(fullList)(sublistSizes)

s =>   //The sequence of integers to be split
 _     //The sizes for it to be split into
  ./:  //Fold over it,
   (Seq[Any]()->s) //Starting with an empty list of sublists, and the original list
   {case(a->s,x) => //a is the current list of sublists, s is the current full list, x is the current element
    (a:+s.take(x),  //Add the first x elements of s as a sublist
     s drop x)      //Drop x elements from the full list
   }._1             //Only keep the list of sublists

R >= 4.1, 30 29 bytes

\(L,B)split(L,rep(seq(!B),B))

Try it online!

An anonymous function taking two vectors and returning a list of vectors.

Thanks to @pajonk for saving a byte!

Jelly, 3 bytes

Rṁ@

Try It Online!

Equivalently, ṁR} but with the arguments the other way around.

R    Range (vectorizes)
 ṁ@  Mold the right argument to the shape of the ranges
ṁ    Mold the left argument to the shape of:
 R}  Range (vectorizes) of the right argument

APL (Dyalog Extended), 3 bytes

-2 thanks to ovs!

⍸⍛⊆

How does it work?

Firstly ⍸2 4 3 is 1 1 2 2 2 2 3 3 3.

We can then use this to partition () the right argument into chunks.

Try it online!

Haskell, 34 bytes

(zipWith take<*>).scanl(flip drop)

Try it online!

scanl(flip drop) takes the input and sucessively drops off prefixes.

Prelude> scanl(flip drop) "Test string, test string, 123" [6,1,2,3]
[ "Test string, test string, 123"
, "tring, test string, 123"
, "ring, test string, 123"
, "ng, test string, 123"
, " test string, 123"
]

Note that the first result will always be the input string.

Once we have that we apply zipWith take to then take off the prefixes for each size.

C (gcc), 65 58 bytes

f(s,b,l)int*s,*b;{for(;l--;s+=*b++)printf("%.*ls ",*b,s);}

Try it online!

Inputs a pointer to a list of digits as a wide-character string, a pointer to a list of integer lengths and that list's length (since pointers in C carry no length info).
Outputs the sub-lists separated by spaces.

Haskell, 35 34 bytes

x?(c:d)=take c x:drop c x?d
x?_=[]

Try it online!

-1, thanks Wheat Wizard!

JavaScript (ES6), 44 bytes

Expects (a)(b).

a=>g=([v,...b])=>v?[a.splice(0,v),...g(b)]:b

Try it online!

(or 43 bytes with linefeeds)

Charcoal, 10 bytes

≔⮌θθEη⭆ι⊟θ

Try it online! Link is to verbose version of code. Outputs a newline-separated list of digit strings. Explanation:

≔⮌θθ

Reverse L.

Eη⭆ι⊟θ

For each element of B, pop that many elements from L, and concatenate the digits into a string for output.

Python 2, 39 bytes

lambda L,B:[map(L.pop,[0]*x)for x in B]

Try it online!

Ruby, 44 26 bytes

->b,l{b.map{|x|l.shift x}}

Try it online!

-18 thanks to dingledooper

Stax, 3 bytes

m%s

Run and debug it

Takes a string of digits, and the partitions as an integer array.

outputs each slice with a newline.

05AB1E, 5 bytes

I've tried to implement £ manually way too often because the docs just say £ - Head. Push a[0:b], which is exactly what this builtin does if you just pass a single integer.

L˜Å¡¦

Try it online!

L convert each length n into a range [1 .. n]
˜ flatten into a list of integers
Å¡ split the sequence on 1's (the only truthy value in 05AB1E)
¦ remove the leading empty list that was created by splitting at index 0

Brachylog, 7 bytes

~cʰ\l₎ᵐ

Try it online!

~cʰ split the left argument into groups, \ transpose so we have a list of (group, length), l₎ᵐ map each pair: the right element is the length of the left element (which is also the output of l).

Python 2, 42 bytes

Inputs \$ L \$ and \$ B \$ as two comma separated lists from STDIN, and outputs sublists each on one line.

L,B=input()
for x in B:print L[:x];L=L[x:]

Try it online!

Factor, 24 bytes

[ [ cut swap ] map nip ]

Try it online!

Mapping the lengths to the part of the input that gets 'cut off.' Cutting a sequence into two parts and getting at the results is efficient in bytes because both pieces just end up on the data stack, instead of locked away inside some collection. Process looks something like this:

  1. "hello world" { 1 2 3 4 1 }
  2. "ello world" { "h" 2 3 4 1 }
  3. "lo world" { "h" "el" 3 4 1 }
  4. "world" { "h" "el" "lo " 4 1 }
  5. "d" { "h" "el" "lo " "worl" 1 }
  6. "" { "h" "el" "lo " "worl" "d" }
  7. { "h" "el" "lo " "worl" "d" }

J, 6 bytes

</.~I.

Try it online!

Called with the list as left arg, grouping mask as right arg.

The whole thing is a dyadic hook, so that...

Python 3, 76 bytes

def f(x,n):x=iter(x);return[[*islice(x,a)]for a in n]
from itertools import*

Try it online!