Changes

Jump to navigation Jump to search
120 bytes removed ,  18:35, 1 December 2023
m
Text replacement - "</syntaxhighlight>" to "</pre>"
(: NEW :) $s ! 'OK'
)
</syntaxhighlightpre>
In some cases, also the first solution can be written more compact. If we know that our input will always have 0-1 items, we can write <code>if(exists($s))</code>. If our input will never be an empty string, a zero, etc, it’s sufficient to write <code>if($s)</code>.
(: NEW :) ($s, 'default')[1]
)
</syntaxhighlightpre>
Note that this only works if both of your inputs have zero or one items.
attribute { "about" } { $value }, $contents
}
</syntaxhighlightpre>
The result is an XML fragment with <code>&lt;element&gt;</code> as root node:
<foo>Bar!</foo>
</element>
</syntaxhighlightpre>
== Transform List to Tree ==
</entries>
return local:link($entries/entry, 'entry1')
</syntaxhighlightpre>
results in
<syntaxhighlight lang="xml">
</entry>
</entry>
</syntaxhighlightpre>
== IP-Converter ==
function($n, $d) { 256 * $n + $d }
)
</syntaxhighlightpre>
results in
<syntaxhighlight lang="xml">
2250433089
</syntaxhighlightpre>
== Count number of files ==
<pre lang='xquery'>
basex "count(file:list('.',true(),'*.jpg'))"</syntaxhighlightpre>
The Linux equivalent is
<syntaxhighlight lang="xml">
find . | grep \.jpg$ | wc -l
</syntaxhighlightpre>
Bureaucrats, editor, reviewer, Administrators
13,551

edits

Navigation menu