---------- Forwarded message ---------- From: Kish Shen <kish.shen_at_...6...> Date: Tue, Sep 5, 2017 at 10:47 AM Subject: Re: [eclipse-clp-users] Issue with exported structures To: Philippe de Rochambeau <phiroc_at_...22...> 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...> 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 > _______________________________________________ > ECLiPSe-CLP-Users mailing list > ECLiPSe-CLP-Users_at_lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users > >Received on Tue Sep 05 2017 - 09:55:41 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST