Created
July 18, 2013 00:43
-
-
Save CliffordAnderson/6025846 to your computer and use it in GitHub Desktop.
Fizz Buzz in XQuery
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
xquery version "3.0"; | |
(: Fizz Buzz in XQuery :) | |
for $i in (1 to 30) | |
return | |
if ($i mod 3 = 0 and $i mod 5 = 0) then "fizzbuzz" | |
else if ($i mod 3 = 0) then "fizz" | |
else if ($i mod 5 = 0) then "buzz" | |
else $i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Cliff, I revisited the FizzBuzz puzzle on my way into work today (think we had this as an XQuery class assignment years ago). Happy to find we came up with the same solution in XQuery!
xquery version "1.0-ml";
(: FizzBuzz puzzle :)
for $num in (1 to 100)
return
if ($num mod 3 = 0 and $num mod 5 = 0) then
"FizzBuzz"
else if ($num mod 3 = 0) then
"Fizz"
else if ($num mod 5 = 0) then
"Buzz"
else $num