Re: [eclipse-clp-users] Issue with exported structures

From: Philippe de Rochambeau <phiroc_at_...22...>
Date: Tue, 5 Sep 2017 19:55:37 +0200
Hi,

let’s say, I have another .pl file with the following contents:

--------

:- compile('persons2').

:- import p2m.

top(
	[
		person{name:philippe,age:53,ba:bank_account{bal:1000}}
	],
	PMBL).

—————

How do I make ECLIPSe display PMBL’s value?

Best regards,

Philippe


> Le 5 sept. 2017 à 11:47, Kish Shen <kish.shen_at_...6...> a écrit :
> 
> Hi Philippe,
> 
> The module qualification :/2 is for predicates only. To use the other exported items, you need to import the module:
> 
> [eclipse 2]: import p2m.
> 
> Yes (0.00s cpu)
> 
> you can then use exported items from p2m unqualified:
> 
> [eclipse 6]: top([person{name:philippe,age:53,ba:bank_account{bal:1000}}],PMBL).
> 
> PMBL = [1000]
> Yes (0.00s cpu)
> 
> Cheers,
> 
> Kish
> 
> 
> 
> 
> 
> On Tue, Sep 5, 2017 at 7:21 AM, Philippe de Rochambeau <phiroc_at_...22... <mailto:phiroc_at_...22...>> wrote:
> Hello,
> 
> I’m having an issue with an exported structure:
> 
> When I run
> 
> 
> p2m:top(
> 	[
> 		p2m:person{name:philippe,age:50,p2m:ba:bank_account{bal:1000}}
> 	],PMBL).	
> 
> 
> I get the below warnings.
> 
> Any help would be much appreciated.
> 
> Philippe
> 
> 
> 
> —————
> 
> WARNING: Unrecognized structure name in module eclipse in
>     bank_account{bal : 1000}
> WARNING: Unrecognized structure name in module eclipse in
>     person{name : philippe, age : 53, p2m : ba : bank_account{bal : 1000}}
> 
> PMBL = []
> Yes (0.00s cpu)
> [eclipse 15]: p2m:top(
> 	[
> 		p2m:person{name:philippe,age:53,p2m:ba:bank_account{bal:1000}}
> 	],PMBL).			
> WARNING: Unrecognized structure name in module eclipse in
>     bank_account{bal : 1000}
> WARNING: Unrecognized structure name in module eclipse in
>     person{name : philippe, age : 53, p2m : ba : bank_account{bal : 1000}}
> 
> PMBL = []
> Yes (0.00s cpu)
> 
> 
> -------------
> 
> ——————————— code ——————————————
> 
> 
> /*
> 	Find people whose balance is above a certain limit.
> */
> 
> :- module(p2m).
> :- export top/2.
> :- export filterBalance/3.
> :- export top/2.
> :- lib(ic).
> :- export struct(bank_account(bal)).
> :- export struct(person(name,age,ba:bank_account)).
> 
> top(FamilyList, PersonsMatchingBalanceLimit) :-
> 		BalanceLimit = 0,
> 		filterBalance(BalanceLimit, FamilyList, Ys), PersonsMatchingBalanceLimit = Ys.
> 		
> filterBalance(BalanceLimit, Family, Ys) :-
> 	(
> 		% foreach person in family
> 		foreach(Person,Family),
> 		fromto(Ys,Ys2,Ys1,[]),
> 		param(BalanceLimit)
> 	do
> 		(
> 			person{ba:Bal} = Person,
> 			arg(1, Bal, Bal2),
> 			Bal2 #>= BalanceLimit -> Ys2=[Bal2|Ys1] ;
> 			Ys2=Ys1
> 		)	
> 	).
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot <http://sdm.link/slashdot>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net <mailto:ECLiPSe-CLP-Users_at_...419...ourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users <https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users>
> 
> 
Received on Tue Sep 05 2017 - 17:55:47 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST