Skip to content

Instantly share code, notes, and snippets.

@paulvictor
Created January 16, 2019 07:56
Show Gist options
  • Select an option

  • Save paulvictor/e01275e5927bcf632c6b4d320b0e8c7c to your computer and use it in GitHub Desktop.

Select an option

Save paulvictor/e01275e5927bcf632c6b4d320b0e8c7c to your computer and use it in GitHub Desktop.
Translating from python to purs
def func():
i = 0;
j = 0;
for (x in xs)
i = i+1;
if (x.foo == "bar")
j += 1;
else
j += 0;
// At this point, i and j are the variables we are interested in
func = execState
(for_ xs \x -> do
modify_ ({i, j} -> {i: i + 1; j})
modify_ ({i, j} -> {i: i, j: if x.foo == "bar" then j + 1 else j + 0})) {i: 0, j: 0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment