Skip to content

Instantly share code, notes, and snippets.

@rbnpercy
Created November 11, 2019 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbnpercy/2ba5b6902a77371ac78d834bcde93002 to your computer and use it in GitHub Desktop.
Save rbnpercy/2ba5b6902a77371ac78d834bcde93002 to your computer and use it in GitHub Desktop.
import json
let jobj = parseFile("1.json")
let coordinates = jobj["coordinates"].elems
let len = float(coordinates.len)
var x = 0.0
var y = 0.0
var z = 0.0
for coord in coordinates:
x += coord["x"].fnum
y += coord["y"].fnum
z += coord["z"].fnum
echo x / len
echo y / len
echo z / len
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment