graph - For loops in ocaml -


i want

let switchgraph cases =  let g = graph.makegraph() in let g = (graph.addnode g 1) in = 2 cases      let g = (graph.addnode g i) in done g 

but apparently, not possible. how else can achieve this.

there 2 things need fix:

  • you need use references (see ref, := , !) this, since let bindings immutable
  • to sequence 2 expressions, need use ;

something should work:

let switchgraph cases =     let g = ref (graph.makegraph()) in     g := graph.addnode (!g) 1;     = 2 cases         g := graph.addnode (!g)     done;     !g 

note g reference, , !g value.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -