-
-
Save tuchk4/7130405338a41a7a91b6de22356c072e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type point = {x: int, y: int}; | |
let coords: list point = []; | |
let printCoords () => List.iter (fun c => Js.log c) coords; | |
let append raw => | |
Array.iter | |
( | |
fun data => { | |
let p = {x: process data.x, y: process data.y}; | |
/* append p to coords */ | |
() | |
} | |
) | |
raw; | |
append data1; | |
append data2; | |
append data3; | |
printCoords (); |
I know this.
I didn't asked how to rewrite this code to make it work.
I am interesting how to be with immutable vars that I need to change(
append data1;
append data2;
append data3;
printCoords ();
append data4;
append data5;
printCoords ();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, you can handle scope by passing a required variable in as a function argument, thus ensuring it's in scope. E.g.: