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
| struct Int { | |
| int x; | |
| Int() = default; | |
| Int(int x) : x(x) { | |
| } | |
| Int(const Int& rhs) { | |
| UpdateCounter(); | |
| x = rhs.x; | |
| } |
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
| (defmacro dfs (graph start visitor) ;; graph is an adjacency vector | |
| "(initialize-vertex visitor vertex) is invoked on every vertex of the graph before the start of the graph search. | |
| (start-vertex visitor vertex) is invoked on the source vertex once before the start of the search. | |
| (discover-vertex visitor vertex) is invoked when a vertex is encountered for the first time. | |
| (examine-edge visitor edge) is invoked on every out-edge of each vertex after it is discovered. | |
| (tree-edge visitor edge) is invoked on each edge as it becomes a member of the edges that form the search tree. If you wish to record predecessors, do so at this event point. | |
| (back-edge visitor edge is invoked on the back edges in the graph. | |
| (cross-edge visitor edge) is invoked on cross edges in the graph. In an undirected graph this method is never called. | |
| I have no idea about what to do with forward edges. | |
| (finish-edge visitor edge) is invoked on the non-tree edges in the graph as well as on each tree edge after its target vertex is finished. |
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
| struct Item { | |
| Item() = default; | |
| Item(int value, int weight) : value_(value), weight_(weight) { | |
| } | |
| int value_; | |
| int weight_; | |
| }; |
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
| (defun tt-heading-description () | |
| "Get header and description of first header element in buffer." | |
| (with-temp-buffer | |
| (insert " | |
| * Top Heading | |
| Some description | |
| * Second Heading | |
| Other description | |
| ") | |
| (let ((first-headline (seq-find (lambda (part) (eql (car part) 'headline)) (org-element-parse-buffer)))) |
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
| (defun intern-gen-sym (&optional str) | |
| (if str | |
| (intern (format nil "intern-g~a~s" str (incf *gensym-counter*))) | |
| (intern (format nil "intern-g~s" (incf *gensym-counter*))))) | |
| (define-condition recursive-currying-lambda (error) | |
| ((datum :initform "Cannot curry lambda with 0 arguments" :allocation :class))) | |
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
| (defun parse-annotation-lines (list) | |
| "Pull out header and item information from LIST." | |
| (let (acc (header-is-next nil) (item-is-next nil) (current-page)) | |
| (nreverse | |
| (dolist (element list acc) | |
| (cond (header-is-next | |
| (push (make-parse-entry *header+ element current-page) acc) | |
| (setq header-is-next nil)) | |
| (item-is-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
| (defparameter *infix-operator-order* '((!) (^ :reverse) (* /) (+ -) (> < >= <= =) (and) (or) (eql))) | |
| (defparameter *infix-operator-set* '(+ * ^ - / ! = and or eql)) | |
| (defparameter *unary-operator-set* '(!)) | |
| (defparameter *infix-operator-hash* (let ((local-hash (make-hash-table))) | |
| (setf (gethash '+ local-hash) '+) | |
| (setf (gethash '* local-hash) '*) | |
| (setf (gethash '^ local-hash) 'expt) |
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
| CL-USER> (disassemble (lambda (a b) (declare (optimize (speed 3) (safety 0) (compilation-speed 0))) | |
| (declare (long-float a) (long-float b)) | |
| (+ a b))) | |
| ; disassembly for (LAMBDA (A B)) | |
| ; Size: 65 bytes. Origin: #x52C50EE0 ; (LAMBDA (A B)) | |
| ; EE0: F20F58D1 ADDSD XMM2, XMM1 | |
| ; EE4: 49896D28 MOV [R13+40], RBP ; thread.pseudo-atomic-bits | |
| ; EE8: 498B5568 MOV RDX, [R13+104] ; thread.alloc-region | |
| ; EEC: 4C8D5A10 LEA R11, [RDX+16] | |
| ; EF0: 4D3B5D70 CMP R11, [R13+112] |
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
| (defpackage #:optimizations | |
| (:use #:cl) | |
| (:shadow #:+)) | |
| (in-package #:optimizations) | |
| (declaim (inline quaternion)) | |
| (defstruct quaternion |
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
| (defpackage #:optimizations | |
| (:use #:cl) | |
| (:shadow #:+)) | |
| (in-package #:optimizations) | |
| (declaim (inline quaternion)) | |
| (defstruct quaternion |