Skip to content

Instantly share code, notes, and snippets.

View oubiwann's full-sized avatar
💭
🌌

Duncan McGreggor oubiwann

💭
🌌
View GitHub Profile
@oubiwann
oubiwann / huge-number.lfe
Last active August 29, 2015 14:00
Playing with tail-recursive factorial in LFE
This file has been truncated, but you can view the full file.
> (factorial 4000000)
exception error: system_limit
in (: erlang
*
3229797
30123180888527072598754061749733156956836010853066267762188108601162877
501605950711425018360722033156484485761208096373181054336452668279306575186488
625487378757417504192553057885369932190386049370641878631432583447644047021486
245708528594358523103979850867383263694029300939124590581455105879597555548321
332105886291655143516998679067067107752904759587500859444578397785006406762423
@oubiwann
oubiwann / lfe_latest.txt
Last active August 29, 2015 14:01
Latest in the world of LFE
Released Features
* Maps in LFE.
* A new (run ...) REPL command run running LFE shell commands.
* Now possible to define functions and macros in the REPL.
* Strings no longer need to be quoted.
* LFE now has Common Lisp macros (prog1 ...) and (prog2 ...).
* (mod:func ...) syntax now supported.
* New (fields-name) macro for easier usage of Mnesia from LFE.
* #| ... |# Common Lisp-style multiline comments now supported.
@oubiwann
oubiwann / 01-elxir_from_lfe.bash
Last active August 29, 2015 14:01
Elixir from LFE
# update rebar.config to include Elixir
$ make get-deps
$ make compile
$ lfetool repl lfe -pa ./deps/elixir/lib/elixir/ebin/
@oubiwann
oubiwann / 01-manual-routes.lfe
Last active August 29, 2015 14:01
LFE Routes
(defun routes
"Routes for the Volvoshop REST API."
;; /order
(((list "order") method arg-data)
(order-api method arg-data))
;; /order/:id
(((list "order" order-id) method arg-data)
(order-api method order-id arg-data))
;; /orders
(((list "orders") method arg-data)
@oubiwann
oubiwann / output.lfetool.txt
Created June 30, 2014 00:31
"lfetool commands" output
$ lfetool2 commands
commands - List all the top-level commands available to lfetool.
extract - lfetool is no longer compressed; this is a no-op (included for
backwards compatibility only).
help - Get the general help for lfetool; if passed a plugin name as
an argument, display the help for that plugin.
info - Get information of the type indicated by the passed argument.
install - Install LFE by default; if passed an argument, in stall the
indicated software.
repl - By default, start an LFE REPL with access to all the
@oubiwann
oubiwann / 01-values.lfe
Last active August 29, 2015 14:03
Using Levenshtein Distance and Team Analysis to Reveal Inherent Engineering Org Structure
> (defun int-exp (a b)
(trunc (math:pow a b)))
int-exp
> (set lfe (int-exp 2 0))
1
> (set hy (int-exp 2 5))
32
> (set clojure (int-exp 2 6))
64
> (bxor clojure (bxor lfe hy))
Pulling lfe from {git,"git://github.com/rvirding/lfe.git","develop"}
Cloning into 'lfe'...
Pulling 'lfe-utils' from {git,"https://github.com/lfe/lfe-utils.git","master"}
Cloning into 'lfe-utils'...
Pulling lfeunit from {git,"git://github.com/lfe/lfeunit.git","master"}
Cloning into 'lfeunit'...
Pulling lfest from {git,"git://github.com/lfex/lfest.git","master"}
Cloning into 'lfest'...
Pulling yaws from {git,"git://github.com/klacke/yaws.git","master"}
Cloning into 'yaws'...
@oubiwann
oubiwann / 01-bottle.py
Last active August 29, 2015 14:05
Comparison of Python (Bottle), Clojure (Compojure), and Erlang/LFE (lfest) REST Routes
from example.bottle.bttl import Bottle
app = Bottle()
@app.get('/')
def index():
return "Hello, World!"
@app.get('/orders')
def get_orders():
@oubiwann
oubiwann / 01-checkout.txt
Last active August 29, 2015 14:10
LFE and Python 3
$ git clone git@github.com:oubiwann/erlport-demo.git
$ cd erlport-demo
@oubiwann
oubiwann / area.clj
Last active August 29, 2015 14:24
Dispatch in LFE and Clojure
;;;; From the Clojure Cookbook
;;;; by Luke VanderHart and Ryan Neufeld
;; The easiest way to implement runtime polymorphism is via hand-rolled,
;; map-based dispatch using functions like cond or condp:
(defn area
"Calculate the area of a shape"
[shape]
(condp = (:type shape)