#!/usr/bin/env julia

import JSON

"""
    gen( x, name )

Generate fixture data and write to file.

# Arguments

* `x`: x-values
* `y`: y-values
* `name::AbstractString`: output filename

# Examples

``` julia
julia> x = rand( 2003 ) * 1000.0;
julia> y = rand( 2003 ) * 1000.0;
julia> gen( x, y, \"data.json\" );
```
"""
function gen( x, y, name )
	h = hypot( x, y );

	# Store data to be written to file as a collection:
	data = Dict([
		("x", x),
		("y", y),
		("expected", h)
	]);

	# Based on the script directory, create an output filepath:
	filepath = joinpath( dir, name );

	# Write the data to the output filepath as JSON:
	outfile = open( filepath, "w" );
	write( outfile, JSON.json(data) );
	close( outfile );
end

# Get the filename:
file = @__FILE__;

# Extract the directory in which this file resides:
dir = dirname( file );

# Generate fixture data:
x = rand( 2003 ) * 2000.0 - 1000.0;
y = rand( 2003 ) * 2000.0 - 1000.0;
gen( x, y, "data.json" );

#!/usr/bin/env julia

import JSON

"""
    gen( x, y, name )

Generate fixture data and write to file.

# Arguments

* `x`: x-values
* `y`: y-values
* `name::AbstractString`: output filename

# Examples

``` julia
julia> x = rand( 2003 ) * 1000.0;
julia> y = rand( 2003 ) * 1000.0;
julia> gen( x, y, \"data.json\" );
```
"""
function gen( x, y, name )
	h = hypot( x, y );

	# Store data to be written to file as a collection:
	data = Dict([
		("x", x),
		("y", y),
		("expected", h)
	]);

	# Based on the script directory, create an output filepath:
	filepath = joinpath( dir, name );

	# Write the data to the output filepath as JSON:
	outfile = open( filepath, "w" );
	write( outfile, JSON.json(data) );
	close( outfile );
end

# Get the filename:
file = @__FILE__;

# Extract the directory in which this file resides:
dir = dirname( file );

# Generate fixture data:
x = rand( 2003 ) * 2000.0 - 1000.0;
y = rand( 2003 ) * 2000.0 - 1000.0;
gen( x, y, "data.json" );

Fix fcn signature in docs
Fix fcn signature in docs
