Skip to content

Instantly share code, notes, and snippets.

@ikasoba
Last active April 5, 2022 06:40
Show Gist options
  • Save ikasoba/0179f9a48b876ae960eb0ca1c1939467 to your computer and use it in GitHub Desktop.
Save ikasoba/0179f9a48b876ae960eb0ca1c1939467 to your computer and use it in GitHub Desktop.
Typescriptの再帰型の練習に再帰的にn~0までArray。range(10)としたら10~0の長さ11の配列が出来上がります。
export const range = (i=0)=>[i,...([()=>range(i-1),()=>[]][~~(i<=0)]())]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment