Skip to content

Instantly share code, notes, and snippets.

View codybartfast's full-sized avatar
🐭
Lovely Crinkly Edges

John Donnellan codybartfast

🐭
Lovely Crinkly Edges
View GitHub Profile
@codybartfast
codybartfast / Heaps_Permutation_Algorithm_C#
Created April 18, 2023 06:01
Heap's Permutation Algorithm
// Heap's Algorithm: https://en.wikipedia.org/wiki/Heap%27s_algorithm
// Returns mutated versions of the provided array
public static IEnumerable<T[]> HeapsPermutations<T>(T[] array)
{
var state = new int[array.Length];
yield return array;
open System
[<Measure>]
type bd // base duration
type Mark = Plain of int<bd> | Partial of int<bd>
type Measure = Mark list
let noteFractions = [| 1; 2; 4; |]
#lang racket
;; an infinite stream of recurring notes
(define notes (list 'c 'cs 'd 'ds 'e 'f 'fs 'g 'gs 'a 'as 'b))
(define (repeat items)
(for*/stream ([_ (in-naturals 1)]
[item items])
item))
(define note-stream (repeat notes))
@codybartfast
codybartfast / progression.rkt
Created June 19, 2019 07:20
Transliteration of Other_Harmony_Python_Exercises
#lang racket
(define (advancing-progression-original)
(for* ([c (in-range 3 7)]
[b (in-range 2 c)]
[a (in-range 1 b)])
(display (list a b c))))
(define (advancing-progression-one)
(for* ([c (in-range 3 7)])