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 "1.0-ml"; | |
(: xquery memoization example for use with MarkLogic :) | |
declare variable $cache := map:map(); | |
declare function local:factorial($n as xs:integer) as xs:integer { | |
if ($n < 0) then | |
(0) | |
else if ($n = 0) then |
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 "1.0"; | |
(: The idiv operator returns an integer as a result, rounding toward 0. :) | |
let $a as xs:decimal := 20.1 | |
let $b as xs:decimal := 1.678 | |
let $result := $a idiv $b | |
return | |
$result |
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
(: xml:id attribute needs to be unique within the specific document scope :) | |
let $xml := document{ <employees> | |
<employee xml:id="n001"> | |
<name>Johny Rotten</name> | |
</employee> | |
<employee xml:id="n002"> | |
<name>Billy Idol</name> | |
</employee> | |
</employees>} |
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
(: simple - http://e-blog-java.blogspot.com/2010/03/determine-prime-numbers-with-xquery.html :) | |
<primes> | |
{ | |
for $a in (2 to 1000) | |
return( | |
if(not(some $counter in (2 to ($a - 1)) satisfies $a mod | |
$counter=0)) then {$a} | |
else {$a} | |
) | |
} |
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 "1.0-ml"; | |
declare variable $flush := 1; | |
declare function local:queue($map){ | |
if ($flush eq 1 or fn:empty(xdmp:get-server-field('queue'))) then | |
let $queue as map:map := map:map( if ($map) then $map else <map:map/>) | |
let $serverfield := xdmp:set-server-field('queue',$queue) | |
return | |
$queue |
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
i've interpreted what you may want to achieve, but mileage may vary | |
xquery version "1.0"; | |
let $string := "test,test,test,test,test" | |
return | |
for $text in tokenize($string,',') | |
return | |
<text>{concat('add some text: ', $text)}</text> |
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
cd /to/your/application/directory | |
/Applications/depx-0.1/depx | |
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
for $n in (1 to 100) | |
let $fizz := if ($n mod 3) then () else "fizz" | |
let $buzz := if ($n mod 5) then () else "buzz" | |
return | |
if ($fizz or $buzz) then concat($fizz,$buzz) else $n |
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
I installed R via brew e.g. | |
>brew install R | |
which complained it needed fortran compiler which was solved with | |
>brew install gfortran | |
then re ran brew R installation and no problems. |
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
R is an object-oriented language with every object having a type (and being a member of a class) | |
*** What is R written in ? | |
R itself, c and fortran (autoconf, shell script) | |
http://blog.revolutionanalytics.com/2011/08/what-language-is-r-written-in.html | |
though some R packages are in c++, Perl, etc |
OlderNewer