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
// 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; |
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
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; |] |
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
#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)) |
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
#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)]) |