What is (not) a closed list?

This is a discussion on What is (not) a closed list? within the PROLOG forums in Programming Languages category; I know that [a,b,c] is a closed list and that [a,b|X] is an open list. What about [a,b|c] ? Is that open or closed (or not a list at all)? I presume a standard defn for a list/1 test would be list([]). list([_|_]). so that would make [a,b|c] a list or should such a test be recursive? Then the question would then be does [a,b|X] pass the test (even if X is instantiated to c). Is there a standard name for lists constructed from "cons" operators whose "ultimate tail" is [] - e.g. lists like [a,b,c] as opposed to [a,b|X] ...

Go Back   Application Development Forum > Programming Languages > PROLOG

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-26-2008, 10:26 PM
Peter Robinson
Guest
 
Default What is (not) a closed list?



I know that [a,b,c] is a closed list and that [a,b|X] is an open list.
What about [a,b|c] ? Is that open or closed (or not a list at all)?

I presume a standard defn for a list/1 test would be

list([]).
list([_|_]).

so that would make [a,b|c] a list

or should such a test be recursive?

Then the question would then be does [a,b|X] pass the test (even if X
is instantiated to c).

Is there a standard name for lists constructed from "cons" operators
whose "ultimate tail" is [] - e.g. lists like [a,b,c] as opposed to
[a,b|X] or [a,b|c] - is that what a closed list really is?

Peter
Reply With Quote
  #2  
Old 08-27-2008, 06:25 AM
Ulrich Neumerkel
Guest
 
Default Re: What is (not) a closed list?

Peter Robinson <pjr@itee.uq.edu.au> writes:

>I know that [a,b,c] is a closed list and that [a,b|X] is an open list.
>What about [a,b|c] ? Is that open or closed (or not a list at all)?


Standard terminology is:

[a,b,c] ... list
[a,b|X] ... partial list
[a,b|c] ... neither a list nor a partial list

So there are instances of partial lists that are
neither lists nor partial lists.

Note, that also X alone is a partial list.



The notion open is used for streams and syntax only.


In jargon - not standard terminology - the last
is sometimes called a malformed list. The [b|c] is also
referred to as a dotted pair (~ Lisp-terminology).
Reply With Quote
  #3  
Old 08-27-2008, 08:38 AM
Carlo Capelli
Guest
 
Default Re: What is (not) a closed list?

I think the terminology covering the topic could be 'incomplete data
structures'.
This refer to the tecnique used, for instance, for 'difference lists', where
the logical variables allow interesting behaviour, loosely related to lazy
evaluation (googling for 'difference lists', see for example
http://www.cs.cmu.edu/~fp/courses/lp...es/11-diff.pdf).

Anyway, a list [a,b|c] is incorrect (IMO) in the sense that the algorithms
normally applied (i.e. append) don't perform the expected task.
This is a consequence of the fact that a list is simply syntax sugar for the
'dotted pair' notation, al Ulrich pointed out, and the algorithms are coded
against the most useful nil (i.e. []) terminated list.

Bye Carlo

"Peter Robinson" <pjr@itee.uq.edu.au> ha scritto nel messaggio
news:newscache$xrm86k$fz8$1@lbox.itee.uq.edu.au...
>
>
> I know that [a,b,c] is a closed list and that [a,b|X] is an open list.
> What about [a,b|c] ? Is that open or closed (or not a list at all)?
>
> I presume a standard defn for a list/1 test would be
>
> list([]).
> list([_|_]).
>
> so that would make [a,b|c] a list
>
> or should such a test be recursive?
>
> Then the question would then be does [a,b|X] pass the test (even if X is
> instantiated to c).
>
> Is there a standard name for lists constructed from "cons" operators whose
> "ultimate tail" is [] - e.g. lists like [a,b,c] as opposed to [a,b|X] or
> [a,b|c] - is that what a closed list really is?
>
> Peter



Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:03 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.