Skip to content

Instantly share code, notes, and snippets.

@digikar99
digikar99 / parametric polymorphism == trivia + exct + polymorphic-functions.lisp
Last active December 20, 2022 23:32
Again, I don't understand if this is what true parametric polymorphism is about. But this seems interesting none-the-less.
(in-package :polymorphic-functions)
(defun parametric-type-run-time-lambda-body (type-car type-cdr type-parameter)
(with-gensyms (object)
(let ((type-pattern (traverse-tree `(,type-car ,@type-cdr)
(lambda (node)
(cond ((eq node type-parameter)
type-parameter)
((and (symbolp node)
(parametric-type-symbol-p node))
@commander-trashdin
commander-trashdin / default-types.lisp
Last active March 2, 2021 17:26
Important part of my util, that is about sane defaults for all types, including parametrized. Let's try to cover all of them, can be very useful.
(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)))