Skip to content

Instantly share code, notes, and snippets.

View ntalbott's full-sized avatar
💻
Writing and Coding

Nathaniel Talbott ntalbott

💻
Writing and Coding
View GitHub Profile
defmodule MSort do
def msort([]), do: []
def msort([e]), do: [e]
def msort(list) do
{left, right} = Enum.split(list, div(Enum.count(list), 2))
merge(msort(left), msort(right))
end
def merge(left, []), do: left
def merge([], right), do: right
@ntalbott
ntalbott / msort.ex
Created July 15, 2015 18:21
Using case
defmodule MSort do
def msort(list) do
case list do
[] -> []
[e] -> [e]
_ ->
{left, right} = Enum.split(list, div(Enum.count(list), 2))
merge(msort(left), msort(right))
end
end
@ntalbott
ntalbott / ipxrelay.patch
Created November 28, 2015 21:40
Patch allowing cross-compilation for ipxrelay
diff --git a/Makefile b/Makefile
index 873fb1b..20dcc64 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
-CC = gcc
+CROSSCOMPILE ?=
+CC = $(CROSSCOMPILE)gcc
CWARN = -W -Wall
COPT = -g -O2
#!/usr/bin/env ruby
CASES = {
"" => ["", "", "", "", ""],
"Some random data." => ["Some random data.", "", "", "", ""],
"This information should be ignored RECORD_NUM 02 This is the information for record 2 RECORD_NUM 01 This is the information for record 1 RECORD_NUM 04 This is the information for record 4" =>
[" This is the information for record 1 ", " This is the information for record 2 ", "", " This is the information for record 4", ""],
}
def process(input, expected_record_count=5)