如何将列表附加到 OCaml 中的列表

How to append a List to a List in OCaml

我想附加以下列表:

open Printf
open Format
let l1 = [[0;0];[1;1]]
let l2 = [2;2]
let l3 = l1 @ [ l2 ]
List.iter (fun ll -> printlist ll) l3

l1 应该是 l1 = [[0;0];[1;1];[2;2]]

但每当我尝试 运行 代码时,它都会检索到以下错误:

File "array.ml", line 70, characters 5-7:
70 | l1 @ l2
          ^^
Error: This expression has type int list
       This is not a function; it cannot be applied.

这是问题的解决方案,由 ChrisDutton 提供

open Printf
open Format
open List
let l1 = [[0;0];[1;1]]
let l2 = [2;2]
let l3 = l1 @ [ l2 ]

let () =
  List.iter (fun l -> List.iter print_int l) l3