I thought it would be a fun challenge to write a program which generates a melody using an L-System, since they are not used too often in music creation. I couldn’t find any other instances of using fractals and music in this way so I explored l-system code that is used to generate drawings and applied that to music. I wrote this program as a plugin for Musescore which had the added benefit practicing Javascript. I created it as a compositional tool, and the rule set can be changed to generate different melodies. The rule set I used is one that is usually used in visual art to generate Koch curves (via wikipedia):
A variant of the Koch curve which uses only right angles.
variables : F
constants : + −
start : F
rules : (F → F+F−F−F+F)
Here, F means “draw forward”, + means “turn left 90°”, and − means “turn right 90°” (see turtle graphics).n = 0:F

n = 1:F+F−F−F+F

n = 2:F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F

n = 3:F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F+F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F−F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F−F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F+F+F−F−F+F+F+F−F−F+F−F+F−F−F+F−F+F−F−F+F+F+F−F−F+F

The melody generator interprets each “F” as a note and each “+” or “-” as going up or down a pitch. I set my start note to “C4”, confined the melody to only move up and down the C pentatonic scale and created the score below using the Koch curve ruleset as seen above. It can technically go on forever, so I limited the score to 51 measures.

Update: This is available as an npm package too!