Newsgroups: comp.lang.prolog Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!news.UVic.CA!sanjuan!notscott From: notscott@sanjuan (Scott Notenberg 8792) Subject: Re: converting ascii character lists to functors Message-ID: Sender: news@sol.UVic.CA Nntp-Posting-Host: sanjuan.uvic.ca Organization: University of Victoria References: Distribution: comp Date: 20 Apr 91 21:14:20 GMT eiverson@nmsu.edu (Eric Iverson) writes: >I called today about converting ascii character lists into functors >which could be unified with other functors. I need to do this because >I need to use a character based read function for my file I/O. >| ?- 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) ; >------------------------------------------------------------------------ >Eric Iverson Internet: eiverson@nmsu.edu ASSUMPTION: The predicate concat(A,B,AB) is available for symbols (quoted strings). Why not simply do the following... ?- name('loves(John,Mary,John)',X), collectUntil(X,40,F) which concats characters (recursively backwards so functor name isn't backwards) to an Accumulator until the ascii '40' is found from the list X. This should work, but who knows I don't use Quintus. Hope this helps... +----------------------------+ +-----------------------------------------+ /| Scott Notenberg (notscott) | | INTERNET : notscott@sanjuan.UVic.ca | $| Department of Comp Science |-| BITNET : notscott@uvunix.bitnet | $| University of Victoria |-| UUCP : {ubc-vision,uw-beaver}!uvicctr! | $| Home : (604) 384-8632 |-| SNAIL : 416-1243 Bay Street, | $| Office : (604) 721-8792 | | Victoria, BC Canada V8T 4X4 | $+----------------------------+ +-----------------------------------------+ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$/