Search a list of records: Difference between revisions

m
(Added Ada.)
Line 681:
</lang>
=={{header|Elena}}==
ELENA 3.4.x :
<lang elena>import extensions.;
import system'routines.;
public program()
{
[
var dataset := new object[]
({
new : { Name = "Lagos".; Population = 21.0r.; },
new : { Name = "Cairo".; Population = 15.2r.; },
new : { Name = "Kinshasa-Brazzaville".; Population = 11.3r.; },
new : { Name = "Greater Johannesburg".; Population = 7.55r.; },
new : { Name = "Mogadishu".; Population = 5.85r.; },
new : { Name = "Khartoum-Omdurman".; Population = 4.98r.; },
new : { Name = "Dar Es Salaam".; Population = 4.7r.; },
new : { Name = "Alexandria".; Population = 4.58r.; },
new : { Name = "Abidjan".; Population = 4.4r.; },
new : { Name = "LagosCasablanca".; Population = 21.0r3.98r; },
).};
{ Name = "Lagos". Population = 21.0r. },
{ Name = "Casablanca". Population = 3.98r. }
).
var index := dataset .selectBy(:r)(r => r.Name); .toArray; ().indexOfElement("Dar Es Salaam").;
console .printLine(index).;
var name := dataset .filterBy(:c)(c => c.Population < 5.0r); firstMember; Name.toArray().FirstMember.Name;
console .printLine(name).;
var namePopulation := dataset .filterBy(:c)(c Name;=> c.Name.startingWith:("A"); firstMember; Population).toArray().FirstMember.Population;
console .printLine(namePopulation)
]}</lang>
{{out}}
<pre>
Anonymous user