More thoughts about list:append

Dear all,

Motivated by our discussion yesterday, I further thought about list:append and how it should (not) act. In our discussion, it was stated that we should support a construct like

?x list:append (1 2 3).

(of course in the body of a rule). I just wanted to say that this is not possible because there are infinitely many solutions for that and I think this is also why this is not supported by Prolog. So, to be more concrete, we get:

?x = (()(1 2 3) )
?x= (()()(1 2 3))
?x = (() () () (1 2 3) )
…

So, this is something we would like to avoid and therefore, the subject of our triple alway needs to be a list (which can contain variables).

If we have that, we come back to our open discussion point, whether we should be able to use append to decompose a list. In prolog, this option is mainly interesting if you process lists with backward rules. To just provide an easy example, I constructed a function :remove using list:append which removes the element you name from a list http://ppr.cs.dal.ca:3002/n3/editor/s/QcJ0q5Fv 
I think that append is a very useful tool to deal with lists and that is the point of the example. 

To also include the other line of thoughts here, I guess that the reverse use of append is difficult to implement if we have several answers, right? We already get this problem if I slightly vary my ad-hoc example here and add the argument to remove twice, like here: http://ppr.cs.dal.ca:3002/n3/editor/s/kpR8cgVs


So for my applications, I would add more rules to deal with that (it depends on the use case whether multiple answers are a problem). 

Append is a very powerful tool if we deal with lists and that is why I like it. The question is how important the good support for lists is in your opinion.

I would also like to better understand why the decomposing function is a problem. 

Is it a problem because you are afraid of users not understanding the complexity of the built-in?
Is it a problem because it is difficult to implement with an imperative language?
Is it a problem because you do not see the benefits (careful, if you say yes here, you might get many more examples ;) )?

So, please explain the problem. I think we did not get to the core of it in our meeting and it would be good to better understand each other before we take a decision here.

Kind regards,
Dörthe

Received on Tuesday, 6 December 2022 14:47:49 UTC