Skip to content

Instantly share code, notes, and snippets.

View JonathanSmith's full-sized avatar

Jonathan A Smith JonathanSmith

View GitHub Profile
user=> (time (nbody/main 100000)) ;;one above
(time (nbody/main 100000))
-0.16907516382852444
-0.16907985939166476
"Elapsed time: 2124.75375 msecs"
nil
user=> (time (main 100000)) ;;; nbody_v2
(time (main 100000))
-0.16907516382852444
(defmap hsv-color-fractal
(let [val %
z (.xy val)
n (.z val)
normalized-count (/ (- n (log2 (log2 (sqrt (+ (* (.x z) (.x z)) (* (.y z) (.y z)))))))
(float max-iterations))
h (* 360.0 normalized-count)
s 0.8
v 1.0
h_v (floor (/ h 60.0))
(defmap rgb-color-fractal
(let [val %
z (.xy val)
n (.z val)
normalized-count (/ (- n (log2 (log2 (sqrt (+ (* (.x z) (.x z)) (* (.y z) (.y z)))))))
(float max-iterations))]
(? (< 4.0 (dot z z))
(color3 normalized-count normalized-count (mix 0.2 1.0 normalized-count))
(color3 0.0 0.0 0.0))))
(defmap rgb-color-fractal
(let [val %
z (.xy val)
n (.z val)
normalized-count (/ (- n (log2 (log2 (sqrt (+ (* (.x z) (.x z)) (* (.y z) (.y z)))))))
(float max-iterations))]
(? (< 4.0 (dot z z))
(color3 normalized-count normalized-count (mix 0.2 1.0 normalized-count))
(color3 0.0 0.0 0.0))))
(defn mouse-click [[x y] state]
(let [ul (:upper-left state)
lr (:lower-right state)
coord (map / [x y] (:dim state))]
(update-bounds
(assoc state
:offset (map + ul (map * coord (map - lr ul)))))))
(defn key-press [key s]
(if-let [dispatch-fn ({:Z (fn [state]
(defmodule resource4
(author 'jonathansmith415@gmail.com)
(export (out 1)))
(include-file "/home/jon/clyawjure/yaws-1.85/include/yaws_api.lfe")
(defun out (arg)
(let* ((url (: yaws_api request_url arg))
(method (http_request-method (arg-req arg)))
(path (: string tokens (url-path url) '"/")))
If you look at test_macro.lfe
(defmacro let@
(((vb . vbs) . b) `(let (,vb) (let@ ,vbs . ,b)))
((() . b) `(begin . ,b)))
(defsyntax let&
([(vb . vbs) . b] [let (vb) (let& vbs . b)])
([() . b] [begin . b]))
(defmethod emit-special 'aget! [type [set! var idx]]
(str (emit var) "[" (emit idx) "]"))
(defmodule imp (export (bar 0)))
(eval-when-compile
(defun import-function-1 (module function)
;(: io format '"~p~p~n" (list module function))
(let ((mod-fun (list_to_atom
(: lists concat (list module '":" function)))))
; (: io format '"~p~n" (list mod-fun))
;;Jonathan Smith 2010
;;inspired by esessoms clj-interface
;;http://github.com/esessoms/clj-interface
(ns libs.erlang (:import
[com.ericsson.otp.erlang
OtpErlangAtom
OtpErlangBinary
OtpErlangBoolean
OtpErlangChar