This file contains 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
Collatz.run: IO(Unit) | |
do IO { | |
var val_str = IO.prompt("start value:"); | |
let start = Nat.parse_decimal(val_str); | |
Collatz.step(start); | |
} | |
Collatz.step(start: Nat): IO(Unit) | |
let next = Collatz.next(start); | |
do IO { |
This file contains 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
" Vim syntax file | |
" Language: Formality | |
" Maintainer: Anders Christiansen Sørby <[email protected]> | |
" Last Change: August 16. 2020 | |
" | |
" Version: 2.0 | |
" Url: | |
" | |
" Remove any old syntax stuff hanging around |
This file contains 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 argparse import ArgumentParser | |
import numpy as np | |
gcd_table = {} | |
def gcd(a, b): | |
while a % b != 0: | |
a, b = b, a % b | |
return b | |
bound = 10000 |
This file contains 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
import numpy as np | |
from itertools import product | |
from timeit import default_timer as timer | |
import matplotlib.pyplot as plt | |
# Deterministic | |
np.random.seed(1234) | |
# Data | |
dim = 4 |
This file contains 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
;; 4clojure problem #53 | |
(fn [s] (loop [longest [] r (sorted-set) [x n & xs :as l] s] | |
(cond | |
(nil? n) longest | |
(= n (inc x)) (recur (if (> (+ 2 (count r)) (count longest)) (vec (conj r x n)) longest) (conj r x n) (rest l)) | |
:else (recur longest (sorted-set) (rest l))))) |
This file contains 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
;; Creates the nth row of pascals triangle | |
;; the addition way | |
(fn [n] | |
(loop [s [1]] | |
(if | |
(= n (count s)) s | |
(recur (into (into [1] (map + s (rest s))) [1])) | |
))) |
This file contains 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
;; A prime finder (not optimized) | |
(fn [s] (loop [i s p [] n 2] | |
(cond | |
(= 0 i) p | |
(every? identity (map #(not= 0 (mod n %)) p)) (recur (dec i) (conj p n) (inc n)) | |
:else (recur i p (inc n))))) |
This file contains 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
;; An infix calculator | |
(defn calc [& x] | |
(loop [a (first x) b (second x) c (nth x 2) remainding (drop 3 x)] ;; This loop is unnecessary complex | |
(let [result (b a c)] | |
(if (empty? remainding) | |
result | |
(recur | |
result | |
(first remainding) | |
(second remainding) |