This file contains hidden or 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
(declaim (optimize (speed 3) (safety 0) (debug 0))) | |
(defvar *earth-radius* (the fixnum 6371)) | |
(defun degree-to-radian (deg) | |
(declare (type single-float deg) | |
(optimize (speed 3) (safety 0) (debug 0))) | |
(the single-float (* deg (/ (coerce pi 'single-float) 180)))) | |
(defun distance (lata lnga latb lngb) |
This file contains hidden or 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
import java.util.Calendar; | |
public class DistancePrimitives { | |
//note: I'm using floats since that's what I did in Lisp. | |
//The program runs in about the same time using doubles | |
private static final float PI = (float)Math.PI; | |
private static final int RADIUS = 6371; | |
public static float degreeToRadian(float degree) { |
This file contains hidden or 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
import java.util.Calendar; | |
public class DistanceObjects { | |
private static final Float PI = new Float(Math.PI); | |
private static final int RADIUS = 6371; | |
public static Float degreeToRadian(Float degree) { | |
return degree * (PI/180f); | |
} | |
This file contains hidden or 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
(declaim (optimize (speed 3) (safety 0) (debug 0))) | |
(defvar *earth-radius* (the fixnum 6371)) | |
(defun degree-to-radian (deg) | |
(declare (type single-float deg) | |
(optimize (speed 3) (safety 0) (debug 0))) | |
(the single-float (* deg (/ (coerce pi 'single-float) 180)))) | |
(defun distance (lata lnga latb lngb) |
This file contains hidden or 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
(defvar *earth-radius* (the fixnum 6371)) | |
(defun degree-to-radian (deg) | |
(declare (type single-float deg) | |
(optimize (speed 3) (safety 0) (debug 0))) | |
(the single-float (* deg (/ (coerce pi 'single-float) 180)))) | |
(defun distance (lata lnga latb lngb) | |
(declare (type single-float lata lnga latb lngb) | |
(optimize (speed 3) (safety 0) (debug 0))) |
This file contains hidden or 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
//per David Beazley's suggestion modified the import statements | |
//yielding a ~25% improvement | |
from math import * | |
import time | |
radius = 6371 | |
def distance(latA, lngA, latB, lngB): | |
latAr = math.radians(latA) | |
lngAr = math.radians(lngA) |
This file contains hidden or 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
//per David Beazley's suggestion modified the import statements | |
//yielding a ~25% improvement | |
from math import * | |
import time | |
radius = 6371 | |
def distance(latA, lngA, latB, lngB): | |
latAr = radians(latA) | |
lngAr = radians(lngA) |
This file contains hidden or 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
$ lein deps | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from central | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from clojure | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from clojure-snapshots | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from clojars | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from central | |
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from central | |
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from clojure | |
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from clojure-snapshots | |
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from clojars |
This file contains hidden or 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
(defproject blackjack "0.1" | |
:dependencies [[org.clojure/clojure "1.1.0"] | |
[org.clojure/clojure-contrib "1.1.0"]] | |
:namespaces [helloworld]) |
This file contains hidden or 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
$ lein deps | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from central | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from clojure | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from clojure-snapshots | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from clojars | |
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from central | |
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from central | |
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from clojure | |
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from clojure-snapshots | |
Downloading: org/clojure/clojure-contrib/1.1.0/clojure-contrib-1.1.0.pom from clojars |