我想附加以下列表:
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