This file contains hidden or 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
| let $f := function($a){upper-case($a)} | |
| let $data := ("test","test2","test3") | |
| return | |
| $data ! $f(.) | |
| will result in | |
| ("TEST", "TEST2", "TEST3") | |
| http://www.w3.org/TR/xquery-30/#id-map-operator |
This file contains hidden or 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 "1.0-ml"; | |
| let $map := map:map() | |
| let $_ := map:put($map,"test","test") | |
| let $data:= map:get($map,?) | |
| return | |
| $data('test') |
This file contains hidden or 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 "1.0-ml"; | |
| declare option xdmp:mapping "true"; | |
| let $map1:= map:map() | |
| let $_ := map:put($map1,'a',xs:float(1.0)) | |
| let $_ := map:put($map1,'b',xs:float(1.0)) | |
| let $_ := map:put($map1,'c',xs:float(1.0)) | |
| let $_ := map:put($map1,'d',xs:float(1.0)) | |
| let $_ := map:put($map1,'e',xs:float(1.0)) | |
| let $_ := map:put($map1,'f',xs:float(2)) |
This file contains hidden or 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"; | |
| declare function local:mapReduce( | |
| $list as item()*, | |
| $mapper as function(*), | |
| $reducer as function(*) | |
| ) | |
| { | |
| let $intermediate := for $l at $pos in $list return $mapper("list" || $pos,$l) | |
| return |
This file contains hidden or 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
| In a lot of cases, gzipping content before you send it to an HTTP client can make a huge difference in download times. | |
| compare downloaded file size of the following two approaches; | |
| xquery version "1.0-ml"; | |
| let $page :=<html> | |
| <body> | |
| <h2>Without Gzip</h2> |
This file contains hidden or 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
| let $doc := <root xml:base="http://example.org/mydoc"></root> | |
| return | |
| base-uri($doc) |
This file contains hidden or 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"; | |
| let $makeFact := function($givenFact) { | |
| let $fact := function($n) { | |
| if( $n lt 2 ) | |
| then 1 | |
| else $n * $givenFact($n - 1) | |
| } | |
| return $fact | |
| } |
This file contains hidden or 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"; | |
| let $makeFactorialFunc := function($givenFactFunc) { | |
| let $fact := function($n) { | |
| if( $n lt 2 ) | |
| then 1 | |
| else $n * $givenFactFunc($n - 1) | |
| } | |
| return $fact | |
| } |
This file contains hidden or 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 "1.0-ml"; | |
| let $data := (1,1,1,1,1,1,1,1,1,20) | |
| let $choose := xdmp:random( sum($data) ) | |
| let $pos := filter( function($a){if($choose le sum($data[1 to $a])) then true() else false()}, 1 to count($data) )[1] | |
| return "weighted choose: " || $choose || " | data position: " || $pos || " value: " || $data[$pos] |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Frameless Example</title> | |
| <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> | |
| <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> | |
| </head> | |
| <body> | |
| <div> |