Solutions

MarkLogic Data Hub Service

Fast data integration + improved data governance and security, with no infrastructure to buy or manage.

Learn More

Learn

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

Community

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

Company

Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

Fun With XQuery

by Jason Booth

Recently on a flight, I decided to put an idea to the test with programming in XQuery. I wanted to write a simple logic puzzle of some sort – what I ended up doing was writing a simple card dealing program. XQuery 1.0, along with MarkLogic extensions to the language (the “xquery version 1.0-ml” dialect), provides some great programming capabilities. The following example shows the usage of maps, recursion, logging (via xdmp:log()), random numbers (via xdmp:random()) and side effects (via xdmp:set()).
 
Why I don’t expect that a poker site, nor the latest strategy game, will be written in XQuery, it is refreshing to see any language used for something you normally wouldn’t use it for. Often, when doing so a developer can learn something new about a language when they look at it in a different context. Also, I hope the following example will show those new to XQuery a look at the language that they may not get to see in other tutorials or examples.

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.