Skip to content

Elegant way of filtering sets in sparql like style #66

@CICS-Oleg

Description

@CICS-Oleg

Consider we have example database and query in sparql:

:book1  dc:title  "SPARQL Tutorial" .
:book1  ns:price  42 .
:book2  dc:title  "The Semantic Web" .
:book2  ns:price  23 .
SELECT  ?title ?price
WHERE   { ?x ns:price ?price .
          FILTER (?price < 30.5)
          ?x dc:title ?title . }

The resul would be:

title	price
"The Semantic Web"	23

Let's try to reproduce this example in metta. Database will look like this:

(book1 title sprql-tutorial)
(book1 price 42)
(book2 title semantic-web)
(book2 price 23)

The question is: do we have more elegant way to gain the same result than using code below?

!(match &self ($x price $y)
            (if (< $y 30.5)
            (match &self ($x title $z) ($z $y))
            Empty))

The result would be just what we need:

[(semantic-web 23)]

Metadata

Metadata

Labels

answeredTutorial question is answered but not added to docsquestionFurther information is requestedtutorialTutorial question

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions