The goal of this exercise is to extract information about the Berlin metro system from Wikidata and to analyze its relationships with Neo4j.
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
#!/bin/sh | |
# Homebrew Script for OSX | |
# To execute: save and `chmod +x ./brew-install-script.sh` then `./brew-install-script.sh` | |
echo "Installing brew..." | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
echo "Installing brew cask..." | |
brew tap homebrew/cask |
##Examples of Higher-Order Functions in XQuery
Here are a few examples of higher-order functions in XQuery. For more examples, see the very nice discussion of higher-order functions in XQuery 3.0 at the BaseX website.
N.B. In some implementations, these functions may not be implemented or may have different names/function signatures. The first four functions have been tested using Saxon PE and the second four using Zorba.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
using Match | |
# Convert decimal to binary numbers | |
# Compare to bits() function in Julia | |
function tobin(num) | |
@match num begin | |
0 => "0" | |
1 => "1" | |
_ => string(tobin(div(num,2)), mod(num, 2)) | |
end |
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.1"; | |
let $date := "July 15, 2022" | |
let $tokens := fn:tokenize($date, " ") | |
let $month := | |
switch ($tokens[1]) | |
case "January" return "01" | |
case "February" return "02" | |
case "March" return "03" | |
case "April" return "04" |
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
(: Thanks to friends at NashFP, especially Mike K. and Mark Wutka :) | |
declare function local:fibC($n as xs:integer, $memo as map(*), $con) { | |
if (map:contains($memo, $n)) then $con(map:get($memo, $n), $memo) | |
else | |
local:fibC($n - 1, $memo, | |
(: n1 = fib(n - 1) :) | |
function($n1 as xs:integer, $memo as map(*)) { | |
local:fibC($n - 2, $memo, | |
(: n2 = fib(n - 2) :) |
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.1"; | |
declare function local:fac($n as xs:int) as xs:int { | |
if ($n = 0) then 1 | |
else if ($n = 1) then 1 | |
else $n * local:fac($n - 1) | |
}; | |
declare function local:hFac($n as xs:int) as xs:int { | |
fn:fold-right(1 to $n, 1, function($a, $b) { $a * $b }) |
NewerOlder