[eclipse-clp-users] List of Structures

From: Edgaonkar, Shrirang <Shrirang.Edgaonkar_at_nttdata.com>
Date: Mon, 2 Feb 2015 06:55:09 +0000
Dear Clp users,



    I have been working on the following problem for some time. I wish to filter the following List.



:- local struct( goodsinfo( goodsid, goodsname, price, saledate, term, zaikoamount, registerdate, categoryid, searchViews ) ).



Result = [goodsinfo(101, "laptop", "tablet", "iPad"), goodsinfo(102, "notebook",
 "pendrive", "tab")]



I am trying something like this

(foreach(goodsinfo( goodsid:GoodsId, goodsname, term, searchViews ),Result), fromto(List,Out,In,[]) do
    X[goodsid of goodsinfo] == 101 -> Out=[X|In] ; Out=In, writeln( X[goodsid of goodsinfo] )),



If goodsid = 101 then rest of the list should be ignored and filtered to get the following.



List = goodsinfo(101, "laptop", "tablet", "iPad").





Please help.



Thanks and Regards,

Shrirang Edgaonkar

______________________________________________________________________
Disclaimer: This email and any attachments are sent in strictest confidence
for the sole use of the addressee and may contain legally privileged,
confidential, and proprietary data. If you are not the intended recipient,
please advise the sender by replying promptly to this email and then delete
and destroy this email and any attachments without any further use, copying
or forwarding.
Received on Mon Feb 02 2015 - 06:59:22 CET

This archive was generated by hypermail 2.2.0 : Mon Feb 02 2015 - 21:13:16 CET