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.
精彩评论