Created
July 13, 2017 17:11
-
-
Save bobfirestone/8abc5ca81dc0760c6dd8b9fe89534fac to your computer and use it in GitHub Desktop.
Elixir implementation of Trump Sort
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
defmodule TrumpSort do | |
def sort([h|tail]) do | |
[ h | sort(tail,h) ] | |
end | |
def sort([], _wall) do | |
[] | |
end | |
def sort([h|tail], wall) when h > wall do | |
[ h| sort(tail,h) ] | |
end | |
def sort([_h|tail], wall) do | |
sort(tail, wall) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment