Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!caen!sdd.hp.com!wuarchive!uunet!mcsun!ukc!canon!imlah From: imlah@canon.co.uk (Bill Imlah) Newsgroups: comp.lang.prolog Subject: Re: converting ascii character lists to functors Message-ID: <1991Apr22.102405.18983@canon.co.uk> Date: 22 Apr 91 10:24:05 GMT References: Distribution: comp Organization: Kenny's Fish Bar (Turbot with a Smile) Lines: 27 eiverson@nmsu.edu (Eric Iverson) writes: >>| ?- name('loves(John,Mary,John)',X),functor_chars(F,X). >X = [108,111,118,101,115,40,74,111,104,110,44,77,97,114,121,44,74,111,104,110,41], >F = loves(_3569,_3590,_3569) ; >Can you think of a way to do this which does not involve writing to, >reading from, and then removing a file? From the unification of args 1 & 3 in your example output, I assume you want to parse the whole term rather than just get the functor. If you can't force Quintus to parse it, you could analyse the term yourself and avoid i/o completely. However, if the form of the term is unconstrained you will find yourself implementing a prolog parser (you may be able to get hold of such code in a s/w library or textbook). Alternatively, some prologs provide access to the parser. Eg. BIMprolog's sread/2 reads a term from an atom. -------------------------------------------------------- Bill Imlah imlah@canon.co.uk Canon Research Centre Europe, 17/20 Frederick Sanger Rd. The Surrey Research Park, Guildford, Surrey, GU2 5YD, UK. Disclaimer: I ain't no Quintus expert.