简体   繁体   English

OCaml的语法是否像Haskell的++?

[英]Does OCaml have syntax like Haskell's ++?

我知道OCaml有List.append,但它有像Haskell的++那样的运算符吗?

For lists: 对于列表:

# (@);;
- : 'a list -> 'a list -> 'a list = <fun>
# [1;2;3] @ [4;5;6];;
- : int list = [1; 2; 3; 4; 5; 6]

For strings: 对于字符串:

# (^);;
- : string -> string -> string = <fun>
# "abc" ^ "def";;
- : string = "abcdef"

Also, you could just say yourself 另外,你可以说自己

let (@) = List.append

or 要么

let (++) = List.append

if noone had yet done it for you in the standard library. 如果还没有人在标准库中为你做过这件事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM