Re: Ann: SWI-Prolog 7.1.0

Aleksey <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <2213724.Puxo9Dp8bt@tarkus>
Hi Jan

Thanks for the explanation, it seems clear for me now

On Saturday 23 November 2013 17:39:14 Jan Wielemaker wrote:
> There are several typical cases. One concerns that you map data from a
> language that can uniquely identify lists from symbols, such as JSON.
> Such languages cannot be mapped naturally to Prolog because it is
> unclear whether [] is some kind of identifier or an empty list. Another
> are expressions such as consult([]), which may mean to consult the file
> '[].pl' or consult nothing. Same for format("", []) with double quotes
> set to 'codes': does this write '' (nothing) or '[]'?
> 
> In practical programming, you have cases where you have a list of
> `tokens' (atoms) and you want to explode some tokens or other special
> symbols into a sequence. The clean way is to use DCGs or difference list
> to create a nice and flat holding the expansion. In some cases however,
> it is way simpler if you can just explode the objects into lists, so you
> get [ 'The', [quick, brown, fox], jumps, over, the, [lazy dog] ].
> 
> This is all fine, until '[]' may appear as a token in the list.  In that
> case, flatten/2 just removes it.  Due to the ambiguity of the empty list,
> creating a multi list and call flatten/2 is considered bad programming.
> Without this ambiguity, using multi lists is safe and can be a handy
> solution, in particular for the not-so-experienced Prolog programmer.
> 
> 	Cheers --- Jan

-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.