Skip to content

Instantly share code, notes, and snippets.

@derickson derickson/color-cycle.xqy
Last active Dec 12, 2015

Embed
What would you like to do?
Cycle light colors
xquery version "1.0-ml";
import module namespace lh = "http://derickson/lib/l-mlhue"
at "/lib/l-mlhue.xqy";
for $i in (1 to 10)
for $state in (
$lh:RED, $lh:MAGENTA, $lh:PURPLE,
$lh:BLUE, $lh:GREEN, $lh:YELLOW,
$lh:ORANGE
)
return (
lh:put-all-state( $state ),
xdmp:sleep(1000)
)
xquery version "1.0-ml";
import module namespace lh = "http://derickson/lib/l-mlhue"
at "/lib/l-mlhue.xqy";
let $loops := 5
let $speed := 500
let $lights := (1 to 3)
let $colors :=
(
$lh:RED, $lh:MAGENTA, $lh:PURPLE,
$lh:BLUE, $lh:GREEN, $lh:YELLOW,
$lh:ORANGE
)
for $x in (1 to $loops)
for $c in (1 to fn:count($colors))
for $l in (1 to fn:count($lights))
return (
lh:put-light-state($lights[$l], $colors[(($c + $l) mod fn:count($colors)) + 1] ),
xdmp:sleep($speed)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.