Skip to content

Instantly share code, notes, and snippets.

(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)))
(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 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);
}
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) {
(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* 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))
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)
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);
}
(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))
(clsql:select [guid] :from [sql-data]
:order-by '(([score] :desc))
:limit count)