Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Sum example to be on a sequence of lists #122

Closed
wants to merge 1 commit into from
Closed

Conversation

Tpt
Copy link
Contributor

@Tpt Tpt commented Sep 21, 2023

The other examples where fixed but Sum seemed to have slipped

Errata https://www.w3.org/2013/sparql-errata#errata-query-22 Issue #24


Preview | Diff

The other examples where fixed but Sum seemed to have slipped

Errata https://www.w3.org/2013/sparql-errata#errata-query-22
Issue #24
@hartig
Copy link
Contributor

hartig commented Sep 21, 2023

It did not slip when I touched these parts in PR #98. In contrast, earlier the example said:

"In this way, Sum(1,2,3) = ..."

and I changed it to:

"In this way, Sum( (1,2,3) ) = ..."

Notice that the function name Sum is actually overloaded in this whole definition; that is, there are actually two functions called Sum:

One of them is the one that the definition is meant to define, which takes as argument a sequence S that consists of lists of values; i.e., S is of the form [ L1, L2, ..., Ln ] where each Li is a list of values, and [ (1), (2), (3) ] is a concrete example of such a sequence (containing exactly three lists where each of them contains one value).

The other function called Sum takes as argument a single list of of values; i.e., (1,2,3) is a concrete example of such a list (containing three values). This second Sum is introduced in the definition as a helper construct to define the first Sum function. That is, the line "Sum(S) = Sum(L)" in the definition defines the first Sum function by using the second one, and the three lines that start with "Sum(L) = ..." define the second Sum function.

Now, the way I wrote the example assumes that this is an example of the second Sum function (i.e., the one that takes a single list of values as argument). The change in your PR assumes that this is an example of the first Sum function. In that sense, both ways of writing the example are correct because of the ambiguity of the function name.

A way to resolve this ambiguity would be to introduce a different name for the second Sum function (the helper construct). For instance, it may be renamed to Sum'. Perhaps it is useful to do that? Let me know if you want me to do it and I can add a corresponding commit into this PR.

(As a side note, when writing this comment I realized that I did make a mistake in PR #98, but that one is in the definition of the 'Flatten' function. I will create another PR with a fix for this issue.)

@TallTed
Copy link
Member

TallTed commented Sep 22, 2023

Unless I'm misreading things (always possible), there really is only one Sum() function, and it's the argument structure that varies in complexity — it may be a single list, or a list of lists — and the latter form may collapse to the former when the list-of-lists has a single member, i.e., the outer parentheses collapse when they enclose a single inner set.

This is not the simplest thing to explain, but I think it will likely be better understood than Sum() and Sum'() or any other pair of Sum() and helperSum().

@hartig
Copy link
Contributor

hartig commented Sep 22, 2023

No, for me it is two different functions. They have different domains. The domain of the first function is the set of lists of lists (or sequences of lists, as it is called in the spec) and the domain of the second function is the set of lists.

Also, the collapsing does not happen magically or implicitly. Instead, that's what the Flatten function is for.

@hartig
Copy link
Contributor

hartig commented Sep 22, 2023

I have created PR #124 to illustrate how I think the definition of the Sum function should be improved and how the corresponding example can be presented.

@Tpt
Copy link
Contributor Author

Tpt commented Sep 22, 2023

Notice that the function name Sum is actually overloaded in this whole definition; that is, there are actually two functions called Sum:

Thank you so much for the explanation! I got confused by it. I am closing this MR, #124 is definitely much better.

@Tpt Tpt closed this Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants