This file contains 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
(define-method-combination eql-combinator (&optional (order ':most-specific-last)) | |
((around (:=) :order order) | |
(primary (eql-combinator) :order order :required t)) | |
(if around | |
`(and ,@(mapcar (lambda (method) | |
`(call-method ,method)) | |
around)) | |
`(call-method ,(first primary)))) | |
This file contains 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
#include <vector> | |
#include <utility> | |
using Graph = std::vector<std::vector<int>>; | |
enum class Visited { WHITE, GREY, BLACK }; | |
void DFSVisit(size_t start, const Graph& graph, std::vector<Visited>& colormap); | |
void TraverseGraphInDfsOrder(const Graph& graph) { |
This file contains 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
(defclass fusion-info () | |
((names :initarg :names | |
:initform nil | |
:accessor names) | |
(fields :initarg :fields | |
:initform nil | |
:accessor fields) | |
(returns :initarg :returns | |
:initform nil | |
:accessor returns) |
This file contains 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
use std::collections::HashMap; | |
pub type Value = i32; | |
pub type Result = std::result::Result<(), Error>; | |
type Builtin = fn(&mut Vec<Value>) -> Result; | |
pub struct Forth<'a> { | |
stack: Vec<Value>, | |
names: HashMap<String, &'a [&'a str]>, | |
builtins: HashMap<&'static str, Builtin>, |
This file contains 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 ->> (obj &rest fns) | |
(labels ((rec (ls acc) | |
(if ls | |
(destructuring-bind (fst . rst) ls | |
(rec rst (if (listp fst) | |
(destructuring-bind (fn . args) fst | |
`(,fn ,acc ,@args)) | |
`(,fst ,acc)))) | |
acc))) | |
(rec fns obj))) |
This file contains 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
#include <iostream> | |
#include <string> | |
#include <variant> | |
#include <tuple> | |
#include <stdexcept> | |
#include <sstream> | |
#include <vector> | |
enum class Op { |
This file contains 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 read-lines (path) ;; read lines just try this out | |
(with-open-file (stream path :direction :input :if-does-not-exist :error) | |
(let ((res (make-array 0 :adjustable t | |
:fill-pointer 0 | |
:element-type 'string))) | |
(loop :for line := (read-line stream nil nil) | |
:while line | |
:do (vector-push-extend line res)) | |
res))) |
This file contains 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 read-lines (path) | |
(with-open-file (stream path :direction :input :if-does-not-exist :error) | |
(flet ((line->vector (line) | |
(let ((vec (make-array 0 :adjustable t :fill-pointer 0))) | |
(loop :for ch :across line | |
:do (vector-push-extend (- (char-code ch) 48) vec)) | |
vec))) | |
(let ((res (make-array 0 :adjustable t :fill-pointer 0))) | |
(Loop :for line := (read-line stream nil nil) | |
:while line |
This file contains 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 read-cycle-num (path) ;;reading input | |
(flet ((convert (char) | |
(- (char-code char) 48))) | |
(with-open-file (stream path :direction :input :if-does-not-exist :error) | |
(let ((res (make-array 0 :adjustable t :fill-pointer 0 :element-type 'fixnum))) | |
(loop :for cycle := (read-char stream nil nil) | |
:while cycle | |
:do (vector-push-extend (convert cycle) res) | |
(read-char stream nil nil)) | |
res)))) |
This file contains 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 read-coords (path) | |
(with-open-file (stream path :direction :input :if-does-not-exist :error) | |
(let ((res (make-array 0 :adjustable t :fill-pointer 0))) | |
(loop :for (x1 y1 _ x2 y2) | |
:= (uiop:split-string (read-line stream nil nil) :separator ", ") | |
:while x1 | |
:do (vector-push-extend (list (parse-integer x1) | |
(parse-integer y1) | |
(parse-integer x2) | |
(parse-integer y2)) res)) |
NewerOlder