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
(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 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
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
(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* 6371) | |
(defun degree-to-radian (deg) | |
(* deg (/ pi 180))) | |
(defun distance (lata lnga latb lngb) | |
(let* ((lata-r (degree-to-radian lata)) | |
(lnga-r (degree-to-radian lnga)) | |
(latb-r (degree-to-radian latb)) | |
(lngb-r (degree-to-radian 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 math | |
import time | |
radius = 6371 | |
def distance(latA, lngA, latB, lngB): | |
latAr = math.radians(latA) | |
lngAr = math.radians(lngA) | |
latBr = math.radians(latB) | |
lngBr = math.radians(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 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
(ele:with-transaction () | |
(mapcar #'(lambda (oid) | |
(ele::controller-recreate-instance ele:*store-controller* oid)) | |
(ele:with-btree-cursor (curs (ele:find-inverted-index class slot)) | |
(loop with i = 0 | |
for (m k v) = (multiple-value-list (ele:cursor-last curs)) | |
then (multiple-value-list (ele:cursor-prev curs)) | |
while (and m (if count | |
(<= (incf i) count) | |
t)) |
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
(clsql:select [guid] :from [sql-data] | |
:order-by '(([score] :desc)) | |
:limit count) |