Skip to content

Instantly share code, notes, and snippets.

View digikar99's full-sized avatar

Shubhamkar Ayare digikar99

View GitHub Profile

sb-simd: Multiplying a 4x4 matrix with a 4-length vector (AVX)

(require 'sb-simd)
(defpackage :simd-pack-user
  (:use :sb-simd-avx :cl))
(in-package :simd-pack-user)

I'm assuming you are referring to the following operation:

@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))
@digikar99
digikar99 / learn-from-lisp.md
Last active January 18, 2023 03:12
This article is in response to Emmet Boudreau’s article ‘Should We be Using Lisp for Data-Science’ published on Medium

Lisp may not be the best language for Data Science, but what can we still learn from it?

This article is in response to Emmet Boudreau’s article ‘Should We be Using Lisp for Data-Science’.

Below, unless otherwise stated, lisp refers to Common Lisp; in general, lisp refers to the lisp family of languages, just like the C-family of languages. There are functional lisps like Clojure and Scheme, and there are general purpose lisps such as Common Lisp and Racket.

The primary hurdle to using Lisp for Data Science, I believe, is the non-infix syntax common in mathematics.

But, is there anything to learn from its syntax?

@digikar99
digikar99 / cl-numericals-survey.org
Last active April 4, 2023 01:42
A Survey of Simple Vector Addition Performance of the Numerical Computing Libraries available in Common Lisp

A Survey of Simple Vector Addition Performance of the Numerical Computing Libraries available in Common Lisp

Help with the following systems is required: CL-BLAPACK, MAXIMA, GSLL, XECTO

ImplementationQuicklispSpeed
ARRAY-OPERATIONSNativeMedium
AVMNative, CudaMedium
CLEMNativeSlow
@digikar99
digikar99 / cltl2-define-modify-macro.lisp
Created April 4, 2023 16:29
Type Declaration Propagating DEFINE-MODIFY-MACRO for INCF and DECF that play nice with CLTL2
(defun macroexpand-until (predicate form &optional env)
"Calls MACROEXPAND-1 on FORM until it is (FUNCALL PREDICATE FORM) returns non-NIL"
(loop :until (funcall predicate form)
:for expansion := (macroexpand-1 form env)
:do (setq form expansion)
:finally (return form)))
(defun macroexpand-until-car (car form &optional env)
"Calls MACROEXPAND-1 on FORM until it is a list which
starts with the symbol specified by CAR"
@digikar99
digikar99 / deep-copy.lisp
Last active July 4, 2023 16:54
Common Lisp Deep Copy
;; Jump to line 99
;; This is incomplete; follow the TODOs and think more to complete
(defpackage :deep-copy
(:use
:adhoc-polymorphic-functions
:cl
:alexandria)
(:local-nicknames (:cm :sandalphon.compiler-macro)
(:mop :closer-mop))
@digikar99
digikar99 / ubuntu-2204.org
Last active August 9, 2023 21:05
Ubuntu 22.04 customization reference for myself

Ubuntu 22.04 Customization

It’s been almost 4 years since my last linux OS upgrade. Last time it was Ubuntu 18.04, this time it is Ubuntu 22.04. Unfortunately, I do a lot of customization which can take plenty of post-installation time. This is one such list made primarily for self-reference later; it’d probably still be incomplete since I’m relying on memory.

Contents

@digikar99
digikar99 / why-coalton-is-a-language.org
Last active November 5, 2023 07:26
An attempt at introducing Coalton to lispers without a background in ML-like languages

Coalton: Why is the interop not easier, and why might it be necessary for Coalton to be an entire language in itself?

If you came here searching for the context in which some reddit comments were written, you might want to check out this previous version of the article.

Several blog posts have been written about Coalton, about how it can be useful and what it brings to the table. However, to me, it hasn’t been clear why Coalton is the way to solve the problems that it does solve. Isn’t a simpler solution possible without making a full embedded language, and giving users the cognitive overhead of thinking about interop between normal lisp and coalton?

I have been thinking about this for a while as one of my pasttimes, and below I’ll summarize the better reasons why coalton might be the way it is. Perhaps, I couldn’t se

@digikar99
digikar99 / lisp-resources-digikar-2020.md
Last active November 9, 2023 04:35
If programming is more than just a means of getting things done for you, then Common Lisp is for you!
@digikar99
digikar99 / lispy-numerical-computing-library-features.org
Last active December 12, 2023 01:37
A comparison and wish-list of features for a Common Lispy approach to a (better) Numpy

Features of a Common Lispy approach to (better) Numpy

Numpy is great, in fact it’s one of the things that pulls people to Python. But can it be better?

Common Lisp is great, in fact it’s one of the things that pulls people to Common Lisp. But can it be better? Indeed Python can’t be better than Common Lisp without it becoming another Lisp. The closest we have is Julia. And while it gets some things right, Julia lacks certain features that limit the goodness of a numerical computing library.

All combined, below I will highlight some of the features that I wish a numerical computing library or ecosystem had. I also want to request the readers for their own inputs about how things can be even better. The goal amidst this is solely to keep things numpy-like. I do not intend to - nor have the background to - make a DSL like April or Petalisp.

While I take some interest in performance and numerical computing, I have m