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 "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; |
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
| 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 |
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 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, |
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 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))) | |
| )) |
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
| 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 |