🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1284

Re: Standards question: behavior of arg/3

#1284
From: Lee Naish
Date: Fri, 19 Oct 1990 09:18
28 lines
1416 bytes
In article <brahme.656264677@vlsic2> brahme@vlsic2.ti.com (Dan Brahme) writes:
>If the ISO standard arg(N, Term, Arg) reports error when N is greater
>than the arity, it is a nuisance. 
>
>Then we cannot do 
>  bagof(Arg, N^arg(N, Term, Arg), Args).

Sorry to be pedantic, but you can't do that anyway in most systems (see
other postings on this topic).

>or
> bagof(Arg, N^(positive_integer(N), arg(N, Term, Arg)), Args). 
>  where positive_integer is
>  positive_integer(1).
>  positive_integer(N) :- positive_integer(N1), N is N1 + 1.

This code loops.

One way to do it properly is to use functor/3 to get the arity, then use
this as a bound on the integers you generate (use between/3 in Quintus
or iota in NU-Prolog).

However, if you really want to get a list of all the args in a term you
do not want to use bagof.  There is already a builtin for that:

	Term =.. [Functor | Args]

	lee
Technical Details
Message-ID: <5817@munnari.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!olivea!samsung!munnari.oz.au!lee
References: <9888@bunny.GTE.COM> <brahme.656264677@vlsic2>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!olivea!samsung!munnari.oz.au!lee
From: lee@munnari.oz.au (Lee Naish)
Newsgroups: comp.lang.prolog
Subject: Re: Standards question: behavior of arg/3
Keywords: ANSI, standard
Message-ID: <5817@munnari.oz.au>
Date: 19 Oct 90 09:18:17 GMT
References: <9888@bunny.GTE.COM> <brahme.656264677@vlsic2>
Sender: news@cs.mu.oz.au
Reply-To: lee@munmurra.UUCP (Lee Naish)
Organization: Comp Sci, University of Melbourne
Lines: 28