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
function derive(axiom, rules) { | |
let out = ''; | |
for (c of axiom) { | |
out += rules[c] || c; | |
} | |
return out | |
} | |
function deriveTimes(axiom, rules, n) { | |
let out = axiom; |
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 <Bela.h> | |
#include <OSCServer.h> | |
#include <OSCClient.h> | |
#include <math.h> | |
#include <digital_gpio_mapping.h> | |
//44100 * 60 * 4 (4 minute loop) | |
#define LOOP_BUFFER_SIZE 10584000 | |
float gLoopBuffer_l[LOOP_BUFFER_SIZE] = {0}; |
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 <Bela.h> | |
#include <stdio.h> | |
#include <cmath> | |
#include <digital_gpio_mapping.h> | |
float gPhase1, gPhase2, gPhase3; | |
float gInverseSampleRate; | |
bool setup(BelaContext *context, void *userData) | |
{ |
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 | |
#shove this in /usr/local/bin/ on the Pi and give it execute permissions | |
#could probably improve very easily by checking if port 5555 is listening before trying to toss data at it | |
#stole ideas from here: https://hydrogenaud.io/index.php/topic,102996.0.html | |
{ | |
while true; | |
do sox -talsa hw:CODEC -r44100 -b16 --buffer 4096 -tflac - \ | |
| pv | nc 192.168.1.4 5555; | |
sleep 10; |
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 diff-sorted | |
[old new] | |
;;iterate through new list | |
(let [old-set (set old)] | |
(loop [actions '() | |
old-list old | |
new-list new] | |
(let [old-val (first old-list) | |
new-val (first new-list) | |
rest-old (rest old-list) |
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 my-update-in | |
[m [k & ks] v] | |
(if (empty? ks) | |
(update m k v) | |
(assoc m k (my-update-in (k m) ks 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
(defn my-assoc-in | |
[m [k & ks] v] | |
(if (empty? ks) | |
(assoc m k v) | |
(assoc m k (my-assoc-in (k m) ks 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
;;The one thing I don't really like about this is that I have to reverse funcs, not sure if there is a more elegant solution | |
(defn my-comp | |
[& funcs] | |
(let [funcs (reverse funcs)] | |
(fn [& args] | |
(reduce #(%2 %1) (apply (first funcs) args) (rest funcs))))) | |
;;this solution from "toolkit" on StackOverflow seems a tad better to me, but I'm not sure how it works... | |
(fn [& fs] |
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
;;I just spent forever and a half writing a function that takes a list of keys and an input map, and validates | |
;;that all keys are present within the input map. I wrote it in two different ways, but they're both ugly as sin. | |
;;Rereading the exercise, I realize that it was actually asking for something different. But whatever, still a useful exercise! | |
;;could probably clarify by making "all-true?" a function, like | |
(defn all-true? | |
[seq] | |
((complement #(some false? %) seq)) | |
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
;;Implemented some using reduce, based on a challenge in Daniel Higginbotham's "Clojure for the Brave and True | |
;;This doesn't really work right; it breaks on lists, and it keeps running through the sequence even after it finds | |
;;a value that passes the predicate... | |
(defn my-some | |
"If the predicate is true for some value, returns that value (implemented with reduce)" | |
[pred sequence] | |
(reduce (fn | |
[x y] | |
(if (pred x) x y)) (conj sequence nil))) | |
NewerOlder