Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implementation details to randomize #318

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _sections/30-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ For convenience, the functions are categorized based on their main usage. Some f
<a id="fn:position" href="#fn:position">`position(node arg?)`</a> | number | Deviates from [XPath 1.0](https://www.w3.org/TR/1999/REC-xpath-19991116/#function-position) in that it accepts an argument. This argument has to be a single node. If an argument is provided the function returns the position of that node amongst its siblings (with the same node name).
<a id="fn:instance" href="#fn:instance">`instance(string id)`</a> | node-set | As in [XForms 1.0](https://www.w3.org/TR/2003/REC-xforms-20031014/slice7.html#fn-instance). Note that it doesn't switch the document root for predicates. E.g. in `instance('cities')/item/[country=/data/country]`, the `/data/country` path still refers to the primary instance.
<a id="fn:current" href="#fn:current">`current()`</a> | node-set | As in [XForms 1.1](https://www.w3.org/TR/xforms11/#fn-current). Used inside predicates of expressions that use instance() to enable referring to a node relative to the context of the _current_ question. E.g. as in `instance('countries')/item[name=current()/../name]/capital`).
<a id="fn:randomize" href="#fn:randomize">`randomize(node-set arg, number seed)`</a> | node-set | Shuffles the node-set argument using the ["inside-out" variant of the Fisher-Yates algorithm](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_%22inside-out%22_algorithm). The optional seed argument performs a (reproducible) shuffle using the same algorithm with a _seeded_ Park Miller Pseudo Number Generator.
<a id="fn:randomize" href="#fn:randomize">`randomize(node-set arg, number seed)`</a> | node-set | Shuffles the node-set argument using the ["inside-out" variant of the Fisher-Yates algorithm](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_%22inside-out%22_algorithm). The optional seed argument performs a (reproducible) shuffle using the same algorithm with a _seeded_ Park Miller Pseudo Number Generator. If the seed value is decimal, it is truncated to the nearest whole number. If the seed value is `NaN` when converted to numeric, the raw value is encoded as UTF-8, hashed with sha256, and the first 8 bytes are used as the seed.
<a id="fn:Date-and-Time-Functions" href="#fn:Date-and-Time-Functions">**Date and Time Functions**</a>|||
<a id="fn:today" href="#fn:today">`today()`</a> | string | Returns a string with today's local date in the format described under the [date datatype](#data-types).
<a id="fn:now" href="#fn:now">`now()`</a> | string | Deviates from [XForms 1.0](https://www.w3.org/TR/2003/REC-xforms-20031014/slice7.html#fn-now) in that it returns the current date and time _including timezone offset_ (i.e. not normalized to UTC) as described under the [dateTime datatype](#data-types).
Expand Down