F#中的可变记录:example

时间:2016-01-08 06:34:59

标签: f# record mutable

嗨,我是F#的初学者,还有点挣扎......

我的代码的一部分我有以下

open System.Collections.Generic

// it could be anything
let graph = new Dictionary<int,int seq>()
graph.Add (1,seq [2;3])
graph.Add (2,seq [1])
graph.Add (3,seq [1])

let remove_table = new Dictionary<int,bool>()
remove_table.Add (1,false)
remove_table.Add (2,false)
remove_table.Add (3,false)

let label = new Dictionary<int,int seq>()
label.Add (1,seq [1])
label.Add (2,seq [1])
label.Add (3,seq [1])
// 

type wgraphobj =
     { Graph : Dictionary<int,int seq>
       RemoveTable : Dictionary<int,bool>
       Label : Dictionary<int,int seq>
     }

let WG1 = {Graph = graph;
          RemoveTable = remove_table;
          Label = label;
          }

let WGmin = WG1
通过定义graph,remove_table,label和label_head_table,

WG1在此片段之前定义良好。

如果我在F#中执行代码没有问题

但是如果我编译,我会收到以下错误消息 The value or constructor 'WG' is not defined ???

由于以下算法,我希望WGmin变得可变,我不在乎WG1是否可变(据我所知,我很想知道怎么做WG1不可变)

我收到了与let mutable WGmin = WG1

相同的错误消息

编辑:对不起,这不是问题......我会重新发布...抱歉有问题

0 个答案:

没有答案