Rosetta Code/Find unimplemented tasks: Difference between revisions
Content deleted Content added
m →{{header|Wren}}: Updated site URL and reran. |
|||
Line 932:
Find limit of recursion
...</pre>
=={{header|hq}}==
This script illustrates how jq interoperates with other command-line tools. It was tested in October, 2022
using both the C and Go implementations of jq.
The only pre-requisites other than bash are curl and jq, which is called at least four times.
<syntaxhighlight lang="bash">
#!/bin/bash
# October 8, 2022
# https://rosettacode.org/w/index.php?title=Rosetta_Code/Find_unimplemented_tasks
# Syntax: $0 [--markdown] CATEGORY
# Fetch the Category:Programming_Tasks and Category:$category pages,
# then compute the differences in the lists of titles.
# If --markdown is specified, then some markdown suitable for RosettaCode.org is added.
BN=$(basename "$0")
JQ=jq
function die { echo "$BN: $@" >&2 ; exit 1 ; }
baseuri="https://rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:"
if [ "$1" = "--markdown" ] ; then
markdown="--argjson markdown true"
shift
else
markdown="--arg markdown false"
fi
category="$1"
test -z "$category" && die "Syntax: $0 [--markdown] CATEGORY"
for id in $category Programming_Tasks; do
id=/tmp/rosettacode.$id.titles.json
test -s "$id" && rm "$id"
done
function getall {
local cat="$1"
local cmcontinue="$2"
local tmpfile="/tmp/rosettacode.$cat.json.tmp"
local continue=true
# cmlimit=500 is the max allowed so use paging
curl -Ss "${baseuri}${cat}&format=json&cmlimit=500${cmcontinue}" > "$tmpfile"
if [ ! -s "$tmpfile" ] ; then return ; fi
$JQ '.query.categorymembers[].title' "$tmpfile" >> /tmp/rosettacode.$cat.titles.json
cmcontinue=$($JQ -r '.continue | if . then .cmcontinue else null end' "$tmpfile" )
if [ -z "$cmcontinue" -o "$cmcontinue" = "null" ] ; then return ; fi
echo $BN: fetching continuation page for $cat ...
getall "$cat" "&cmcontinue=$cmcontinue"
}
getall $category
getall Programming_Tasks
for id in $category Programming_Tasks; do
id=/tmp/rosettacode.$id.titles.json
test -s "$id" || die "unable to find $id"
done
$JQ -r -n $markdown --slurpfile tasks /tmp/rosettacode.Programming_Tasks.titles.json \
--slurpfile cat /tmp/rosettacode.$category.titles.json '
def mark: if $markdown then "* [[\(gsub(" ";"_"))|\(.)]]" else . end;
($tasks - $cat)[] | mark '
</syntaxhighlight>
=={{header|Julia}}==
|