TypeScript 类型系统## TypeScript 类型系统 分享人:陈文岗 学校:中国科学院大学 2021年1月21日 ## 关于TypeScript TypeScript是微软推出的JavaScript静态类型版本,它是JavaScript的超集,可以编译为纯粹的JavaScript TypeScript How Does TypeScript Work? TypeScript file.ts JavaScript jpg) ## TypeScript 基础类型 // 数字类型 let num: number; num = 123; // 布尔类型 let flag: boolean; flag = false; // 字符串类型 let str: string; str = 'Hello World'; ## TypeScript 高级类型 // 数组类型 let arr: number]; arr 'chenwengang', age: 23 }; // 函数类型/函数签名 type Callback = () => void; let cb:Callback = () => { console.log('callback'); }; ## TypeScript 高级类型 // 交叉类型 type User1 = { name: string;0 码力 | 25 页 | 1.27 MB | 2 年前3
5 刘知杭 静态类型的Python## 静态类型的Python PYTHON 30th Lyzh(刘知杭) ## 目录 CONTENTS ➤ 有关类型的概念 使用mypy对Python源代码进行静态分析 代数数据类型 拓展知识 ## 关于类型的一些基本概念 有类型不等于有类型系统 PYTHON 30th 动态语言类型化的必要性 ## 不久前的一个案例 ☀️ ☀️ ☁️ rl = filter(lambda x: HttpResponse(json.dumps(rl), content_type='application/json') ## 类型的概念 CPython定义了PyObject这个结构体作为对象头。 CPython中的类型,是指在对象头中指向类型元信息的指针。 ## ●●● // cpython/include/object.h #define PyObject_HEAD PyObject CPython有类型,但CPython没有类型系统。这就是CsPython中诸多问题的由来。 ## 类型系统是什么? 类型系统(type system)是一种编译期(Compile-time)的类型推导检查规则。 类型系统(type system)的基本目标是防止程序在运行时发生类型错误。当且仅当语言运行时不存在任何形式的类型错误,那么它就是sound的。soundness是类型系统研究的重要目标。0 码力 | 42 页 | 6.87 MB | 2 年前3
The Idris Tutorial Version 0.99manipulated like any other value. The standard example is the type of lists of a given length $ {}^{1} $ , Vect n a, where a is the element type and n is the length of the list and can be an arbitrary term. When therefore give the following type to the app function, which concatenates vectors: app : Vect n a -> Vect m a -> Vect (n + m) a This tutorial introduces Idris, a general purpose functional programming Idris library, by importing Data.Vect, or we can declare them as follows: data Vect : Nat -> Type -> Type where Nil : Vect Z a (::) : a -> Vect k a -> Vect (S k) a Note that we have used the0 码力 | 182 页 | 1.04 MB | 2 年前3
基本数据类型## PyTorch ## 基本数据类型 主讲人:龙良曲 ## All is about Tensor |python|PyTorch| |---|---| |Int|IntTensor of size()| |float|FloatTensor of size()| |Int array|IntTensor of size \[d1, d2, ...]| |Float array|FloatTensor0 码力 | 16 页 | 1.09 MB | 2 年前3
MoonBit月兔编程语言 现代编程思想 第四课 多元组, 结构体,枚举类型# 现代编程思想 多元组,结构体与枚举类型 Hongbo Zhang 基础数据类型:多元组与结构体 ## 回顾:多元组 • 多元组:固定长度的不同类型数据的集合 ☐ 定义: $ (\leq $ 表达式 $ \gt $ , $ \leq $ 表达式 $ \gt $ , $ \geq $ ) ☐ 类型:(<表达式类型>,<表达式类型>,...) ○ 例如: ■ 身份信息:("Bob" == 2023 • 列表:任意长度的相同类型数据的集合 ○ 例如: ■ 字符的序列:Cons('H', Cons('i', Cons('!', Nil))) Cons : construct 的缩写 ## 笛卡尔积 - 一个多元组类型的元素即是每个组成类型的元素构成的有序元素组。集合的笛卡尔积,又称积类型 。例:扑克牌的所有花色: $ \{ $ postal: Int } 通过名称,我们能明确数据的信息以及对应字段的含义 ## 结构体的定义 - 结构体的定义形如 struct <结构体名称> { <字段名>: <类型> ; ... } o struct PersonalInfo { name: String; age: Int} • 定义结构体的值时,形如 { <字段名>: <值>0 码力 | 26 页 | 435.86 KB | 2 年前3
C++高性能并行编程与优化 - 课件 - 10 从稀疏数据结构到量化数据类型{ int x = -7 >> 2; printf("%d\n", x); } 1 ## 位运算 >> 对负数的处理 signed 类型的 >> n 会把最高位复制 n 次。 因为补码的特性,这导致负数 >> 的结果仍是负数。 这样就实现了和 Python 一样的始终向下取整除法。 ## 11001010 printf("%d\n", x); } -2 ## unsigned 类型的位运算 >> 不一样 而 unsigned 类型的 >> n 会不会复制最高位, 只是单纯的位移,这会导致负数的符号位单独被位 移,补码失效,造成结果不对。 unsigned 类型的 >> 会生成 shr 指令,signed 类型的 >> 会生成 sar 指令。 我们需要负方向无限延伸的稀疏数据结果,那就只要 2; } bate::timing("main"); return 0; } ## 使用 int64_t :每个占据 8 字节 • 如果用更大的数据类型,用时会直接提升两倍! 这是因为 i%2 的计算时间,完全隐藏在内存的超高延迟里了。 - 可见,当数据量足够大,计算量却不多时,读写数据量的大小唯一决定着你的性能。 - 特别是并行以后,计算量可以被并行加速,而访存却不行。0 码力 | 102 页 | 9.50 MB | 2 年前3
MoonBit月兔编程语言 现代编程思想 第五课 数据类型:树、二叉树、二叉搜索树、AVL树R-Tree:存储空间几何结构 · ..... ## 数据结构:二叉树 - 二叉树要么是一棵空树,要么是一个节点;它最多具有两个子树:左子树与右子树。 - 叶节点的两个子树都是空树 • 基于递归枚举类型的定义(本节课默认存储数据为整数) 1. enum IntTree { 2. Node(Int, IntTree, IntTree) // 存储的数据,左子树,右子树 3. Empty0 码力 | 29 页 | 1015.26 KB | 2 年前3
Mypy 1.10.0+dev Documentationtype Any are present within your codebase. ## --cobertura-xml-report DIR Causes mypy to generate a C键类型 XML type checking coverage report. To generate this report, you must either manually install the lxml are present within your codebase. cobertura_xml_report Type: string Causes mypy to generate a C键类型 XML type checking coverage report. To generate this report, you must either manually install the lxml0 码力 | 318 页 | 270.84 KB | 2 年前3
Idris 语言文档 Version 1.3.1引言 在传统编程语言中,类型与值之间有明确的区分。例如在 Haskell 中,下面这些类型分别表示整数、字符、字符列表以及任意值的列表: • Int, Char, [Char], [a] 与此对应,下面这些值分别为上述类型的成员: • 42, ' a', "Hello world!", [2,3,4,5,6] 然而,在带有依赖类型(Dependent Ty Type)的语言中,它们的区别并不明显。依赖类型允许类型「依赖」于值,换句话说,类型是一等(First-Class)的语言构造,即它可以像值一样进行操作。标准范例就是带长度的列表类型 $ ^{1} $ Vect n a,其中 a 为元素的类型,而 n 为该列表的长度且可以任意长。 当类型包含了描述其性质的值(如列表的长度)时,它就能描述函数自身的性质了。比如连接两个列表的操作,它拥有性质:结果列表 的长度为两个输入列表的长度之和。因此我们可以为 app 函数赋予如下类型,它用于连接向量(Vector): app : Vect n a -> Vect m a -> Vect (n + m) a 本教程介绍了 Idris,一个通用的依赖类型函数式编程语言。Idris 项目旨在为可验证的通用编程打造一个依赖类型的语言。为此,Idris 被设计成了编译型语言,目的在于生成高效的可执行代0 码力 | 224 页 | 2.06 MB | 2 年前3
The Idris Tutorial
Version 1.3.3manipulated like any other value. The standard example is the type of lists of a given length $ ^{1} $ , Vect n a, where a is the element type and n is the length of the list and can be an arbitrary term. When therefore give the following type to the app function, which concatenates vectors: app : Vect n a -> Vect m a -> Vect (n + m) a This tutorial introduces Idris, a general purpose functional programming Idris library, by importing Data.Vect, or we can declare them as follows: data Vect : Nat -> Type -> Type where Nil : Vect Z a (::) : a -> Vect k a -> Vect (S k) a Note that we have used the0 码力 | 66 页 | 627.66 KB | 2 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100













