Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4518 - Fill #12882

Closed
x820745674 opened this issue Jul 11, 2022 · 0 comments
Closed

4518 - Fill #12882

x820745674 opened this issue Jul 11, 2022 · 0 comments
Labels
4518 answer Share answers/solutions to a question en in English

Comments

@x820745674
Copy link

type Fill<
  T extends unknown[],
  N,
  Start extends number = 0,
  End extends number = T['length'],
  L extends 1[] = [],
  IsReplace extends boolean = false
> = Start extends End 
    ? T
    :T extends  [infer Head, ...infer Rest]
    ? L['length'] extends Start
    ? [N, ...Fill<Rest, N, Start, End, [1,...L], true>]
    : L['length'] extends End
    ? [Head, ...Fill<Rest, N, Start, End, [1,...L], false>]
    : [(IsReplace extends true? N : Head), ...Fill<Rest, N, Start, End, [1, ...L], IsReplace>]
    : []
@x820745674 x820745674 added answer Share answers/solutions to a question en in English labels Jul 11, 2022
@github-actions github-actions bot added the 4518 label Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4518 answer Share answers/solutions to a question en in English
Projects
None yet
Development

No branches or pull requests

1 participant