Skip to content

Instantly share code, notes, and snippets.

View movie_data.csv
We can't make this file beautiful and searchable because it's too large.
title,cast,director,overview
View Lab7.rkt
#lang typed/racket
(require typed/rackunit)
(define-type ExprC (U Real Symbol String LamC AppC IfC SetC))
(struct LamC ([params : (Listof Symbol)] [body : ExprC]) #:transparent)
(struct AppC ([fun : ExprC] [args : (Listof ExprC)]) #:transparent)
(struct IfC ([test : ExprC] [thn : ExprC] [els : ExprC]) #:transparent)
(struct SetC ([var : Symbol] [newval : ExprC]) #:transparent)
(define-type Value (U Real Boolean String CloV PrimV ArrayV))
View A* pseudocode
// A* pseudocode from the wikipedia article
function A*(start, goal)
// The set of nodes already evaluated
closedSet := {}
// The set of currently discovered nodes that are not evaluated yet.
// Initially, only the start node is known.
openSet := {start}
// For each node, which node it can most efficiently be reached from.
View gist:864c0fb570bce2258856cf3b17a6798d
PID COMM STATE
1 systemd INT
2 kthreadd INT
3 rcu_gp OTHER
4 rcu_par_gp OTHER
5 kworker/0:0 OTHER
6 kworker/0:0H OTHER
7 kworker/u4:0 OTHER
8 mm_percpu_wq OTHER
9 ksoftirqd/0 INT
View gist:56da1c6998191732aac1f04922b9ad14
;; Test parse
(check-equal? (parse 10) (vc 10))
(check-equal? (parse -10) (vc -10))
(check-equal? (parse '{+ 10 5}) (appC (idC '+) (list (valueC (realV 10)) (valueC (realV 5)))))
(check-equal? (parse '{+ 10 {+ 2 3}}) (appC (idC '+) (list (valueC (realV 10)) (appC (idC '+)
(list (valueC (realV 2))
(valueC (realV 3)))))))
(check-equal? (parse '{* 10 5}) (appC (idC '*) (list (valueC (realV 10)) (valueC (realV 5)))))
(check-equal? (parse '{* 10 {+ 2 3}}) (appC (idC '*) (list (valueC (realV 10)) (appC (idC '+)
(list (valueC (realV 2))
View gist:24ebc184f3d9c6a8c6f6fbcc92f6c972
;; Turn an s-expression in to an AST using the ExpressionC elements defined above.
(define (parse [expression : Sexp]) : ExprC
(match expression
[(? real? value) (numC (realV value))]
[(list 'ifleq0 condition if-block else-block)
(ifleq0C (parse condition) (parse if-block) (parse else-block))]
[(? symbol? value) (idC value)]
[(list 'fn (list (? symbol? arguments) ...) body) (lambdaC (cast arguments (Listof Symbol)) (parse body))]
[(list 'let (? list? arguments) ... 'in (? list? body))
(appC (lambdaC (get-let-arg-symbols (cast arguments (Listof Sexp))) (parse body))
View mcclane_concordance_tests.py
import unittest
import filecmp
from concordance import *
class TestList(unittest.TestCase):
def test_01(self):
conc = Concordance()
conc.load_stop_table("stop_words.txt")
conc.load_concordance_table("file1.txt")
View hash_quad_tests_mcclane.py
import unittest
from hash_quad import *
class TestList(unittest.TestCase):
def test_01a(self):
ht = HashTable(7)
self.assertEqual(ht.get_table_size(), 7)
def test_01b(self):
View mcclane_heap_tests.py
import unittest
import random
from heap import *
class TestHeap(unittest.TestCase):
def test_01_enqueue(self):
"""Test simple enqueue operations and build heap"""
test_heap = MaxHeap(7)
test_heap.build_heap([2, 9, 7, 6, 5, 8])
insert = test_heap.enqueue(10)
View sorts_tests.py
import unittest
from sorts import *
class TestLab4(unittest.TestCase):
def test_simple(self):
"""Simple test for selection sort"""
nums = [23, 10]
comps = selection_sort(nums)
self.assertEqual(comps, 1)