Skip to content

Instantly share code, notes, and snippets.

(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)
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) {
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);
}
(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)
(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)))
//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)
//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)
$ 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
(defproject blackjack "0.1"
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0"]]
:namespaces [helloworld])
$ 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