开发者

Does OCaml have syntax like Haskell's ++?

开发者 https://www.devze.com 2023-04-10 07:08 出处:网络
I know OCaml has List.a开发者_开发技巧ppend, but does it have an operator like Haskell\'s ++?For lists:

I know OCaml has List.a开发者_开发技巧ppend, but does it have an operator like Haskell's ++?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号