Skip to content

Instantly share code, notes, and snippets.

Eugene needs your help
We can't make this file beautiful and searchable because it's too large.
title,cast,director,overview
#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))
// 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.
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
;; 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))
@mcclane
mcclane / gist:24ebc184f3d9c6a8c6f6fbcc92f6c972
Last active October 17, 2020 23:29
possible let desugaring
;; 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))
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")
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):
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)