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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: ircd | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the charybdis ircd | |
# Description: starts charybdis using start-stop-daemon |
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
-- Author: Michael-Keith Bernard | |
-- Date: May 22, 2012 | |
-- Description: Various implementations of the Fibonacci sequence in Lua. Lua | |
-- has native support for tail-call elimination which is why `tail_call` and | |
-- `continuation` run in near constant time. For sufficiently large numbers of n | |
-- you can start to see linear performace characteristics (particularly for the | |
-- `continuation` implementation), but ultimately the `tail_call` implementation | |
-- is an order of magnitude faster than iteration even for values of n as small | |
-- as 500k. |
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
-module(sortlib). | |
-export([qsort/1, bsort/1, ssort/1, isort/1, msort/2, | |
msort_lte/1, msort_gte/1]). | |
-export([test_sort/0, test_sort/1, shuffle/1, split/1, merge/3]). | |
-import(lists, [reverse/1]). | |
%% Various sorting algorithms implemented in Erlang |
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
-- Author: Michael-Keith Bernard | |
-- Date: July 26, 2012 | |
-- | |
-- Game of Life | |
-- | |
-- Ported from this Clojure implementation: | |
-- | |
-- (defn neighbours [[x y]] | |
-- (for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])] | |
-- [(+ dx x) (+ dy y)])) |
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
-- Author: Michael-Keith Bernard | |
-- Date: July 27, 2012 | |
-- Notes: An example Binary Tree Zipper implementation in Lua | |
function node(v, left, right) | |
local n = {} | |
n.value = v | |
n.left = left | |
n.right = right | |
return n |
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
#!/usr/bin/env python | |
# Author: Michael-Keith Bernard | |
# Date: July 27, 2012 | |
# | |
# Game of Life | |
# | |
# Ported from this clojure implementation: | |
# | |
# (defn neighbours [[x y]] |
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
-- Return true if any element of the iterable is true (or false if the iterable | |
-- is empty). Note that all values other than nil and false are considered true. | |
-- | |
-- ... - any number of values | |
-- | |
-- Examples | |
-- | |
-- any(false, false, true) -- true | |
-- any(false, false, false) -- false | |
-- any(true, true, true) -- true |
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
-- Author: Michael-Keith Bernard | |
-- Date: August 10, 2012 | |
-- | |
-- Notes: This Trie implementation is a port of the Clojure implementation | |
-- below. I had to implement quite a few functions from clojure.core to keep the | |
-- same basic functionality. Probably very little if any of this code is | |
-- production worthy, but it's interesting all the same. Finally, all of the | |
-- documentation strings are pulled directly from clojure.core and may not | |
-- accurately reflect the Lua implementation. | |
-- |
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
function defmulti(keyfn) | |
if not keyfn then | |
keyfn = function(...) return ... end | |
end | |
local multi = { | |
_keyfn = keyfn, | |
_methods = {} | |
} | |
setmetatable(multi, { | |
__call = function(self, ...) |
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
def compose(f, g): | |
def inner(*args, **kwargs): | |
return f(g(*args, **kwargs)) | |
return inner | |
# Clojure: (comp #(+ 1 %) #(* 2 %)) | |
times2plus1 = compose(lambda n: n + 1, lambda n: n * 2) | |
print times2plus1(4) | |
# OUT: 9 |
OlderNewer