开发者

Does OCaml have syntax like Haskell's ++?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜