Re: what's the corresponding predcate as atomic_list_concat in swi

z_axis <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Organization zsoft
Message-ID <[email protected]>
Can it convert '1 2 3 4 5 6 7' to [1,2,3,4,5,6,7] ?
IIRC,in swi, atomic_list_concat('1 2 3 4 5 6 7', ' ', X).  => X =  
[1,2,3,4,5,6,7]

Best Regards!
在 Thu, 27 Jun 2013 02:22:15 +0800,Daniel Diaz  
<[email protected]> 写道:

> Hi,
>
> the easiest way to convert numbers to atoms and then use atom_concat/3.  
> This should work:
>
> atomic_concat(X1, X2, A3) :-
> 	to_atom(X1, A1),
> 	to_atom(X2, A2),
> 	atom_concat(A1, A2, A3).
>
> to_atom(A, A) :-
> 	atom(A), !.
>
> to_atom(X, A) :-
> 	number_atom(X, A).
>
>
> Daniel
>
> Le 26 juin 2013 à 08:39, Sean Charles <[email protected]> a écrit :
>
>> Hi z_axis,
>>
>> I looked long and hard and I couldn't find anything suitably matched in  
>> the atom and character code sections … sorry.
>>
>> I think somebody that *knows* the language has an opportunity to  
>> hand-roll something at this point… I will also try to do this as an  
>> exercise, it will be good to try.
>>
>> My initial thought would be to use a stream writing to an atom, then  
>> write each atom in the original list plus the intervening comma for all  
>> but the last atom.
>>
>>    open_output_atom_stream ...
>>    write_term_to_atom  … each list member plus a comma
>>    close_output_atom_stream ...
>>
>> Simples. Except I just have to do it. And if it could be used  
>> "backwards" to split the atom then so much the better, like SWI.
>>
>> I am sure somebody else will do it first but I like the look of this so  
>> I shall try as well.
>>
>> Sean.
>>
>>
>>
>>
>> On 26 Jun 2013, at 03:15, z_axis <[email protected]> wrote:
>>
>>> It seems there is just atomic_concat in gprolog ?
>>> Mime-Version: 1.0
>>> Content-Type: Text/Plain; charset=iso-8859-7
>>> Content-Transfer-Encoding: base64
>>> X-CM-TRANSID:C8CowEApvUUWT8pR28F5Cw--.21S2
>>> X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73
>>> 	VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxU2t8nUUUUU
>>> X-CM-SenderInfo: x2bd5xrv6rljoofrz/1tbiThZIZlEAFN07UAABsE
>>>
>>> ZV4o8C5pKSArIDEgPSAwDQo=
>>>
>>>
>>> _______________________________________________
>>> Users-prolog mailing list
>>> [email protected]
>>> https://lists.gnu.org/mailman/listinfo/users-prolog
>>
>>
>> _______________________________________________
>> Users-prolog mailing list
>> [email protected]
>> https://lists.gnu.org/mailman/listinfo/users-prolog
>>
>> --
>> Ce message a ete verifie par MailScanner
>> pour des virus ou des polluriels et rien de
>> suspect n'a ete trouve.
>>
>
>


-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/


_______________________________________________
Users-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/users-prolog
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.