From: Philippe de R. <ph...@fr...> - 2017-09-05 17:55:47
|
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 <kis...@gm...> 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 <ph...@fr... <mailto:ph...@fr...>> 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 > ECL...@li... <mailto:ECL...@li...> > https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users <https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users> > > |