Skip to content

Instantly share code, notes, and snippets.

View djtrack16's full-sized avatar

Darius Liddell djtrack16

  • CareRev
View GitHub Profile
@brianstorti
brianstorti / priority_queue.rb
Last active November 17, 2022 16:14
Priority queue implementation in Ruby
class PriorityQueue
attr_reader :elements
def initialize
@elements = [nil]
end
def <<(element)
@elements << element
bubble_up(@elements.size - 1)
@crabmusket
crabmusket / Alphabet.hs
Last active April 20, 2020 12:02
Naive bijective function in Haskell. http://stackoverflow.com/questions/742013
module Alphabet (
Alphabet,
encodeWithAlphabet,
decodeFromAlphabet
) where
import Prelude
import Data.List(elemIndex, mapAccumR)
import Data.Maybe(fromMaybe)
@pepijndevos
pepijndevos / parsistent_heap.clj
Created January 15, 2011 17:13
A persistent heap implemented in Clojure
(ns persistent-heap)
(defn swap [heap idx idy]
(assoc heap idx (get heap idy) idy (get heap idx)))
(defn children [idx]
(let [idx (inc (* idx 2))
idy (inc idx)]
[idx idy]))