Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!news.duq.edu!newsgate.duke.edu!news.mathworks.com!news-peer.gsl.net!news.gsl.net!mr.net!news-out.communique.net!uunet!in3.uu.net!uucp2.uu.net!sangam!konark!saathi.ncst.ernet.in!sasi
From: Sasikumar M <sasi@saathi.ncst.ernet.in>
Subject: Re: Simple Question
In-Reply-To: <5d6gq4$soc@morgoth.sfu.ca>
X-Nntp-Posting-Host: saathi.ncst.ernet.in
Content-Type: TEXT/PLAIN; charset=US-ASCII
Message-ID: <Pine.ULT.3.94.970210133429.21842F-100000@saathi.ncst.ernet.in>
To: Dave Parchomchuk <parchomc@sfu.ca>
Sender: news@konark.ncst.ernet.in (News Administration)
Organization: National Centre for Software Technology, Bombay, India
References: <5d6gq4$soc@morgoth.sfu.ca>
Mime-Version: 1.0
Date: Mon, 10 Feb 1997 08:06:10 GMT
Lines: 22



> I would like to write a simple predicate that does the following:
> 
> ?- text(hello123,Text)
> Text = "hello" 
> ?- number(hello123,Number)
> Number = "123"
> 

One way is the following:

   Using the name predicate you can convert the atom to a string
[h,e,l,l,o,1,2,3], then you can scan this suitably to create a
sub-list of what is required. This can be converted back to an atom
by name.

I am not sure if there is a better way of doing this!

 -Sasikumar


