Skip to content

Instantly share code, notes, and snippets.

@derickson
Last active December 12, 2015 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derickson/4700756 to your computer and use it in GitHub Desktop.
Save derickson/4700756 to your computer and use it in GitHub Desktop.
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