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
| from typing import cast | |
| class Tree: | |
| def accept(self, v: 'TreeVisitor') -> object: | |
| pass | |
| class Leaf(Tree): | |
| def accept(self, v: 'TreeVisitor') -> object: | |
| return v.visit_leaf(self) | |
| class Node(Tree): | |
| def __init__(self, value: int, left: Tree, right: Tree) -> None: | |
| self.value = value |
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
| #ifndef LIST_H | |
| #define LIST_H | |
| #include <stddef.h> | |
| /** | |
| * @brief A list traversal field that can be embedded in objects. | |
| */ | |
| typedef struct list_node { | |
| struct list_node *next; |
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
| #ifndef LIST_H | |
| #define LIST_H | |
| #include <stddef.h> | |
| /** | |
| * @brief A list traversal field that can be embedded in objects. | |
| */ | |
| typedef struct list_node { | |
| /////// |
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
| /** | |
| * @file variable_queue.h | |
| * | |
| * @brief Generalized queue module for data collection | |
| * | |
| * @author Michael Sullivan ([email protected]) | |
| **/ | |
| #include <stddef.h> | |
| #include <stdlib.h> |
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
| (* A modification of binary-set-fn.sml to be able to handle set elements | |
| * that contain sets. *) | |
| (* binary-set-fn.sml | |
| * | |
| * COPYRIGHT (c) 1993 by AT&T Bell Laboratories. See COPYRIGHT file for details. | |
| * | |
| * This code was adapted from Stephen Adams' binary tree implementation | |
| * of applicative integer sets. | |
| * |
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
| {-# LANGUAGE GeneralizedNewtypeDeriving, DeriveFoldable #-} | |
| import Data.Foldable | |
| import qualified Data.Set as Set | |
| import qualified Data.Map as Map | |
| class Memo a where | |
| memo :: (a -> b) -> (a -> b) | |
| memoFix :: ((a -> b) -> (a -> b)) -> (a -> b) |
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
| #!/usr/bin/env python3 | |
| def build_rgraph(graph): | |
| rgraph = {k: set() for k in graph.keys()} | |
| for u in graph.keys(): | |
| for v in graph[u]: | |
| rgraph[v].add(u) | |
| return rgraph | |
| def dfs(graph, seen, val, start): |
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
| (* uses some data structures from | |
| * https://github.com/standardml/cmlib/ *) | |
| (* also the pretty printer uses some hacked up versions of some stuff | |
| * from tom7 that I don't actually include but will if anybody wants to | |
| * actually run this *) | |
| signature VARIABLE = | |
| sig |
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
| Alaska,1 | |
| Delaware,1 | |
| Montana,1 | |
| NorthDakota,1 | |
| SouthDakota,1 | |
| Vermont,1 | |
| Wyoming,1 | |
| Hawaii,2 | |
| Idaho,2 | |
| Maine,2 |
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
| void reboot(void) | |
| { | |
| while (1) { /* keep trying if it doesn't work */ | |
| /* wait for the output buffer to be empty */ | |
| while (inb(KEYBOARD_CMD_PORT) & KEYBOARD_OUTBUF_FULL_MASK) | |
| ; | |
| /* send the command to have the keyboard controller reboot the machine. | |
| * wtf. */ | |
| outb(KEYBOARD_CMD_PORT, KEYBOARD_CMD_REBOOT); |