Common Lisp (CL) -- язык программирования, стандартизированный в 1994 году. Ссылка на спек онлайн https://www.lispworks.com/documentation/HyperSpec/Front/index.htm Common Lisp -- это спецификация языка, существует неск4олько имплементаций, удовлетворяющих этой спецификации. Самой популярной* является sbcl (https://www.sbcl.org/). Common Lisp -- язык общего назначения, содержит элементы различных парадигм (функциональной и объектно-ориентированной(CLOS)). Это динамически типизированный язык, поддерживающий ограниченный набор опциональных типов и возможности объявлять их. Имеет существенную поддержку динамической разработки, REPL, динамическое переопределение функций и объектов в процессе разработки и в рантайме.Помимо этого, важной фичей языка являются его инструменты для метапрограммирования.
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
(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 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
#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 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
(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 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
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 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 ->> (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 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
#include <iostream> | |
#include <string> | |
#include <variant> | |
#include <tuple> | |
#include <stdexcept> | |
#include <sstream> | |
#include <vector> | |
enum class Op { |
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 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 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 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 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 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)))) |
NewerOlder