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 *default-impl* (make-hash-table)) | |
| (Defun %dimensions-comp (dimensions) | |
| (cond ((eql '* dimensions) 0) | |
| ((listp dimensions) (mapcar (lambda (x) (if (eql '* x) 0 x)) dimensions)) | |
| (t dimensions))) | |
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
| (ql:quickload 'adhoc-polymorphic-functions) | |
| (use-package :adhoc-polymorphic-functions) | |
| ;(define-polymorphic-function make (type size)) ;;This one is harder that you might think | |
| (define-polymorphic-function push-front (data container)) | |
| (define-polymorphic-function push-back (data container)) | |
| (define-polymorphic-function pop-front (container)) | |
| (define-polymorphic-function pop-back (container)) | |
| (define-polymorphic-function size (container)) |
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
| (defstruct guest | |
| (checkin 0 :type fixnum) | |
| (checkout 0 :type fixnum)) | |
| (defstruct guestload | |
| (start 0 :type fixnum) | |
| (guestcount 0 :type fixnum)) | |
| (defstruct tdate | |
| (date 0 :type fixnum) |
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
| type Guest struct { | |
| CheckInDate int | |
| CheckOutDate int | |
| } | |
| type Load struct { | |
| StartDate int | |
| GuestCount int | |
| } |
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
| template <class Iterator, class RandomGenerator> | |
| void QuickSort(Iterator begin, Iterator end, RandomGenerator& generator) { | |
| if (begin == end) { | |
| return; | |
| } | |
| std::uniform_int_distribution<> dis(0, end - begin - 1); | |
| auto pivot = *(begin + dis(generator)); | |
| auto first = begin; | |
| auto last = end - 1; | |
| if (begin == last) { |
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 encode-type (typename) | |
| (let ((str "")) | |
| (labels ((rec (name) | |
| (when name | |
| (if (listp name) | |
| (mapcar #'rec name) | |
| (setf str (concatenate 'string str "-" (format nil "~s" name))))))) | |
| (rec typename) | |
| str))) |
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
| module Main where | |
| import Data.Maybe | |
| import Text.Read | |
| uncurry3 :: (a -> b -> c -> d) -> (a,b,c) -> d | |
| uncurry3 foo (a,b,c) = foo a b c | |
| get3Ints s = do | |
| [a, b, c] <- traverse readMaybe $ words s |
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 define-struct (name inheritance &body slots) | |
| (let ((trueslots (loop :for (name . rest) :in slots | |
| :collect (ecase (length rest) | |
| (1 `(,name . ,rest)) | |
| (2 (let ((type (cadr (member :t rest)))) | |
| `(,name ,(default type) :type ,type))) | |
| (3 (let ((type (cadr (member :t rest)))) | |
| `(,name ,(third rest) :type ,type))))))) | |
| `(progn |
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
| (ql:quickload 'adhoc-polymorphic-functions) | |
| (use-package :adhoc-polymorphic-functions) | |
| (deftype ind () `(integer 0 #.array-dimension-limit)) | |
| (defparameter *default-impl* (make-hash-table)) | |
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 munger which XORs a key with some data | |
| use std::borrow::Borrow; | |
| #[derive(Clone)] | |
| pub struct Xorcism<'a> { | |
| key: &'a [u8], | |
| position: usize, | |
| } | |
| pub trait Captures<'a> {} |