The goal of this FAQ is to provide a humorous response to the inevitable question that comes up whenever people discuss a project that is written in Vala. Hopefully, it will save some time in the long run.
That was called Mono, and nobody liked it.
/* example implementation -- not recommended for actual use, but it would work! | |
* (SIMD-friendly in principle; not shown) | |
* (probably not ideal for memory-bound workloads; uses 50% more space) | |
* based on two insights: | |
* - complex multiplication (a+bi)(c+di) with i^2 = -1 is equivalent to | |
* split-complex multiplication (a+bk)(c+dk) - 2*b*d with k^2 = +1 | |
* - the split-complex numbers are isomorphic to the direct product R*R with the | |
* basis (1+k)/sqrt(2), (1-k)/sqrt(2), both idempotents, thus split-complex | |
* multiplication (a+bk)(c+dk) can be done by (a+b)(c+d) and (a-b)(c-d) | |
*/ |
-- A simple array-manipulation library for Lua. | |
-- The natural question is: why bother writing this? | |
-- After all, it's very short, and anyone reasonably familiar with | |
-- normal array-manipulation libraries could replicate it in a few | |
-- hours. | |
-- But despite this, such a library does not exist in the wild, and | |
-- the existing counterparts are bad. For instance, penlight.List | |
-- lacks foldr(), and includes a bunch of things that it shouldn't, | |
-- like t:put(x), which is equivalent to t:insert(1, x), but also | |
-- prevents anyone reading your code from knowing what it does. |
-- This script attempts to automatically sort the \bibitem{}s in the bibliography of a .tex file according to occurrences of \cite{}. | |
-- Pretty much everyone wants this, but LaTeX you to use extra files or sort by hand. This is annoying for small projects which only | |
-- need to use a single .tex file. | |
-- Assumptions: all \cite{} and \bibitem{} occurrences are in one file; only one \bibitem{} on each line; string.lower() works with | |
-- your citation handles. | |
tfile = [==[ PASTE .tex FILE HERE ]==] -- or use file i/o and io:lines() instead of the first call to gmatch() | |
local orders, count, lines = {}, 1, {} |
(defn echo [x] (do (prn x) x)) | |
(defn readmap [fn fl] | |
(with-open [r (clojure.java.io/reader fl)] (doall (map fn (line-seq r))))) | |
(defn zip-county-frac [s] (let [l (clojure.string/split s #",")] (list (second l) (first l) (nth l 4)))) | |
(defn cbsa-county [s] (list (first (clojure.string/split s #"," 2)) (clojure.string/replace (or (re-find #",\d\d,\d\d\d," s) "") #"," ""))) |
def gen_primes(): | |
"""Generate an infinite sequence of prime numbers.""" | |
D = {} | |
q = 2 | |
S = 4 | |
r = 2 | |
while True: | |
if q not in D: | |
if q == S: | |
S = S + r |