Created
December 23, 2025 13:50
-
-
Save namedgraph/4e5b6b54fa17094f4e0f8fe55bc8d87a to your computer and use it in GitHub Desktop.
SPARQL Christmas tree
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
| PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | |
| SELECT ?line | |
| WHERE { | |
| VALUES ?row { 1 2 3 4 5 6 7 } | |
| # Width of the widest row (9 stars + 2 spaces = 11 total) | |
| BIND(11 AS ?width) | |
| # Calculate number of stars for this row | |
| BIND(IF(?row <= 5, (2 * ?row) - 1, 1) AS ?numStars) | |
| # Calculate spaces on each side | |
| BIND((?width - ?numStars) / 2 AS ?numSpaces) | |
| # Generate the line with balanced spacing | |
| BIND(SUBSTR(" ", 1, ?numSpaces) AS ?spacePart) | |
| BIND(SUBSTR("*********", 1, ?numStars) AS ?starPart) | |
| BIND(CONCAT(?spacePart, ?starPart, ?spacePart) AS ?line) | |
| } | |
| ORDER BY ?row |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment