首页 > 其他分享 >ts类型体操Concat

ts类型体操Concat

时间:2023-04-16 10:01:51浏览次数:29  
标签:... https _____________ ts Expect 体操 type Concat


/*
  533 - Concat
  -------
  by Andrey Krasovsky (@bre30kra69cs) #easy #array

  ### Question

  Implement the JavaScript `Array.concat` function in the type system. A type takes the two arguments. The output should be a new array that includes inputs in ltr order

  For example:

  ```ts
  type Result = Concat<[1], [2]> // expected to be [1, 2]
  ```

  > View on GitHub: https://tsch.js.org/533
*/

/* _____________ Your Code Here _____________ */

// type Concat<T, U> = [...T,...U]
type Tuple = readonly unknown[];
type Concat<T extends Tuple, U extends Tuple> = [...T, ...U];

/* _____________ Test Cases _____________ */
import type { Equal, Expect } from '@type-challenges/utils'

type cases = [
  Expect<Equal<Concat<[], []>, []>>,
  Expect<Equal<Concat<[], [1]>, [1]>>,
  Expect<Equal<Concat<[1, 2], [3, 4]>, [1, 2, 3, 4]>>,
  Expect<Equal<Concat<['1', 2, '3'], [false, boolean, '4']>, ['1', 2, '3', false, boolean, '4']>>,
]

/* _____________ Further Steps _____________ */
/*
  > Share your solutions: https://tsch.js.org/533/answer
  > View solutions: https://tsch.js.org/533/solutions
  > More Challenges: https://tsch.js.org
*/

标签:...,https,_____________,ts,Expect,体操,type,Concat
From: https://blog.51cto.com/u_15283585/6193330

相关文章

  • ts类型体操 Awaited
    /*189-Awaited-------byMaciejSikora(@maciejsikora)#easy#promise#built-in###QuestionIfwehaveatypewhichiswrappedtypelikePromise.Howwecangetatypewhichisinsidethewrappedtype?Forexample:ifwehave`Promise&l......
  • heatmapts_simple-heatmap的使用
    simpleheat的使用<scriptsetuplang="ts">import{SimpleHeat}from"simpleheat-ts";import*asdatfrom"dat.gui";letframe:number|null=null;constoCanvas=document.createElement("canvas");oCanva......
  • vs 2017编译bootst库
    1.下载boost源码,这里下载boost_1_69_0:boost_1_69_0.7z.2.解压后,已管理员身份打开VS2017的x86_x64兼容工具.例如我的路径是F:F://切换到F盘cdwork\C++\boost_1_69_0执行bootstrap.bat生成b2.exe执行b2.exe--toolset=msvc-14.1install--prefix="D:\Project\Boos......
  • Python模块-requests
    1、requests模块requests模块是python中原生的基于网络请求的模块,其主要作用是用来模拟浏览器发起请求。功能强大,用法简洁高效。2、模块介绍及请求过程requests模块模拟浏览器发送请求请求流程:指定url-->发起请求-->获取响应对象中存储的数据-->持久化存储3、爬取百度首页#!......
  • Default Arguments总结
    默认实参默认实参在C++编程实践中非常常见,但其中也有一些有趣的知识点与扩展,本文对默认实参做简单总结;函数默认实参默认实参用来取代函数调用中缺失的尾部实参:voidProcess(intx=3,inty=4){}拥有默认实参的形参之后的形参必须在同一作用域内有声明提供了默认参数,否则编译......
  • C语言的fgets函数
    fgets是C语言中的一个标准库函数,用于从指定文件中读取一行字符串。它的声明如下:char*fgets(char*str,intn,FILE*stream);其中,str是一个字符数组,用来存储读取的字符串;n表示读取的最大字符数(包括换行符和终止符);stream表示要读取的文件流。fgets函数会从stream中读取字符,直到遇......
  • Python Web全栈工程师「课代表itspcool」
    PythonWeb全栈工程师核心代码,注释必读//下、栽、课、呈茄/:itspcool进入Python世界,打开编程之门Python语法基础一、标识符所谓的标识符就是对变量、常量、函数、类等对象起的名字。首先必须说明的是,Python语言在任何场景都严格区分大小写!Python对于标识符的命名......
  • D. Connected Components
    D.ConnectedComponentshttps://www.codeforces.com/contest/292/problem/D 思路由于需要删除任意连续段的连接线,引入前缀和连续段的左右两边都需要,所以引入两个前缀和。 https://blog.csdn.net/qq_28954601/article/details/79281640Codehttps://blog.csdn.net/q......
  • 67、K8S-部署管理-Helm部署Prometheus、TSDB数据持久化
    Kubernetes学习目录1、准备仓库1.1、配置prometheus仓库1.1.1、增加prometheus仓库helmrepoaddprometheus-communityhttps://prometheus-community.github.io/helm-charts1.1.2、查询增加的结果]#helmrepolistNAMEURL......
  • 前端pdf一次下载多个echarts图表
    //需下载pdf,html2canvas模块savePDF:function(){letobj1=document.getElementById("pieChart");letobj2=document.getElementById("homepage-bandwidth-container");letobj3=document.getElementById("homepage-iops-container");le......