打印设备常用词汇及其解析
A 字头
编号 缩写 总称 描述
1 APTC Adjustment of Paper Thickness Control 打印厚度自动调整装置
2 AIR Automatic Image Refinement 自动图象修饰
3 ASF Automatic Sheet Feeder 自动送纸器
4 ASIC Application Specific Integrated Circuit 专用集成电路
5 API Application Program Interface 应用程序接口
6 APT Advanced Photo Scale Technology 先进照片比例技术
7 Air Brush 渐变色调
8 ALU 算术逻辑单元
9 AcuLaser Technology 色阶扩展技术(精彩影像激光技术)
10 AGM 交互图形模式
11 AGA Auto Gap adjustment 自动间隙调整
12 ATM Adobe Type Manager 字体管理软件
13 AFP Advanced Function Printing 高级功能打印
14 ASIC Application Specific Integrated Circuit 特定用途集成电路
15 PFM Printer Font Metrics 打印机字库量度
16 AFM Adobe Font Metrics Adobe字库量度
17 ASSY 组件
18 ASA Auto Skew Adjustment 自动纠偏
19 APT Auto Border recognition 自动定边
20 AIS Automatic Interpreter Selection 自动仿真选择
21 Alignment Adjust 成列度调整
B 字头 编号 缩写 总称 描述
1 Bi-directional 双向
2 BIM Bit Image Mode 位图图形方式
3 BJ Bubble Jet 气泡喷射
4 Back Space 退格
5 BOM Bill Of Material 物料清单
6 BLP Bottom Leaded Plastic 底部引出塑封技术
7 BC Business Color 商用彩色
8 Backend Printer 后台打印
9 BPS Bit Per Second 传输速率(位/秒)
10 Bi-Directional Logic Seeking Character,Graphics 双向逻辑查找(选距)
C 字头 编号 缩写 总称 描述
1 CPI Character Per Inch 每英寸打印的字符数,是打印精度的标志
2 CPL Character Per Line 每行打印的字符数,是打印宽度的标志 2 CPS Character Per Second 每秒钟打印的字符数,是打印速度的标志
3 CKD Completely Knocked Down 全拆卸组装方式(零件)
4 CMY(K) 墨盒或打印头为三色(四色)
5 CSF Cut Sheet Feeder 单页送纸器
6 CR Carriage Return 回车
7 Color Seal 彩色覆膜
8 Cut Sheet 单页纸
9 Continuous paper 连续纸
10 Control code 控制码
11 CCS Continuous Charging system
12 COS Chip Operating System 芯片操作系统
13 Cleaning Roller 清洁辊
14 Courier 书信体
15 CPLD Complex PLD 复杂可编程逻辑器件
16 CFF Compact Font Format 压缩字库格式
17 CMS Color Management System 彩色管理系统
18 CRD Color Rendering Dictionary 彩色转换字典
19 CUPS Common UNIX Printing System 通用UNIX 打印系统
20 CTP Computer To Plate 电脑直接制版
21 Character Set 字符集
22 Customization 客户化
23 Code Page 代码页
24 CSS Color Select Set 色选装置
25 CRT Crystal Ray Tube 阴极射线管
26 CUPS Common UNIX Printing System 通用UNIX打印系统
27 CAT Citizen Acoustic Technology 西铁城静音技术
28 Character pitch 字符间距
D 字头 编号 缩写 总称 描述
1 DPI Dot Per Inch 每英寸所打印的点数,是打印精度的标志
2 DF Data Format 数据格式
3 DMP Dot Matrix Printers 点阵打印机
4 DQ Draft Quality 草稿质量
5 DDM Data Dump Mode 数据卸出格式
6 DBCS Double Byte Code System 双字节内码系统
7 Double height printing 倍高打印
8 Double width printing 倍宽打印
9 DIP Dual In Line Package 双列直插式组合开关
10 DDI Device Driver Interface 设备驱动接口
11 DMA Direct Memory Access 直接存储器存取
12 Drum 光鼓
13 Developer Unit 显影器
14 Default 系统出厂(隐含/缺省)设置
15 DCS Desktop Color Seperation 桌面彩色配置
16 DMI Desktop Management Interface 桌面管理接口
17 DMTF Desktop Management Task Force 桌面任务管理
18 Dithering Pattern 抖动模式
19 DTP Desk Top Printer 桌面印刷
20 DDK Device Driver Kit 设备驱动程序开发工具
21 DDS Digital Document Server 数码文档服务器
22 DMR Degree of Make Rows 成行度
23 DMC Degree of Make Columns 成列度
24 DDI Device Driver Interface 设备驱动程序接口
25 DCDL Double Choose the Distance to Logics 双向逻辑选距
26 DPA Document Printing Application 文件打印应用
27 DSP Digital Signal Processing 数字信号处理
28 Duty Ratio 占空比
E 字头 编号 缩写 总称 描述
1 Emulation 兼容/仿真
2 Energy Star 能源之星
3 EDS Electric Dual Switches 电子设置开关(EEPROM存储)
4 Elite 12CPI
5 EPI Element Per Inch 每英寸像素
6 EET Panasonic的边缘增强技术
7 ESC/P-K Epson Standard Code Kanji Epson针式打印机控制命令集 9 ESC/P-K2 ESC/P-K的增强版本(汉字打印控制、定位移动等)
8 ESC/P Epson Standard Code Page Epson激光打印机页面描述语言
9 ESC/P2 ESC/P增强版本,具有平滑变倍字体功能
10 EDO Extended Data Out DRAM 扩展数据输出动态存储器
11 ECP Extended Capabilities Port 扩展型并行接口
12 EPP Enhanced Parallel Port 增强型并行接口
13 EMC Electro Magnetic Compatibility 电磁兼容性
14 ECO Economize on Energy 节能
15 EP Cartridge Electron Picture Cartridge 电子照相暗盒(包括感光鼓,显影,碳粉)
16 EIO Extended Input Output 增强型输入/输出结构
17 EPLD Erasable Programmable Logic Device 可擦除,可编程逻辑器件
18 EDA Electronics Design Automation 电子设计自动化
19 ECL Escape Code Language 转义码控制语言
20 ESD Electromagnetic Static Discharge 静电放电
21 ESC/POS Epson Standard Code for Point of Sale Epson制定的微打控制命令集
22 EMI Electro Magnetic Interference 电磁干扰
23 EMF Enhanced MetaFiles Format 增强型图元文件
24 EMS Electronic Manufacturing Service 电子制造服务
25 Embed System 嵌入式系统
F 字头 编号 缩写 总称 描述
1 Form Length 页长
2 Form feed 换页
3 Firmware 固件(监控程序)
4 FD Fast Drying 快干
5 FPM Fast Page Mode 快速页模式
6 FM Fast Memory 快擦写存储器
7 FPC Par Point Communications 通信
8 Flat-Bed Printer 平推式打印机
9 Fanfold 连续纸
10 Font 字体
11 FAQ Familiar Question 常见问题解答
12 Fuser Roller 热熔辊(定影)
13 FPGA Field Programmable Gate Array 现场可编门阵列
14 FPOT First Paper Out Time 首页输出时间
15 FPOT First Paper/Print Output Time 首页输出时间
16 FFC 扁平电缆
17 Forward 正向
18 Frame 框架(墙板)
G 字头 编号 缩写 总称 描述
1 GUI Graphical User Interface 图形用户界面
2 GA Graphical Adapter 图形适配器
3 GDI Graphical Device Interface 图形设备界面,是Windows系统打印输出的一种方式,利用主机的处理器和内存来处理打印图象,并直接生成页面描述点阵
4 GSM g/M sq 克/每平方米
5 GPD General Printer Description Windows 2000/XP的 DDK 语言
6 GPC General Printer Characterization 通用打印机特征
7 Gate Array 门阵列
8 GAL Generic Array Logic 通用逻辑阵列
9 GPIO General Purpose Input/Output 通用输入/输出
10 GPIB General Purpose Interface Bus 通用接口总线
11 GPL General Public License 通用公共许可证
H 字头 编号 缩写 总称 描述
1 HCPP 连续/单页打印切换装置
2 HE High End 高档(高端)
3 HRC High Resolution Control 高分辨率控制
4 Half Tone 半色调
5 HSP High Speed Printer 高速打印机
6 Hatching 标注
7 HELPS High-End Laser Print Solutions 高端激光打印解决方案
8 HSD High Speed Draft 高速草体
9 HPS Home Position Sensor 字车初始位置检测器
10 HDK Hardware Development Kit 硬件开发工具(UNIX)
11 HBP Host-based printers 基于主机的打印机
12 HPW Head Pin Waveform 打印针控制信号
13 Heat-Sink 打印头散热罩
I 字头 编号 缩写 总称 描述
1 Imaging Drum 图象光鼓
2 IPP Internet Printing Protocol Internet打印协议
3 Ink Jet Printer 喷墨打印机
4 In House Test 内部测试
5 Ink Cartridge 打印喷头(墨头)
6 IPS Inches Per Second 每秒英寸,是打印机走纸速度的标志
7 IrDA Infrared Data Association 红外线收发器
8 Intelligent Color 智能彩色
9 Initialize 初始化
10 Interface 接口
11 ICC International Color Consortium 国际彩色协会
12 IDE Integrated Device Electronics 集成设备电子部件
13 ISP In System Programmable 系统编程
14 IPDST Intelligent Printing Data Stream 智能打印数据流
15 IRQ Interrupt ReQuest 中断请求
16 IPM Image Per Minute 每分钟打印的页面数
J 字头 编号 缩写 总称 描述
Jet Express
K 字头 编号 缩写 总称 描述
1 KPS Kanji Per Second 每秒钟打印的汉字数,是打印速度的标志
L 字头 编号 缩写 总称 描述
1 LF Line Feed 换行
2 LQ Letter Quality 信函质量
3 LED Light Emitting Diode 发光二极管
4 LCD Light Crystal Display 液晶显示器
5 LCS LCS 液晶光栅
6 LIPS LBP Image Printer System 图象打印系统
7 LPI Line Per Inch 每英寸打印的行数,是打印机打印精度的标志
8 LPM Lines Per Minute 每分钟打印的行数,是打印机打印速度的标志
9 Low End 低档
10 Load Sharing 负载共享
11 LDP Light Duty Printer 轻型打印机
12 Loading position 装入位置
13 LIPS LBP Image Printer System 佳能公司的页面描述语言
14 LBP Laser Beam Printer 激光束打印机
15 Line Spacing 行间距
16 LEE Long life for all printer Engine Elements 所有打印引擎组件的长寿命设计
17 LSB Least Significant Bit 最低有效位
18 LPT Line Printer 并行接口
19 LPD Line Printing Daemon 逐行打印守护程序
M 字头 编号 缩写 总称 描述
1 MTBF Mean Time Between Failures 平均无故障工作时间 (前后两次出现故障的时间间隔)
2 MCBF Mean Character Between Failures 平均无故障打印字符数
3 MTTR Mean Time To Repair 平均修复时间
4 Multi Part 多层纸
5 MAP Micro Art Printing 精制打印技术
6 MAH Multi Lager Actuator Head 多层压电打印头
7 MCI Media Control Interface 媒体控制接口
8 MICR Magnetic Ink Character Recognition 磁墨字符识别,是一种防伪技术,可供支票及存单打印用
9 Mopier Multiple Original Printer 多源打印
10 MET Memory Enhancement Technology 内存增强技术
11 Memory Reduction Technology 内存压缩技术
12 MIF Management Information Format 管理信息格式
13 MFP Multipart Forms Printer 多层套打打印机
14 Micro feed 微调整
15 MDP Micro Dry Process 微干处理
16 MSDN Microsoft Developer Network 微软开发人员网络
17 MFP Multi-Function Peripheral 多功能设备
18 MTPL Mannesmann Tally Printer Language
19 MAC Media Access Control 媒体存取控制
20 MSB Most Significant Bit 最高有效位
21 MOQ Minmum Order Quantity 最小定货量
22 MDT Minidriver Development Tools 小型驱动程序开发工具
N 字头 编号 缩写 总称 描述
1 NIC Netware Interface Card 网络接口卡
2 Nibble Mode 半字节方式
3 NLQ Near LQ 近似信函体
4 NPM Network Printing Management 网络打印管理
5 NG Not Good 不良
6 NMI Non Maskable Interrupt 不可屏蔽中断
O 字头 编号 缩写 总称 描述
1 OEM Original Equipment Manufacture 原始设备制造厂家
2 ODM Original Design Manufacture 原始设计厂家
3 On Site Test 现场测试
4 On Line 在线、联机
5 Overlapping Form 叠头表格
6 OSM Output System Manager 打印和封装一体化
7 OPC Organic Photo Conductor 有机光电导体(感光鼓)
8 OPC Belt Cartridge 带型感光鼓
9 OTP One Time Programmable 一次性编程
10 OCF Original Composite Format 原创复合型格式
11 OBF Open Box Fail 开箱检测不合格
12 OTP On Demand Print 按需打印
13 Opto-Electro-Mechanical 光-机-电
P 字头 编号 缩写 总称 描述
1 Page Skip 跳页
2 PES Page End Sensor 缺纸传感器
3 PPM Page-Per-Minute 每分钟打印机打印的页数,是打印机打印速度的标志
4 PPH Page-Per-Hour 每小时打印机打印的页数,是打印机打印速度的标志
5 PCL Printer Control Language HP的激光打印机控制语言,利用打印机自己的处理器芯片和内存
6 Pget Lexmark的分辨率增强技术
7 PDL Page Descriptional Language 页面描述语言
8 Paper Feed 换页
9 Paper Out 缺纸
10 PPDS Personal Printer Data Stream IBM打印标准
11 PPS Pulse Per Second 每秒脉冲数
12 PQ Print Quality 打印质量
13 Platform 平台
14 Pre Loaded 预装载
15 P&P Plug and Play 即插既用
16 Photo Enhancement Mode 照片增强模式
17 Photo Grade 灰度级照片增强技术
18 Photo-Ret 照片增强技术
19 Photo-Real 照片增强技术
20 Post Script 三次曲线字库描述技术
21 PPC 普通复印纸
22 Pitch 字间距
23 Platen 卷轴
24 PCB Printed Circuit Board 印刷电路板
25 Proportional Printing 比例打印
26 PPD Post Script Printer Description PS打印机描述
27 POD Print On Demand 按需打印
28 PIM Print Image Matching 全真数码影象打印技术
29 Prestige 公文体
30 Print Density 打印浓度
31 Printable Area 可打印区域
32 PLD Programmable Logic Device 可编程逻辑器件
33 PLA Programmable Logic Array 可编程逻辑阵列
34 PES Paper Edge Sensor 纸边检测器
35 PGS Platen Gap Sensor 打印辊间隙检测器
36 PPP The Point-to-Point Protocol 点到点协议
37 PPI Pixels Per Inch 每英寸的像素数
38 PFM Printer Font Metrics 点阵字体描述
39 PFB Printer Font Binary 向量字体描述
40 PS TBCP Post Script Tagged Binary Communication Protocol PS 标记二进制通信协议 41 PHY Physical layer 物理层
42 PDF Portable Document Format 便携文件格式
43 PPIO Public-document Printing In Office 面向商务领域的打印输出
44 POH Power On Hours 通电时间
45 PDM Product Data Management 产品数据管理
46 PWM Pulse Width Modulation 脉宽调制
47 PPS Pulse Per Second 每秒脉冲数
48 PLM Product Life-Cycle Management 产品生命周期管理
49 Proto Type 样机
50 Pull Up 上拉
51 Pull Down 下拉
52 Paper Tension Button 紧纸器
53 Paper Eject Button 退纸器
Q 字头 编号 缩写 总称 描述
1 Quad Dot 四分之一点
2 QFP Quad Flat Package 四列扁平塑料封装
R 字头 编号 缩写 总称 描述
1 RET Resolution Enhancement Technology 分辨率增强技术
2 RISC Reduced Instruction Set Computer 精简指令集计算机
3 RF Roller Feed 送纸器
4 Reset 复位
5 RMA 工厂维修部门
6 RIP Raster Image Processor 光栅图象处理器(PostScript 解释器)
7 Roman T 罗马(正楷)T形
8 RLF Retrorse Line Feed 逆向换行
9 Ribbon Cassette 色带盒
10 Reverse 反向
11 RAW Raw Image Formats 原始图象数据格式
12 Roll Type 滚筒
13 Roll Paper 卷纸
S 字头 编号 缩写 总称 描述
1 Skew Detect 纸张倾斜检测
2 Skew Level 歪斜度
3 SD Super Draft 高速草体
4 SSD Super Speed Draft 超高速草体
5 SKD Semi-Knocked Down 半拆卸组装方式(部件)
6 SOHO Small Office Home Office 小型办公室,家居办公室
7 SCSI Small Computer System Interface 小型计算机接口
8 SSC Sync Burst SRAM Cache 同步触发静态存储器高速缓存
9 SNMP Simple Network Management Protocol 网络管理协议
10 Solid Ink Printer 固体喷墨(蜡)打印机
11 Selftest 自检
12 Standby position 打印备位
13 Subscript 下标
14 Superscript 上标
15 Slash Zero 零加斜线
16 SBCS Single Byte Code System 单字节内码系统
17 SDK Software Developer Kit 软件开发工具
18 SIDM Serial Impact Dot Matrix 串行击打点阵
19 Sans Serif H 等线体H型
20 Script 手写体
21 Standard Cell 标准单元
22 SLIP Serial Line Internet Protocol 串口IP协议
23 SIMM Single In-Line Memory 单线存储器
24 Solenoid 打印针的励磁线圈
25 Staggered 24* 2 Staggered 24针双列交错式排列方式
26 SRGM Standard Rer Green Blue 色彩语言协定
27 SOP Skip Over Peforation 页缝空白
28 SPP Standard Parallel Port 标准并行端口
29 SPP Straight Paper Process 直线馈纸方式
30 SOC System On Chip 嵌入式系统
31 Single Chip Microcomputer 单片机
32 SPQ Small Production Quantity 最少生产量
33 Simplified Character Font 简体字库
34 Sound Absorbing Sheet 吸音棉
T 字头 编号 缩写 总称 描述
1 TOF Top of Format 页首设置
2 Toner Cartridge 墨粉盒
3 TTF True Type Font 二次曲线字库
4 TIT Thermal Ink Transfer 热熔型热转印
5 TDS Thermal Dye Sublimation 染料升华型热转印
6 T.B.D To be determine 待定
7 Tear off 切纸/撕纸
8 Tear off position 切纸/撕纸位置
9 Top of Page 页顶
10 TCO Total Cost of Ownership 总体拥有成本
11 TSOP Thin Small Outline Package 薄型小尺寸封装
12 TinyBGA Tiny Ball Grid Array 小球型栅阵列封装
13 TCE Total Customer Experience 全面客户体验
14 Transfer Unit 转印部件
15 TCP/IP Transmission Control Protocol/Internet Protocol 网络的传输控制协议/网际协议 16 TTL Transister-Transister-Logic 晶体管-晶体管逻辑电路
17 Timing Belt 同步齿型带
18 Top Cover 上盖
19 Traditional Character Font 繁体字库
20 TPM Total Print Management 整体打印管理
U 字头 编号 缩写 总称 描述
1 Uni-directional 单向
2 UPC Unit Per Character
3 UPP Unit Per Pulse
4 USB Universal Serial Bus 通用串行总线
5 User defined character 用户定义字符
6 UART Universal Asynchronous Receiver Transmitter 通用异步收发器
V 字头 编号 缩写 总称 描述
1
W 字头 编号 缩写 总称 描述
1 WPS Windows Printing System 视窗打印系统
2 Web Smoothing 网页打印质量
3 WDM Windows Driver Mode 视窗驱动模式
4 WTB Waste Toner Box 废粉盒
5 WPD Windows Printer Description 视窗打印机描述
X 字头 编号 缩写 总称 描述
1 XML Extensible Markup Language 可扩展性标记语言
推荐阅读
-
常用缓存技巧及其常见问题解析
-
打印设备常用词汇及其解析
-
新式能通设备:利用固态变压器的能源路由器设计及其流量能量模型解析
-
简单易懂的路由器基础与常用词汇解析
-
微积分——什么是导数- 1.1 “derivative”的词源 作为名词,始于15世纪中期,词义为“a derived word or form, a word formed immediately or remotely from another or a root (派生词或派生形式,直接或者由另一个词或词根组成的词)”,由形容司“derivative (派生的)”转化而来。常用词义“that which is derived or deduced from another(由另一个事物派生或演绎而来的事物)”始于1590年代,其数学意义“a derivative function (导数函数)”始于1670年代。 1.2 “derivative”的数学意义来源 Newton(牛顿)将“derivative”称为“Fluxion(流数)”,即流(flow): f′是“流动的(fluent)”(即“流动的功变化的量”)函数f (牛顿用点号(.)代替上撇号(′)( primes);上撇号(′)( primes)是由拉格朗日(Lagrange)在18世纪末引入的)的“流数(fluxion)”。但是随着莱布尼茨的符号和他基于微分(differentials)的方法被普遍采用,牛顿的这个方便的术语就被废弃了。 函数导数的传统名称曾经称为“微分系数(Differential Coefficient)”。之所以使用这个名称是因为当我们将等式写作df(x)=f′(x)dx时f′(x)是dx(微分)的系数。事实上,在18世比和19世纪早期,数学家们对无穷小微分比微分系数更感兴趣。 然而,随着分析变得越来越严谨,注意力转向了导数f′而不是微分f′(x)dx。认识到,函数导数f′是由函数“导出的、衍生出的、演绎出的、推导出的、等等(derived)”,在语法意义上,名词的复数形式是派生于名词的单数形式。在拉丁语中,动词“dērīvāre”词义为“to lead or draw off (water or liquid), to divert, derive (words)(引导或脱去(水或液体),转移、派生(词汇))”,可以解析为由前缀“dē”(词义为“from(来自)”)+“rīvus”(词义为“*, stream of water(小溪、水流)”)构成。这就是对于函数导数f′“导数函数(derived function)”或者“导数(derivative)”的源头。 尽管“derive”流行用于表示导数计算的动词,大部分数学家喜欢用“微分(differentiate)”表示,例如: “针对x微分, 你将会得到相同的函数。” 1.3 “derivative”中文翻译为“导数” 根据前面的叙述,函数导数f′是由函数“导出的、衍生出的、演绎出的、推导出的、等等(derived)”的意义,中文将其翻译为“导数”。 2. “导数(derivative)”的数学意义
-
F#探险之旅(二):函数式编程(上)-函数式编程范式简介 F#主要支持三种编程范式:函数式编程(Functional Programming,FP)、命令式编程(Imperative Programming)和面向对象(Object-Oriented,OO)的编程。回顾它们的历史,FP是最早的一种范式,第一种FP语言是IPL,产生于1955年,大约在Fortran一年之前。第二种FP语言是Lisp,产生于1958,早于Cobol一年。Fortan和Cobol都是命令式编程语言,它们在科学和商业领域的迅速成功使得命令式编程在30多年的时间里独领风骚。而产生于1970年代的面向对象编程则不断成熟,至今已是最流行的编程范式。有道是“*代有语言出,各领风骚数十年”。 尽管强大的FP语言(SML,Ocaml,Haskell及Clean等)和类FP语言(APL和Lisp是现实世界中最成功的两个)在1950年代就不断发展,FP仍停留在学院派的“象牙塔”里;而命令式编程和面向对象编程则分别凭着在商业领域和企业级应用的需要占据领先。今天,FP的潜力终被认识——它是用来解决更复杂的问题的(当然更简单的问题也不在话下)。 纯粹的FP将程序看作是接受参数并返回值的函数的集合,它不允许有副作用(side effect,即改变了状态),使用递归而不是循环进行迭代。FP中的函数很像数学中的函数,它们都不改变程序的状态。举个简单的例子,一旦将一个值赋给一个标识符,它就不会改变了,函数不改变参数的值,返回值是全新的值。 FP的数学基础使得它很是优雅,FP的程序看起来往往简洁、漂亮。但它无状态和递归的天性使得它在处理很多通用的编程任务时没有其它的编程范式来得方便。但对F#来说这不是问题,它的优势之一就是融合了多种编程范式,允许开发人员按照需要采用最好的范式。 关于FP的更多内容建议阅读一下这篇文章:Why Functional Programming Matters(中文版)。F#中的函数式编程 从现在开始,我将对F#中FP相关的主要语言结构逐一进行介绍。标识符(Identifier) 在F#中,我们通过标识符给值(value)取名字,这样就可以在后面的程序中引用它。通过关键字let定义标识符,如: let x = 42 这看起来像命令式编程语言中的赋值语句,两者有着关键的不同。在纯粹的FP中,一旦值赋给了标识符就不能改变了,这也是把它称为标识符而非变量(variable)的原因。另外,在某些条件下,我们可以重定义标识符;在F#的命令式编程范式下,在某些条件下标识符的值是可以修改的。 标识符也可用于引用函数,在F#中函数本质上也是值。也就是说,F#中没有真正的函数名和参数名的概念,它们都是标识符。定义函数的方式与定义值是类似的,只是会有额外的标识符表示参数: let add x y = x + y 这里共有三个标识符,add表示函数名,x和y表示它的参数。关键字和保留字关键字是指语言中一些标记,它们被编译器保留作特殊之用。在F#中,不能用作标识符或类型的名称(后面会讨论“定义类型”)。它们是: abstract and as asr assert begin class default delegate do donedowncast downto elif else end exception extern false finally forfun function if in inherit inline interface internal land lazy letlor lsr lxor match member mod module mutable namespace new nullof open or override private public rec return sig static structthen to true try type upcast use val void when while with yield 保留字是指当前还不是关键字,但被F#保留做将来之用。可以用它们来定义标识符或类型名称,但编译器会报告一个警告。如果你在意程序与未来版本编译器的兼容性,最好不要使用。它们是: atomic break checked component const constraint constructor continue eager event external fixed functor global include method mixinobject parallel process protected pure sealed trait virtual volatile 文字值(Literals) 文字值表示常数值,在构建计算代码块时很有用,F#提供了丰富的文字值集。与C#类似,这些文字值包括了常见的字符串、字符、布尔值、整型数、浮点数等,在此不再赘述,详细信息请查看F#手册。 与C#一样,F#中的字符串常量表示也有两种方式。一是常规字符串(regular string),其中可包含转义字符;二是逐字字符串(verbatim string),其中的(")被看作是常规的字符,而两个双引号作为双引号的转义表示。下面这个简单的例子演示了常见的文字常量表示: let message = "Hello World"r"n!" // 常规字符串let dir = @"C:"FS"FP" // 逐字字符串let bytes = "bytes"B // byte 数组let xA = 0xFFy // sbyte, 16进制表示let xB = 0o777un // unsigned native-sized integer,8进制表示let print x = printfn "%A" xlet main = print message; print dir; print bytes; print xA; print xB; main Printf函数通过F#的反射机制和.NET的ToString方法来解析“%A”模式,适用于任何类型的值,也可以通过F#中的print_any和print_to_string函数来完成类似的功能。值和函数(Values and Functions) 在F#中函数也是值,F#处理它们的语法也是类似的。 let n = 10let add a b = a + blet addFour = add 4let result = addFour n printfn "result = %i" result 可以看到定义值n和函数add的语法很类似,只不过add还有两个参数。对于add来说a + b的值自动作为其返回值,也就是说在F#中我们不需要显式地为函数定义返回值。对于函数addFour来说,它定义在add的基础上,它只向add传递了一个参数,这样对于不同的参数addFour将返回不同的值。考虑数学中的函数概念,F(x, y) = x + y,G(y) = F(4, y),实际上G(y) = 4 + y,G也是一个函数,它接收一个参数,这个地方是不是很类似?这种只向函数传递部分参数的特性称为函数的柯里化(curried function)。 当然对某些函数来说,传递部分参数是无意义的,此时需要强制提供所有参数,可是将参数括起来,将它们转换为元组(tuple)。下面的例子将不能编译通过: let sub(a, b) = a - blet subFour = sub 4 必须为sub提供两个参数,如sub(4, 5),这样就很像C#中的方法调用了。 对于这两种方式来说,前者具有更高的灵活性,一般可优先考虑。 如果函数的计算过程中需要定义一些中间值,我们应当将这些行进行缩进: let halfWay a b = let dif = b - a let mid = dif / 2 mid + a 需要注意的是,缩进时要用空格而不是Tab,如果你不想每次都按几次空格键,可以在VS中设置,将Tab字符自动转换为空格;虽然缩进的字符数没有限制,但一般建议用4个空格。而且此时一定要用在文件开头添加#light指令。作用域(Scope)作用域是编程语言中的一个重要的概念,它表示在何处可以访问(使用)一个标识符或类型。所有标识符,不管是函数还是值,其作用域都从其声明处开始,结束自其所处的代码块。对于一个处于最顶层的标识符而言,一旦为其赋值,它的值就不能修改或重定义了。标识符在定义之后才能使用,这意味着在定义过程中不能使用自身的值。 let defineMessage = let message = "Help me" print_endline message // error 对于在函数内部定义的标识符,一般而言,它们的作用域会到函数的结束处。 但可使用let关键字重定义它们,有时这会很有用,对于某些函数来说,计算过程涉及多个中间值,因为值是不可修改的,所以我们就需要定义多个标识符,这就要求我们去维护这些标识符的名称,其实是没必要的,这时可以使用重定义标识符。但这并不同于可以修改标识符的值。你甚至可以修改标识符的类型,但F#仍能确保类型安全。所谓类型安全,其基本意义是F#会避免对值的错误操作,比如我们不能像对待字符串那样对待整数。这个跟C#也是类似的。 let changeType = let x = 1 let x = "change me" let x = x + 1 print_string x 在本例的函数中,第一行和第二行都没问题,第三行就有问题了,在重定义x的时候,赋给它的值是x + 1,而x是字符串,与1相加在F#中是非法的。 另外,如果在嵌套函数中重定义标识符就更有趣了。 let printMessages = let message = "fun value" printfn "%s" message; let innerFun = let message = "inner fun value" printfn "%s" message innerFun printfn "%s" message printMessages 打印结果: fun value inner fun valuefun value 最后一次不是inner fun value,因为在innerFun仅仅将值重新绑定而不是赋值,其有效范围仅仅在innerFun内部。递归(Recursion)递归是编程中的一个极为重要的概念,它表示函数通过自身进行定义,亦即在定义处调用自身。在FP中常用于表达命令式编程的循环。很多人认为使用递归表示的算法要比循环更易理解。 使用rec关键字进行递归函数的定义。看下面的计算阶乘的函数: let rec factorial x = match x with | x when x < 0 -> failwith "value must be greater than or equal to 0" | 0 -> 1 | x -> x * factorial(x - 1) 这里使用了模式匹配(F#的一个很棒的特性),其C#版本为: public static long Factorial(int n) { if (n < 0) { throw new ArgumentOutOfRangeException("value must be greater than or equal to 0"); } if (n == 0) { return 1; } return n * Factorial (n - 1); } 递归在解决阶乘、Fibonacci数列这样的问题时尤为适合。但使用的时候要当心,可能会写出不能终止的递归。匿名函数(Anonymous Function) 定义函数的时候F#提供了第二种方式:使用关键字fun。有时我们没必要给函数起名,这种函数就是所谓的匿名函数,有时称为lambda函数,这也是C#3.0的一个新特性。比如有的函数仅仅作为一个参数传给另一个函数,通常就不需要起名。在后面的“列表”一节中你会看到这样的例子。除了fun,我们还可以使用function关键字定义匿名函数,它们的区别在于后者可以使用模式匹配(本文后面将做介绍)特性。看下面的例子: let x = (fun x y -> x + y) 1 2let x1 = (function x -> function y -> x + y) 1 2let x2 = (function (x, y) -> x + y) (1, 2) 我们可优先考虑fun,因为它更为紧凑,在F#类库中你能看到很多这样的例子。 注意:本文中的代码均在F# 1.9.4.17版本下编写,在F# CTP 1.9.6.0版本下可能不能通过编译。 F#系列随笔索引页面