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
| { pkgs }: | |
| { | |
| allowUnfree = true; | |
| allowBroken = true; | |
| packageOverrides = self: with self; rec { | |
| etsEnv = self.buildEnv { | |
| name = "etsEnv"; |
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
| (ns dft.core) | |
| (defn fft [x] | |
| (let [length (count x)] | |
| (if (<= length 1) | |
| (->> x | |
| (persistent!) | |
| (vec)) | |
| (let [x (transient x) | |
| even (recur (map #(nth % x) (range length))) |
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
| ;; From e.g. https://github.com/scottjad/uteal | |
| (defmacro dlet | |
| "let with inspected bindings" | |
| [bindings & body] | |
| `(let [~@(mapcat (fn [[n v]] | |
| (if (or (vector? n) (map? n)) | |
| [n v] | |
| [n v '_ `(println (name '~n) ":" ~v)])) | |
| (partition 2 bindings))] | |
| ~@body)) |
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
| ;; Version 1: direct inline the anonymous function: | |
| (defn as-currency | |
| "Money amounts are transmitted as \"$2.44\". | |
| Parse this and return a numeric type." | |
| [currency-amount] | |
| (-> (subs currency-amount 1) | |
| ((fn [x] (println x) x)) | |
| (bigdec) | |
| ((fn [x] (println x) x)))) |
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 loop-while | |
| [bind condition & body] | |
| `(loop ~bind | |
| (when ~condition | |
| ~@body | |
| (recur ~@(map second (partition 2 bind)))))) |
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
| ((lambda (x) (list x (list 'quote x))) | |
| '(lambda (x) (list x (list 'quote x)))) |
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
| (defn dl | |
| [& elements] | |
| (fn [x] (concat elements x))) | |
| (defn dl-un | |
| [l] | |
| (l nil)) | |
| (defn dl-concat | |
| [& lists] | |
| (fn [x] ((apply comp lists) x))) |
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
| #!/bin/bash | |
| git diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
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
| (defn ones-in-partitions | |
| "Number of 1s in all partitions of an integer n" | |
| [n] | |
| (-> (repeat (dec n) 1) | |
| (clojure.math.combinatorics/partitions) | |
| (count))) | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| (defn partitions |
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
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| {-# LANGUAGE OverlappingInstances #-} | |
| module Montgomery where | |
| -- type R = 2 | |
| r :: Integer | |
| r = 2 |