skechers是什么牌子| 什么叫心脏早搏| 感冒可以吃什么水果好| 到付是什么意思| 女性阴毛变白是什么原因| 缺血吃什么补血最快| 院士相当于什么级别| 塑料五行属什么| 码子是什么意思| 牙神经痛吃什么药| 茉字五行属什么| 红细胞偏低有什么危害| 七情六欲是什么意思| 什么颜色的衣服最防晒| 骨质疏松是什么意思| 二院是什么医院| 罪对什么| 试管都有什么方案| polo villae是什么档次| 乙肝肝炎表面抗体阳性是什么意思| 人情世故什么意思| 澳大利亚属于什么气候| 话费为什么扣那么快| 夏至有什么习俗| 龟奴是什么| 骨量减少是什么意思| 高血压吃什么降的快| 上报是什么意思| 月经量少吃什么好| 前列腺增大伴钙化灶是什么意思| gummy是什么意思| 樱桃什么时候成熟| 珍珠米是什么米| 晚上睡觉放屁多是什么原因| 乳腺3类是什么意思| 鸡是什么动物| 喝什么茶去火排毒祛痘| 月经后期是什么意思| 7月6号是什么星座| 男人都喜欢什么样的女人| 风热感冒什么症状| 慰安妇是什么意思| 异性朋友是什么意思| 上火了吃什么食物降火| 肠胃炎吃什么药效果好| 前列腺吃什么药见效快| 兔死狐悲指什么生肖| 5月26号什么星座| 肾结石看病挂什么科室| 民不聊生是什么意思| 吃皮蛋不能和什么一起吃| 7月10号是什么星座| 组织是什么意思| 纸可以做什么| 平均血小板体积偏高是什么意思| 什么水果对眼睛好| 柝什么意思| 光谱是什么| 王八和乌龟有什么区别| 同样的药为什么价格相差很多| 属猪的幸运颜色是什么| lh是什么意思啊| 疱疹用什么药好得快| 电势是什么| 榴莲吃了对身体有什么好处| 和衣是什么意思| 红糖有什么功效| 整夜做梦是什么原因| 虐恋是什么意思啊| 母公司是什么意思| 古代男宠叫什么| 生日送什么| 受罪是什么意思| 广东有什么市| 3a是什么| 尿酸查什么项目| 收官之作什么意思| 前列腺炎吃什么中药| 干咳嗽无痰是什么原因| 贪恋是什么意思| 武的部首是什么| 心口疼吃什么药| 舌尖有裂纹是什么原因| 舌强语謇是什么意思| 牙体牙髓科看什么| 背疼是什么原因引起的女人| 杨梅什么时候上市| 什么叫多重耐药菌| 肾阳虚吃什么药最好最有效| 臀位是什么意思| 什么的飞翔| 莲蓬吃了有什么好处| 绣球花什么时候修剪| 什么药通便最快| sage是什么颜色| 胃酸多吃什么药| 吃什么利尿最快去腹水的| 口腔扁平苔藓吃什么药好得快| 肾功能四项检查什么| 美联储加息意味着什么| 吃什么可以增强抵抗力和免疫力| 周瑜是一个什么样的人| hpv阳性是什么意思| 月经不调吃什么药调理最好| m蛋白是什么| 吃维生素e软胶囊有什么好处| 芒果和什么不能一起吃| hpv59阳性是什么意思| 盆腔积液吃什么消炎药| 蓝莓是什么味道| 古驰属于什么档次| 218是什么星座| 梦见嫂子是什么意思| 股癣用什么药膏| 风是什么结构| 说女人强势是什么意思| 为什么姓张的不用说免贵| 美国现在什么季节| 侧记是什么意思| 什么什么为什么| 黄疸高对婴儿有什么影响| 皮肚是什么| 超标是什么意思| 运动出汗多是什么原因| 什么食物含叶酸| 女生食指戴戒指什么意思| 什么叫比例| 什么是局限性肺纤维化| 狗皮膏药是什么意思| semir是什么牌子| 久视伤血是什么意思| aug是什么意思| 血沉高意味着什么意思| 前列腺液和精液有什么区别| 防弹衣为什么能防弹| bunny是什么意思| 中风是什么原因引起的| 肌酐高什么原因| 睡觉被口水呛醒是什么原因| 多愁善感的动物是什么生肖| 温饱是什么意思| 6.4是什么星座| 肺栓塞的主要症状是什么| 赵本山什么时候去世的| 来月经前头痛什么原因| 尼姑庵是什么意思| 支气管炎吃什么药好| 平均分是什么意思| 卡介疫苗什么时候打| 混油皮是什么特征| 早醒是什么原因造成的| p是什么意思医学| 折耳根是什么| 外阴有白色的东西是什么| 集体户口和个人户口有什么区别| 狮子座女和什么星座最配| 一个木一个舌读什么| 320是什么意思| 3.1号是什么星座| 男人吃洋葱有什么好处| 有什么故事| 高血压需要注意些什么| 奶粉二段和三段有什么区别| 糖尿病患者可以吃什么水果| 什么叫直男| 面包糠是什么做的| 朗朗原名叫什么| 小别胜新婚是什么意思| 鲜卑人是现在的什么人| 双鱼座上升星座是什么| 什么是癣| 7月30日是什么星座| 潆是什么意思| 孕期阴道炎可以用什么药| 42属什么| 检查幽门螺旋杆菌挂什么科| 什么是rpa| 业力什么意思| 天津有什么玩的| 什么人不怕冷| 女人男相有什么说法| 女人40不惑什么意思| 什么食物胆固醇高| 肉桂属于什么茶类| 柏读什么| 硕是什么意思| 红色加蓝色是什么颜色| 脸上长毛什么原因| 甲状腺属于什么科| 倒三角是什么意思| 澄面是什么面粉| 嗳气和打嗝有什么区别| 诺言背叛诺言是什么歌| 山西为什么叫山西| hr什么意思| 飞行模式和关机有什么区别| 阴虱卵长什么样图片| 结膜炎挂什么科| apn是什么意思| gpt是什么| 椎间盘轻度膨出是什么意思| ipv是什么疫苗| 茉莉花茶有什么功效| 爱好是什么意思| 孩子鼻子流鼻血是什么原因| 肌肉僵硬是什么原因| 痰多是什么原因| 秦始皇原名叫什么| 补气血吃什么水果| 碳酸钙是什么东西| 蜂蜜不能和什么食物一起吃| 急性扁桃体炎吃什么药| 什么的玻璃| 息影是什么意思| 吃什么容易长胖| 副巡视员是什么级别| 古尔丹代价是什么| 木有什么意思| 喝酒脸红是什么原因造成的| 猪胰是什么东西| 痔疮吃什么消炎药| 三级手术是什么意思| 子宫肌瘤是什么原因导致的| ecmo是什么| 私处变黑是什么原因| 财主代表什么生肖| 什么是五谷| 1994年是什么年| 鼻窦炎的症状是什么| 脖子大是什么原因| 更年期提前是什么症状| 不怕流氓什么就怕流氓有文化| 酸菜鱼放什么配菜好吃| 扎是什么意思| 为什么会子宫内膜增厚| 什么是夜店| 4月29号是什么星座的| 性格内敛是什么意思| 西元前是什么意思| 五马分尸是什么意思| 无料案内所是什么意思| 特别容易饿是什么原因| 什么是伟哥| 上火了吃什么降火最快| tap什么意思| 第二性征是什么意思| 牙龈长期出血是什么原因| 河粉是什么| 汗斑是什么样的图片| 38年属什么生肖| 小青柑是什么茶类| 世界上最大的昆虫是什么| pearl是什么意思| 阑尾炎什么症状| 肺火吃什么中成药| 台风什么时候到福建| 玄色是什么颜色| 石头五行属什么| 去痛片又叫什么名| 靶身高是什么意思| 非布司他片是什么药| 胆固醇是什么东西| 梦见出血是什么征兆| 有冬瓜西瓜南瓜为什么没有北瓜| 百度

中建信息的生态数学题,以及选择题

百度 区级行政权力事项调整目录在区政府政务网、区机构编制委员会办公室网公布。

ML (Meta Language) is a general-purpose, high-level, functional programming language. It is known for its use of the polymorphic Hindley–Milner type system, which automatically assigns the data types of most expressions without requiring explicit type annotations (type inference), and ensures type safety; there is a formal proof that a well-typed ML program does not cause runtime type errors.[1] ML provides pattern matching for function arguments, garbage collection, imperative programming, call-by-value and currying. While a general-purpose programming language, ML is used heavily in programming language research and is one of the few languages to be completely specified and verified using formal semantics. Its types and pattern matching make it well-suited and commonly used to operate on other formal languages, such as in compiler writing, automated theorem proving, and formal verification.

ML
ParadigmMulti-paradigm: functional, generic, imperative
Designed?byRobin Milner, others at the University of Edinburgh
First?appeared1973; 52?years ago?(1973)
Typing disciplineInferred, static, strong
Dialects
Caml, OCaml, Standard ML, F#
Influenced by
ISWIM
Influenced
Caml, Clojure, Coq, Cyclone, C++, Elm, F#, F*, Haskell, Idris, Kotlin, Miranda, Nemerle, Opa, Erlang, Rust, Scala, Standard ML

Overview

edit

Features of ML include a call-by-value evaluation strategy, first-class functions, automatic memory management through garbage collection, parametric polymorphism, static typing, type inference, algebraic data types, pattern matching, and exception handling. ML uses static scoping rules.[2]

ML can be referred to as an impure functional language, because although it encourages functional programming, it does allow side-effects[3] (like languages such as Lisp, but unlike a purely functional language such as Haskell). Like most programming languages, ML uses eager evaluation, meaning that all subexpressions are always evaluated, though lazy evaluation can be achieved through the use of closures. Thus, infinite streams can be created and used as in Haskell, but their expression is indirect.

ML's strengths are mostly applied in language design and manipulation (compilers, analyzers, theorem provers), but it is a general-purpose language also used in bioinformatics and financial systems.

ML was developed by Robin Milner and others in the early 1970s at the University of Edinburgh,[4] and its syntax is inspired by ISWIM. Historically, ML was conceived to develop proof tactics in the LCF theorem prover (whose language, pplambda, a combination of the first-order predicate calculus and the simply typed polymorphic lambda calculus, had ML as its metalanguage).

Today there are several languages in the ML family; the three most prominent are Standard ML (SML), OCaml and F#. Ideas from ML have influenced numerous other languages, like Haskell, Cyclone, Nemerle,[5] ATS, and Elm.[6]

Examples

edit

The following examples use the syntax of Standard ML. Other ML dialects such as OCaml and F# differ in small ways.

Factorial

edit

The factorial function expressed as pure ML:

fun fac (0 : int) : int = 1
  | fac (n : int) : int = n * fac (n - 1)

This describes the factorial as a recursive function, with a single terminating base case. It is similar to the descriptions of factorials found in mathematics textbooks. Much of ML code is similar to mathematics in facility and syntax.

Part of the definition shown is optional, and describes the types of this function. The notation E?: t can be read as expression E has type t. For instance, the argument n is assigned type integer (int), and fac (n?: int), the result of applying fac to the integer n, also has type integer. The function fac as a whole then has type function from integer to integer (int -> int), that is, fac accepts an integer as an argument and returns an integer result. Thanks to type inference, the type annotations can be omitted and will be derived by the compiler. Rewritten without the type annotations, the example looks like:

fun fac 0 = 1
  | fac n = n * fac (n - 1)

The function also relies on pattern matching, an important part of ML programming. Note that parameters of a function are not necessarily in parentheses but separated by spaces. When the function's argument is 0 (zero) it will return the integer 1 (one). For all other cases the second line is tried. This is the recursion, and executes the function again until the base case is reached.

This implementation of the factorial function is not guaranteed to terminate, since a negative argument causes an infinite descending chain of recursive calls. A more robust implementation would check for a nonnegative argument before recursing, as follows:

fun fact n = let
  fun fac 0 = 1
    | fac n = n * fac (n - 1)
  in
    if (n < 0) then raise Domain else fac n
  end

The problematic case (when n is negative) demonstrates a use of ML's exception system.

The function can be improved further by writing its inner loop as a tail call, such that the call stack need not grow in proportion to the number of function calls. This is achieved by adding an extra, accumulator, parameter to the inner function. At last, we arrive at

fun fact n = let
  fun fac 0 acc = acc
    | fac n acc = fac (n - 1) (n * acc)
  in
    if (n < 0) then raise Domain else fac n 1
  end

List reverse

edit

The following function reverses the elements in a list. More precisely, it returns a new list whose elements are in reverse order compared to the given list.

fun reverse [] = []
  | reverse (x :: xs) = (reverse xs) @ [x]

This implementation of reverse, while correct and clear, is inefficient, requiring quadratic time for execution. The function can be rewritten to execute in linear time:

fun 'a reverse xs : 'a list = List.foldl (op ::) [] xs

This function is an example of parametric polymorphism. That is, it can consume lists whose elements have any type, and return lists of the same type.

Modules

edit

Modules are ML's system for structuring large projects and libraries. A module consists of a signature file and one or more structure files. The signature file specifies the API to be implemented (like a C header file, or Java interface file). The structure implements the signature (like a C source file or Java class file). For example, the following define an Arithmetic signature and an implementation of it using Rational numbers:

signature ARITH =
sig
        type t
        val zero : t
        val succ : t -> t
        val sum : t * t -> t
end
structure Rational : ARITH =
struct
        datatype t = Rat of int * int
        val zero = Rat (0, 1)
        fun succ (Rat (a, b)) = Rat (a + b, b)
        fun sum (Rat (a, b), Rat (c, d)) = Rat (a * d + c * b , b * d)
end

These are imported into the interpreter by the 'use' command. Interaction with the implementation is only allowed via the signature functions, for example it is not possible to create a 'Rat' data object directly via this code. The 'structure' block hides all the implementation detail from outside.

ML's standard libraries are implemented as modules in this way.

See also

edit

References

edit
  1. ^ Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17(3):348–375, 1978.
  2. ^ Milner, Robin; Tofte, Mads (1991). "4.1 Contexts, environments and scope". Commentary on Standard ML. The MIT Press. pp.?35–36. ISBN?0-262-63137-7.
  3. ^ Sebesta, Robert (1999). Concepts of Programming Languages (4th?ed.). Addison-Westley. p.?54. ISBN?0-201-38596-1.
  4. ^ Gordon, Michael J. C. (1996). "From LCF to HOL: a short history". Retrieved 2025-08-08.
  5. ^ Programming language for "special forces" of developers, Russian Software Development Network: Nemerle Project Team, retrieved January 24, 2021
  6. ^ Tate, Bruce A.; Daoud, Fred; Dees, Ian; Moffitt, Jack (2014). "3. Elm". Seven More Languages in Seven Weeks (Book version: P1.0-November 2014?ed.). The Pragmatic Programmers, LLC. pp.?97, 101. ISBN?978-1-941222-15-7. On page 101, Elm creator Evan Czaplicki says: 'I tend to say "Elm is an ML-family language" to get at the shared heritage of all these languages.' ["these languages" is referring to Haskell, OCaml, SML, and F#.]

Further reading

edit
edit
一九八三年属什么生肖 任达华属什么生肖 李子树苗什么品种好 紫外线是什么意思 白介素高说明什么
泄气的意思是什么 脑供血不足吃点什么药 六神无主是什么意思 地瓜不能和什么一起吃 白带呈绿色是什么原因
2022是什么年 老婆的弟弟叫什么 终亡其酒的亡是什么意思 婚动是什么意思 天地不仁以万物为刍狗是什么意思
阳历10月是什么星座 存货是什么 十多块钱的烟什么好抽 胰岛素是干什么用的 11.6号是什么星座
7月4日什么星座hcv9jop1ns6r.cn 什么化妆品好用哪个牌子的hcv8jop4ns7r.cn 今年80岁属什么生肖hcv8jop0ns0r.cn 名列前茅是什么生肖hcv8jop2ns7r.cn 幽门螺旋杆菌什么症状hcv8jop0ns8r.cn
身上起红疙瘩是什么hcv8jop7ns1r.cn 人设是什么意思cj623037.com dce是什么溶剂hcv9jop2ns4r.cn 什么样的人着床晚dajiketang.com 摸头是什么意思mmeoe.com
波立维什么时间吃最好hcv8jop1ns5r.cn 为什么喝完酒头疼hcv9jop2ns3r.cn 钙化灶什么意思hcv8jop4ns3r.cn 舌苔发白是什么原因hcv9jop3ns2r.cn 淋巴炎挂什么科hcv8jop2ns3r.cn
白羊座的幸运色是什么wuhaiwuya.com 水洗标是什么hcv8jop8ns1r.cn 案例是什么意思hcv9jop1ns7r.cn 女人三十如狼四十如虎什么意思hcv8jop5ns9r.cn zf是什么意思bjhyzcsm.com
百度