Compare commits

..

3 Commits

3 changed files with 66 additions and 0 deletions

37
Rainbow/rainbow.js Normal file
View File

@ -0,0 +1,37 @@
// Approximate racket functions
function circle(color) {
print(`${color} circle`)
}
function square(color) {
print(`${color} square`)
}
function print(shape) {
console.log(shape)
}
// Cuz javascript doesn't have functional primitives
function first(list) {
return list[0]
}
function rest(list) {
return list.slice(1)
}
// Helper to cycle through the functions
function cycle(list) {
return rest(list).concat(first(list))
}
// The actual function
function rainbow(...functions) {
let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']
function rainbowRecursive(functions, colors) {
if (colors.length === 0) {
return
}
first(functions)(first(colors))
rainbowRecursive(cycle(functions), rest(colors))
}
rainbowRecursive(functions, colors)
}
rainbow(circle, square)

17
Rainbow/rainbow.rkt Normal file
View File

@ -0,0 +1,17 @@
#lang racket
(require pict)
(require pict/color)
; The actual function
(define (rainbow . shapes)
(define colors (list red orange yellow green blue purple))
(define (cycle lst) (append (rest lst) (list (first lst))))
(define (rainbow-recursive shapes colors)
(cond
[(empty? colors) (void)]
[(print((first colors) (first shapes)))
(rainbow-recursive (cycle shapes) (rest colors))]
)
)
(rainbow-recursive shapes colors))
; Example usage
(rainbow (filled-rectangle 25 25) (filled-ellipse 25 25))

12
VolumeFix/VolumeFix.ahk Normal file
View File

@ -0,0 +1,12 @@
; Fix Windows Volume:
$Volume_Up::
SoundGet, volume
Send {Volume_Up}
SoundSet, volume + 1
Return
$Volume_Down::
SoundGet, volume
Send {Volume_Down}
SoundSet, volume - 1
Return