Skip to content

Instantly share code, notes, and snippets.

View msp729's full-sized avatar
⁉️
long shifts at the math factory

nate msp729

⁉️
long shifts at the math factory
View GitHub Profile
@msp729
msp729 / main.c
Created February 27, 2025 22:53
C compact matrix Fibonacci (GMP)
#include "gmp.h"
typedef struct {
mpz_t step, ident;
} flm;
// these variables are used in the functions as storage
// they're exterior so that I can initialize them once each.
mpz_t s0, s1, s2;
flm base;
@msp729
msp729 / main.py
Created February 27, 2025 18:29
Python compact matrix Fibonacci
class FLM:
iden: int
step: int
def sum(self):
return self.iden + self.step
def __init__(self, iden = 0, step = 1):
self.iden = iden
self.step = step
@msp729
msp729 / main.rs
Last active February 27, 2025 23:07
Rust compact matrix Fibonacci
use num_bigint::BigUint;
use num_traits::One;
use num_traits::Zero;
use core::ops::{Mul, MulAssign};
#[derive(Debug, Clone)]
struct FLM {
step: BigUint,
ident: BigUint,
@msp729
msp729 / pylc.lisp
Created January 12, 2025 13:19
Python list comprehensions in lisp
(defun flatmap (fn lst)
"as seen in haskell's (>>=) :: [a] -> (a -> [b]) -> [b], or rust's flat_map"
(apply #'append (mapcar fn lst)))
(defun get-fors (lst)
"extract the for clauses, as (variable list list-of-conditions)"
(unless lst (return-from get-fors nil))
(let ((v (get-for lst)))
`((,(car v) ,(cadr v) ,(caddr v)) . ,(get-fors (cdddr v)))
))
@msp729
msp729 / Main.hs
Created November 8, 2023 16:46
Haskell code used to solve a problem in ANT
module Main (main) where
import Text.Printf (printf)
lq :: [(Int, Int)]
lq = [(i, 10 - i) | i <- [1 .. 9]]
lqjk :: [(Int, Int, Int, Int)]
lqjk = do
(l, q) <- lq -- take l and q values from the lq list