Change notation3 list realization to non-recursive function.
Fixes issue
@@ -1738,19 +1738,26 @@ class RDFSink(object):
return Literal(s, lang=lang)
def newList(self, n, f):
- if not n:
- return self.newSymbol(
+ nil = self.newSymbol(
'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'
)
+ if not n:
+ return nil
- a = self.newBlankNode(f)
first = self.newSymbol(
'http://www.w3.org/1999/02/22-rdf-syntax-ns#first'
)
rest = self.newSymbol(
- 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest')
- self.makeStatement((f, first, a, n[0]))
- self.makeStatement((f, rest, a, self.newList(n[1:], f)))
+ 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest'
+ )
+ a = self.newBlankNode(f)
+
+ for ne in n:
+ self.makeStatement((f, first, a, ne))
+ an = self.newBlankNode(f)
+ self.makeStatement((f, rest, a, an, f))
+ a = an
+ self.makeStatement((f, rest, a, nil, f))
return a
def newSet(self, *args):
